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

Cleanup the nested loops in the main func of attache-control #6

Closed
beautifulentropy opened this issue Nov 23, 2021 · 0 comments · Fixed by #24
Closed

Cleanup the nested loops in the main func of attache-control #6

beautifulentropy opened this issue Nov 23, 2021 · 0 comments · Fixed by #24

Comments

@beautifulentropy
Copy link
Member

Cleaning up these nested loops will make it easier to reason about the code.

beautifulentropy added a commit that referenced this issue Feb 4, 2022
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant