Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Make update interval a configurable flag
Browse files Browse the repository at this point in the history
As in clusters that have many `HelmRelease` resources, the hardcoded
default would put too much pressure on `etcd` due to Tiller collecting
information. By making the interval a configurable flag, people can
tweak the value to find the right balance of (non) pressure and
observability.
  • Loading branch information
hiddeco committed Sep 23, 2019
1 parent cdb4536 commit 91c0b11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 6 additions & 4 deletions cmd/helm-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ var (
tillerTLSCACert *string
tillerTLSHostname *string

chartsSyncInterval *time.Duration
logReleaseDiffs *bool
updateDependencies *bool
chartsSyncInterval *time.Duration
statusUpdateInterval *time.Duration
logReleaseDiffs *bool
updateDependencies *bool

gitTimeout *time.Duration
gitPollInterval *time.Duration
Expand Down Expand Up @@ -104,6 +105,7 @@ func init() {
tillerTLSHostname = fs.String("tiller-tls-hostname", "", "server name used to verify the hostname on the returned certificates from the server")

chartsSyncInterval = fs.Duration("charts-sync-interval", 3*time.Minute, "period on which to reconcile the Helm releases with HelmRelease resources")
statusUpdateInterval = fs.Duration("status-update-interval", 10*time.Second, "period on which to update the Helm release status in HelmRelease resources")
logReleaseDiffs = fs.Bool("log-release-diffs", false, "log the diff when a chart release diverges; potentially insecure")
updateDependencies = fs.Bool("update-chart-deps", true, "update chart dependencies before installing/upgrading a release")

Expand Down Expand Up @@ -226,7 +228,7 @@ func main() {
// the status updater, to keep track of the release status for
// every HelmRelease
statusUpdater := status.New(ifClient, hrInformer.Lister(), helmClient)
go statusUpdater.Loop(shutdown, log.With(logger, "component", "statusupdater"))
go statusUpdater.Loop(shutdown, *statusUpdateInterval, log.With(logger, "component", "statusupdater"))

// start HTTP server
go daemonhttp.ListenAndServe(*listenAddr, chartSync, log.With(logger, "component", "daemonhttp"), shutdown)
Expand Down
9 changes: 2 additions & 7 deletions pkg/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
kube "k8s.io/client-go/kubernetes"
"k8s.io/helm/pkg/helm"
helmrelease "k8s.io/helm/pkg/proto/hapi/release"

Expand All @@ -30,14 +29,10 @@ import (
iflister "github.com/fluxcd/helm-operator/pkg/client/listers/helm.fluxcd.io/v1"
)

const period = 10 * time.Second

type Updater struct {
hrClient ifclientset.Interface
hrLister iflister.HelmReleaseLister
kube kube.Interface
helmClient *helm.Client
namespace string
}

func New(hrClient ifclientset.Interface, hrLister iflister.HelmReleaseLister, helmClient *helm.Client) *Updater {
Expand All @@ -48,8 +43,8 @@ func New(hrClient ifclientset.Interface, hrLister iflister.HelmReleaseLister, he
}
}

func (u *Updater) Loop(stop <-chan struct{}, logger log.Logger) {
ticker := time.NewTicker(period)
func (u *Updater) Loop(stop <-chan struct{}, interval time.Duration, logger log.Logger) {
ticker := time.NewTicker(interval)
var logErr error

bail:
Expand Down

0 comments on commit 91c0b11

Please sign in to comment.