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

Rename --registry-poll-interval #2284

Merged
merged 1 commit into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions cmd/fluxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func main() {
memcachedTimeout = fs.Duration("memcached-timeout", time.Second, "maximum time to wait before giving up on memcached requests.")
memcachedService = fs.String("memcached-service", "memcached", "SRV service used to discover memcache servers.")

automationInterval = fs.Duration("automation-interval", 5*time.Minute, "period at which to check for image updates for automated workloads")
registryPollInterval = fs.Duration("registry-poll-interval", 5*time.Minute, "period at which to check for updated images")
registryRPS = fs.Float64("registry-rps", 50, "maximum registry requests per second per host")
registryBurst = fs.Int("registry-burst", defaultRemoteConnections, "maximum number of warmer connections to remote and memcache")
Expand Down Expand Up @@ -182,6 +183,7 @@ func main() {
)
fs.MarkDeprecated("registry-cache-expiry", "no longer used; cache entries are expired adaptively according to how often they change")
fs.MarkDeprecated("k8s-namespace-whitelist", "changed to --k8s-allow-namespace, use that instead")
fs.MarkDeprecated("registry-poll-interval", "changed to --automation-interval, use that instead")

var kubeConfig *string
{
Expand Down Expand Up @@ -245,6 +247,13 @@ func main() {
k8sruntime.ErrorHandlers = []func(error){logErrorUnlessAccessRelated}
// Argument validation

// Maintain backwards compatibility with the --registry-poll-interval
// flag, but only if the --automation-interval is not set to a custom
// (non default) value.
if fs.Changed("registry-poll-interval") && !fs.Changed("automation-interval") {
*automationInterval = *registryPollInterval
}

// Sort out values for the git tag and notes ref. There are
// running deployments that assume the defaults as given, so don't
// mess with those unless explicitly told.
Expand Down Expand Up @@ -595,10 +604,10 @@ func main() {
Logger: log.With(logger, "component", "daemon"),
ManifestGenerationEnabled: *manifestGeneration,
LoopVars: &daemon.LoopVars{
SyncInterval: *syncInterval,
RegistryPollInterval: *registryPollInterval,
GitTimeout: *gitTimeout,
GitVerifySignatures: *gitVerifySignatures,
SyncInterval: *syncInterval,
AutomationInterval: *automationInterval,
GitTimeout: *gitTimeout,
GitVerifySignatures: *gitVerifySignatures,
},
}

Expand Down Expand Up @@ -634,7 +643,7 @@ func main() {
shutdownWg.Add(1)
go daemon.Loop(shutdown, shutdownWg, log.With(logger, "component", "sync-loop"))

cacheWarmer.Notify = daemon.AskForImagePoll
cacheWarmer.Notify = daemon.AskForAutomatedWorkloadImageUpdates
cacheWarmer.Priority = daemon.ImageRefresh
cacheWarmer.Trace = *registryTrace
shutdownWg.Add(1)
Expand Down
2 changes: 1 addition & 1 deletion daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ func (d *Daemon) updatePolicies(spec update.Spec, updates resource.PolicyUpdates
return result, err
}
if anythingAutomated {
d.AskForImagePoll()
d.AskForAutomatedWorkloadImageUpdates()
}

var err error
Expand Down
4 changes: 2 additions & 2 deletions daemon/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/weaveworks/flux/update"
)

func (d *Daemon) pollForNewImages(logger log.Logger) {
logger.Log("msg", "polling images")
func (d *Daemon) pollForNewAutomatedWorkloadImages(logger log.Logger) {
logger.Log("msg", "polling for new images for automated workloads")

ctx := context.Background()

Expand Down
42 changes: 21 additions & 21 deletions daemon/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ import (
)

type LoopVars struct {
SyncInterval time.Duration
RegistryPollInterval time.Duration
GitTimeout time.Duration
GitVerifySignatures bool

initOnce sync.Once
syncSoon chan struct{}
pollImagesSoon chan struct{}
SyncInterval time.Duration
AutomationInterval time.Duration
GitTimeout time.Duration
GitVerifySignatures bool

initOnce sync.Once
syncSoon chan struct{}
automatedWorkloadsSoon chan struct{}
}

func (loop *LoopVars) ensureInit() {
loop.initOnce.Do(func() {
loop.syncSoon = make(chan struct{}, 1)
loop.pollImagesSoon = make(chan struct{}, 1)
loop.automatedWorkloadsSoon = make(chan struct{}, 1)
})
}

Expand All @@ -38,7 +38,7 @@ func (d *Daemon) Loop(stop chan struct{}, wg *sync.WaitGroup, logger log.Logger)
syncTimer := time.NewTimer(d.SyncInterval)
// Similarly checking to see if any controllers have new images
// available.
imagePollTimer := time.NewTimer(d.RegistryPollInterval)
automatedWorkloadTimer := time.NewTimer(d.AutomationInterval)

// Keep track of current, verified (if signature verification is
// enabled), HEAD, so we can know when to treat a repo
Expand All @@ -49,26 +49,26 @@ func (d *Daemon) Loop(stop chan struct{}, wg *sync.WaitGroup, logger log.Logger)
// In-memory sync tag state
lastKnownSyncTag := &lastKnownSyncTag{logger: logger, syncTag: d.GitConfig.SyncTag}

// Ask for a sync, and to poll images, straight away
// Ask for a sync, and to check
d.AskForSync()
d.AskForImagePoll()
d.AskForAutomatedWorkloadImageUpdates()

for {
select {
case <-stop:
logger.Log("stopping", "true")
return
case <-d.pollImagesSoon:
if !imagePollTimer.Stop() {
case <-d.automatedWorkloadsSoon:
if !automatedWorkloadTimer.Stop() {
select {
case <-imagePollTimer.C:
case <-automatedWorkloadTimer.C:
default:
}
}
d.pollForNewImages(logger)
imagePollTimer.Reset(d.RegistryPollInterval)
case <-imagePollTimer.C:
d.AskForImagePoll()
d.pollForNewAutomatedWorkloadImages(logger)
automatedWorkloadTimer.Reset(d.AutomationInterval)
case <-automatedWorkloadTimer.C:
d.AskForAutomatedWorkloadImageUpdates()
case <-d.syncSoon:
if !syncTimer.Stop() {
select {
Expand Down Expand Up @@ -150,10 +150,10 @@ func (d *LoopVars) AskForSync() {
}

// Ask for an image poll, or if there's one waiting, let that happen.
func (d *LoopVars) AskForImagePoll() {
func (d *LoopVars) AskForAutomatedWorkloadImageUpdates() {
d.ensureInit()
select {
case d.pollImagesSoon <- struct{}{}:
case d.automatedWorkloadsSoon <- struct{}{}:
default:
}
}
Expand Down
3 changes: 2 additions & 1 deletion site/daemon.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ fluxd requires setup and offers customization though a multitude of flags.
| **syncing:** control over how config is applied to the cluster
| --sync-interval | `5m` | apply the git config to the cluster at least this often. New commits may provoke more frequent syncs
| --sync-garbage-collection | `false` | experimental: when set, fluxd will delete resources that it created, but are no longer present in git (see [garbage collection](./garbagecollection.md))
| **automation (of image updates):**
| --automation-interval | `5m` | period at which to check for image updates for automated workloads
| **registry cache:** (none of these need overriding, usually)
| --memcached-hostname | `memcached` | hostname for memcached service to use for caching image metadata
| --memcached-timeout | `1s` | maximum time to wait before giving up on memcached requests
| --memcached-service | `memcached` | SRV service used to discover memcache servers
| --registry-cache-expiry | `1h` | Duration to keep cached registry tag info. Must be < 1 month.
| --registry-poll-interval | `5m` | period at which to poll registry for new images
| --registry-rps | `200` | maximum registry requests per second per host
| --registry-burst | `125` | maximum number of warmer connections to remote and memcache
| --registry-insecure-host | [] | registry hosts to use HTTP for (instead of HTTPS)
Expand Down
2 changes: 1 addition & 1 deletion site/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ See also
by default.

The latter default is quite conservative, so you can try lowering it
(it's set with the flag `--registry-poll-interval`).
(it's set with the flag `--automation-interval`).

Please don't _increase_ the rate limiting numbers (`--registry-rps`
and `--registry-burst`) -- it's possible to get blacklisted by image
Expand Down
2 changes: 1 addition & 1 deletion test/flux-deploy-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ spec:
- --git-url=ssh://docker@MINIKUBE_IP:/home/docker/flux.git
- --git-branch=master
# Tune up to make tests run quicker
- --registry-poll-interval=60s
- --automation-interval=60s
- --git-poll-interval=60s