-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add authenticated controller status reporting #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dcccbeb
feat: add authenticated controller status reporting
Nickfost 9bf0fb1
fix: harden status reporting edge cases
Nickfost 9f7a924
fix: close status reporting boundary gaps
Nickfost 688a98a
fix: enforce status transport boundaries
Nickfost 5ea4a67
fix: keep status snapshots consistent and fresh
Nickfost f3d8c12
fix: expose invalid status observations
Nickfost 0039a43
fix: preserve reporting cutover guarantees
Nickfost 7e14e6b
fix: preserve health metric semantics
Nickfost 6632562
fix: preserve legacy probes and runner truth
Nickfost 6598d71
test: join status publisher before cleanup
Nickfost 6938d1d
fix: make runner exit completion idempotent
Nickfost 7bda4e1
fix: enforce cleanup and retention continuously
Nickfost e0caefd
fix: retain cleanup and reporting invariants
Nickfost a45ab8e
fix: close replay and maintenance races
Nickfost fb46a3f
fix: bound authenticated request handling
Nickfost 8d9422b
fix: distinguish wait completion from failure
Nickfost 1280054
fix: reject errored Docker wait responses
Nickfost 0a1761b
fix: address final review findings
Nickfost File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "os" | ||
| "path/filepath" | ||
| "sync" | ||
| "time" | ||
| ) | ||
|
|
||
| var statusWriteMu sync.Mutex | ||
| var encodeControllerStatus = func(file *os.File, value controllerStatus) error { | ||
| return json.NewEncoder(file).Encode(value) | ||
| } | ||
|
|
||
| type controllerStatus struct { | ||
| Controller string `json:"controller"` | ||
| SoftwareVersion string `json:"software_version"` | ||
| Current int `json:"current"` | ||
| Busy int `json:"busy"` | ||
| Maximum int `json:"maximum"` | ||
| GeneratedAt int64 `json:"generated_at"` | ||
| } | ||
|
|
||
| func (s *Scaler) writeStatus() { | ||
| statusWriteMu.Lock() | ||
| defer statusWriteMu.Unlock() | ||
| current, busy := s.runners.counts() | ||
| softwareVersion := commitSHA | ||
| if softwareVersion == "unknown" { softwareVersion = version } | ||
| value := controllerStatus{ | ||
| Controller: s.config.FleetInstance, SoftwareVersion: softwareVersion, | ||
| Current: current, Busy: busy, Maximum: s.config.MaxRunners, GeneratedAt: time.Now().Unix(), | ||
|
Nickfost marked this conversation as resolved.
|
||
| } | ||
| directory := filepath.Dir(s.config.StatusFile) | ||
| if err := os.MkdirAll(directory, 0o755); err != nil { | ||
| s.logger.Warn("write controller status", "error", err) | ||
| return | ||
| } | ||
| temporary, err := os.CreateTemp(directory, ".status-*") | ||
| if err != nil { | ||
| s.logger.Warn("write controller status", "error", err) | ||
| return | ||
| } | ||
| name := temporary.Name() | ||
| defer os.Remove(name) | ||
|
Nickfost marked this conversation as resolved.
|
||
| if err = temporary.Chmod(0o644); err == nil { | ||
| err = encodeControllerStatus(temporary, value) | ||
| } | ||
| if closeErr := temporary.Close(); err == nil { err = closeErr } | ||
| if err == nil { err = os.Rename(name, s.config.StatusFile) } | ||
|
Nickfost marked this conversation as resolved.
|
||
| if err != nil { s.logger.Warn("write controller status", "error", err) } | ||
| } | ||
|
|
||
| func (s *Scaler) publishStatus(ctx context.Context, interval time.Duration) { | ||
| ticker := time.NewTicker(interval) | ||
| defer ticker.Stop() | ||
| for { | ||
| select { | ||
| case <-ctx.Done(): | ||
| return | ||
| case <-ticker.C: | ||
| s.writeStatus() | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.