Repository navigation
fix(operator): fence workloads until wipe workers drain #619
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
ValgulNecron
merged 10 commits into
GameplanePanel:master
from
Baylem:fix/production-wipe
Oct 16, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d91f011
fix(operator): fence workloads until wipe workers drain
Baylem 4fa43cb
fix: preserve a coherent snapshot during wipe preflight
Baylem 43f3693
test: register wipe jobs in missing-template fixture
Baylem 54cf527
fix: preserve idle snapshot across capture status writes
Baylem ffa86c9
fix: recover workload guards after restore completion
Baylem 5154eb1
ci: retry checks after runner package installation stalled
Baylem 7006d7a
fix(operator): reuse wipe worker inventory within reconciliation
Baylem 3f97222
docs(operator): clarify wipe guard release preconditions
Baylem 2cad5d5
test(operator): avoid envtest scheme name collision
Baylem fa23541
fix(operator): stop fast polling settled wipe failures
Baylem 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
85 changes: 85 additions & 0 deletions
85
operator/internal/controller/gameserver_capture_status_test.go
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,85 @@ | ||
| package controller | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "testing" | ||
| "time" | ||
|
|
||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| "sigs.k8s.io/controller-runtime/pkg/client/fake" | ||
| "sigs.k8s.io/controller-runtime/pkg/client/interceptor" | ||
|
|
||
| gameplanev1alpha1 "github.com/GameplanePanel/gameplane/operator/api/v1alpha1" | ||
| ) | ||
|
|
||
| func TestCaptureStatusPatchPreservesConcurrentIdleClock(t *testing.T) { | ||
| for _, captureWasReady := range []bool{false, true} { | ||
| t.Run(fmt.Sprintf("captureWasReady=%t", captureWasReady), func(t *testing.T) { | ||
| gs := wipeGameServer(false, "") | ||
| gs.Spec.Idle = enabledIdle(5) | ||
| now := metav1.NewTime(time.Now().UTC().Truncate(time.Second)) | ||
| oldHeartbeat := metav1.NewTime(now.Add(-time.Second)) | ||
| recent := metav1.NewTime(now.Add(-time.Minute)) | ||
| backdated := metav1.NewTime(now.Add(-10 * time.Minute)) | ||
| players := int32(0) | ||
| gs.Status.Phase = gameplanev1alpha1.GameServerPhaseRunning | ||
| gs.Status.Agent = &gameplanev1alpha1.AgentStatus{LastHeartbeat: &oldHeartbeat, PlayersOnline: &players} | ||
| gs.Status.Idle = &gameplanev1alpha1.IdleStatus{EmptySince: &recent} | ||
| gs.Status.Capture = &gameplanev1alpha1.CaptureStatus{Ready: captureWasReady} | ||
| ss := wipeStoppedSet(gs) | ||
| one := int32(1) | ||
| ss.Spec.Replicas = &one | ||
| ss.Status.Replicas, ss.Status.ReadyReplicas = 1, 1 | ||
| injected := false | ||
| c := fake.NewClientBuilder().WithScheme(testScheme(t)).WithObjects(gs, ss).WithStatusSubresource(gs, ss). | ||
| WithInterceptorFuncs(interceptor.Funcs{ | ||
| SubResourcePatch: func(ctx context.Context, c client.Client, subresource string, obj client.Object, patch client.Patch, opts ...client.SubResourcePatchOption) error { | ||
| if subresource == "status" && !injected { | ||
| injected = true | ||
| var current gameplanev1alpha1.GameServer | ||
| if err := c.Get(ctx, client.ObjectKeyFromObject(gs), ¤t); err != nil { | ||
| return err | ||
| } | ||
| // Model a clock backdate and fresh agent heartbeat arriving | ||
| // after idle derivation but during the capture status write. | ||
| current.Status.Idle.EmptySince = &backdated | ||
| current.Status.Agent.LastHeartbeat = &now | ||
| if err := c.Status().Update(ctx, ¤t); err != nil { | ||
| return err | ||
| } | ||
| } | ||
| return c.SubResource(subresource).Patch(ctx, obj, patch, opts...) | ||
| }, | ||
| }).Build() | ||
| r := &GameServerReconciler{Client: c, Scheme: c.Scheme()} | ||
| idle, idleStatus, _, scheduleErr, err := r.reconcileIdle(t.Context(), gs) | ||
| if err != nil || idle != idleAwake || idleStatus == nil || idleStatus.EmptySince == nil || !idleStatus.EmptySince.Equal(&recent) { | ||
| t.Fatalf("initial idle derivation: state=%v err=%v", idle, err) | ||
| } | ||
| if err := r.reconcileCapture(t.Context(), gs); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if _, err := r.reconcileStatus(t.Context(), gs, idle, idleStatus, scheduleErr, tunnelPlan{}, &gameplanev1alpha1.GameTemplate{}, nil, ""); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| current := wipeCurrent(t, c, gs) | ||
| if !injected || current.Status.Idle == nil || current.Status.Idle.EmptySince == nil || !current.Status.Idle.EmptySince.Equal(&backdated) { | ||
| t.Fatal("final status merge overwrote the concurrently backdated idle clock") | ||
| } | ||
| if current.Status.Agent == nil || current.Status.Agent.LastHeartbeat == nil || !current.Status.Agent.LastHeartbeat.Equal(&now) { | ||
| t.Fatal("status merge overwrote the fresh agent heartbeat") | ||
| } | ||
| if current.Status.Capture == nil || current.Status.Capture.Ready { | ||
| t.Fatal("disabled capture status was not persisted") | ||
| } | ||
| // The preserved backdate must drive the next sleep decision, | ||
| // rather than silently resetting the server's idle interval. | ||
| nextIdle, _, _, _, err := r.reconcileIdle(t.Context(), current) | ||
| if err != nil || nextIdle != idleAsleep || current.Annotations[IdleAsleepSinceAnnotation] == "" { | ||
| t.Fatalf("backdated clock did not produce sleep: state=%v err=%v", nextIdle, err) | ||
| } | ||
| }) | ||
| } | ||
| } |
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
Oops, something went wrong.
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.