Skip to content
This repository was archived by the owner on Jan 26, 2023. It is now read-only.

Commit 6e528e5

Browse files
Make attache-control a long running sidecar (#24)
Previous to this change, we've avoided hashicorp/nomad#10058 by adding a long sleep before attache-control would otherwise exit successfully. Unfortunately this still means that subsequent scaling deployments will fail if the sleep incurred from the initial deployment has expired. This change makes attache-control a proper sidecar (long running ephemeral post-start task). Instead of exiting after a successful run, attache-control will stop the ticker channel and continue running until it receives a kill signal. - Configure attache-control as a side-car in the example nomad job - Remove attempt-limit flag and cliOpts.attemptLimit - Split the main func of attache-control into helpers - Add helper methods to scalingOpts - Replace calls to time.Tick with time.NewTicker - Add renewChan (chan struct{}) and acquired (bool) to the lock struct - lock.Acquire() sets lock.acquired to true, initializes lock.renewChan, and calls lock.periodicallyRenew() in a long-running go-routine - lock.Cleanup() closes lock.renewChan and sets lock.acquired to false Fixes #6 Part Of #11
1 parent b2bb0e3 commit 6e528e5

File tree

8 files changed

+273
-233
lines changed

8 files changed

+273
-233
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ $ ./attache-control -help
5757
Usage of ./attache-control:
5858
-attempt-interval duration
5959
Duration to wait between attempts to join or create a cluster (e.g. '1s') (default 3s)
60-
-attempt-limit int
61-
Number of times to join or create a cluster before exiting (default 20)
6260
-await-service-name string
6361
Consul Service for newly created Redis Cluster Nodes, (required)
6462
-consul-acl-token string

cmd/attache-control/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ type cliOpts struct {
2020
// cluster.
2121
attemptInterval time.Duration
2222

23-
// attemptLimit is the number of times to attempt joining or creating a cluster before Attache
24-
// should exit as failed.
25-
attemptLimit int
26-
2723
// awaitServiceName is the name of the Consul Service that newly created
2824
// Redis Cluster nodes will join when they're first started but have yet to
2925
// form or join a cluster. This field is required.
@@ -102,7 +98,6 @@ func ParseFlags() cliOpts {
10298
// CLI
10399
flag.StringVar(&conf.lockPath, "lock-kv-path", "service/attache/leader", "Consul KV path to use as a leader lock for Redis Cluster operations")
104100
flag.DurationVar(&conf.attemptInterval, "attempt-interval", 3*time.Second, "Duration to wait between attempts to join or create a cluster (e.g. '1s')")
105-
flag.IntVar(&conf.attemptLimit, "attempt-limit", 20, "Number of times to attempt join or create a cluster before exiting")
106101
flag.StringVar(&conf.awaitServiceName, "await-service-name", "", "Consul Service for newly created Redis Cluster Nodes, (required)")
107102
flag.StringVar(&conf.destServiceName, "dest-service-name", "", "Consul Service for healthy Redis Cluster Nodes, (required)")
108103
flag.StringVar(&conf.logLevel, "log-level", "info", "Set the log level")

0 commit comments

Comments
 (0)