-
Notifications
You must be signed in to change notification settings - Fork 128
Rolling updates for versiond-managed binaries (blue/green + drain, part 1 of #1367) #1437
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
Open
snevolin
wants to merge
24
commits into
gonka-ai:ak/pixelplex-refactoring-into-r2
Choose a base branch
from
snevolin:sn/versiond-rolling-updates
base: ak/pixelplex-refactoring-into-r2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
47aa9c0
Add rolling updates for versiond-managed binaries.
snevolin 05062a3
Fixed versiond rolling update compatibility issues
snevolin b6aaf3e
Fixed remaining versiond rolling update issues
snevolin 3821ae1
Harden versiond rolling update edge cases.
snevolin 6694b02
Clean up versiond rolling update style.
snevolin 9136cfc
Harden versiond rolling update validation.
snevolin c1fb3ea
Add versiond rolling update testermint coverage.
snevolin 5cfbfae
Preserve devshard grace during versiond shutdown
snevolin 953123f
Move devshard lifecycle endpoints to admin listener
snevolin d75005b
Extend legacy drain grace default
snevolin 8aeb8b1
Drain removed versiond children asynchronously
snevolin 83bc2ce
Reuse released versiond child ports
snevolin 9d84158
Gate versiond rolling overlap by storage mode
snevolin 9f7f340
Add full-stack versiond rolling update tests
snevolin 89c0b1e
Close lifecycle drain admission race
snevolin b879f3a
Track proxy requests across route swaps
snevolin d7e9afe
Defer version re-adds until drain completes
snevolin 592cca8
Match override identity before skipping restart
snevolin dba49df
Promote legacy versiond installs lazily
snevolin 000f6d5
Supervise child shutdown with a process FSM
snevolin 4f66fc2
Require public health before routing children
snevolin e586a2d
Return child port allocation errors
snevolin 035daa3
Merge latest pixelplex refactoring into rolling updates
snevolin cb21777
refactor(testenv): name stack tests by behavior
snevolin 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package events | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestListenerReadyHandler(t *testing.T) { | ||
| l := NewListener("http://localhost:26657") | ||
| var states []bool | ||
| l.OnReady(func(ready bool) { | ||
| states = append(states, ready) | ||
| }) | ||
|
|
||
| l.setReady(true) | ||
| l.setReady(false) | ||
|
|
||
| require.Equal(t, []bool{true, false}, states) | ||
| } |
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,74 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "strings" | ||
| "sync/atomic" | ||
|
|
||
| "devshard/observability" | ||
|
|
||
| "github.com/labstack/echo/v4" | ||
| ) | ||
|
|
||
| type lifecycleState struct { | ||
| ready atomic.Bool | ||
| draining atomic.Bool | ||
| inflight atomic.Int64 | ||
| } | ||
|
|
||
| type drainStatus struct { | ||
| Ready bool `json:"ready"` | ||
| Draining bool `json:"draining"` | ||
| Inflight int64 `json:"inflight"` | ||
| } | ||
|
|
||
| func newLifecycleState() *lifecycleState { | ||
| observability.SetLifecycleInflight(0) | ||
| return &lifecycleState{} | ||
| } | ||
|
|
||
| func (s *lifecycleState) SetReady(ready bool) { | ||
| s.ready.Store(ready) | ||
| } | ||
|
|
||
| func (s *lifecycleState) StartDrain() { | ||
| s.draining.Store(true) | ||
| s.ready.Store(false) | ||
| } | ||
|
|
||
| func (s *lifecycleState) Status() drainStatus { | ||
| return drainStatus{ | ||
| Ready: s.ready.Load(), | ||
| Draining: s.draining.Load(), | ||
| Inflight: s.inflight.Load(), | ||
| } | ||
| } | ||
|
|
||
| func (s *lifecycleState) addInflight(delta int64) { | ||
| inflight := s.inflight.Add(delta) | ||
| observability.SetLifecycleInflight(inflight) | ||
| } | ||
|
|
||
| func (s *lifecycleState) middleware(next echo.HandlerFunc) echo.HandlerFunc { | ||
| return func(c echo.Context) error { | ||
| if isLifecycleBypassPath(c.Request().URL.Path) { | ||
| return next(c) | ||
| } | ||
| if s.draining.Load() { | ||
| return echo.NewHTTPError(http.StatusServiceUnavailable, "devshardd is draining") | ||
| } | ||
| s.addInflight(1) | ||
| defer s.addInflight(-1) | ||
| return next(c) | ||
| } | ||
| } | ||
|
|
||
| func isLifecycleBypassPath(path string) bool { | ||
| clean := "/" + strings.Trim(strings.TrimSpace(path), "/") | ||
| switch clean { | ||
| case "/healthz", "/metrics": | ||
| return true | ||
| default: | ||
| return false | ||
| } | ||
| } | ||
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.