-
Notifications
You must be signed in to change notification settings - Fork 858
fix: prepend agones sidecars before user defined init containers #4240
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
base: main
Are you sure you want to change the base?
fix: prepend agones sidecars before user defined init containers #4240
Conversation
@Sivasankaran25 @0xaravindh sorry for a ping but is this syntax legal in Golang? I see that it is a vararg I'm not sure if ... unpack operator works for slices. Another way to do it: import "slices"
pod.Spec.InitContainers = slices.Concat(sidecars, pod.Spec.InitContainers) but this requires go 1.22+ |
@stevefan1999-personal yes, since we're already using Go 1.24, it's safe to use slices.Concat() — no issues there. #slices |
Oh that's a really good catch! My only extra thought - might be worth adding a unit test to make sure that the sdk-server sidecar is always first, and we don't ever have a regression. No strong opinions on which slice syntax is used 😄 |
/gcbrun |
Build Failed 😭 Build Id: b191037d-1958-41e8-9068-ab10a026abe9 Status: FAILURE To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
/gcbrun |
/gcbrun submit-e2e-test-cloud-build is still flaky. |
Build Failed 😭 Build Id: 2d520d12-cba1-4178-9e1c-96c819c2e196 Status: FAILURE To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
/gcbrun |
Build Failed 😭 Build Id: ca564f19-822c-4573-a93e-5eb0dc0ae8ec Status: FAILURE To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Ignore the errors for now - CI is pretty borked |
/gcbrun |
I'd still love a unit test here so we never regress this change. |
Build Failed 😭 Build Id: 404943de-1fd1-4011-a130-0bea2e3f4863 Status: FAILURE To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Overview
This PR addresses and closes #4239 by fixing a critical initialization order issue with the Agones SDK init container that causes deadlocks in certain deployment configurations.
Problem Description
Discovery Context
I discovered this issue while working with a custom init container setup for our game server deployments. Our initialization workflow includes an init container responsible for:
This initialization process has a critical dependency: it requires the Agones SDK to be fully initialized and accessible before it can proceed with port allocation and server registration tasks.
The Deadlock Scenario
Kubernetes init containers execute sequentially in the order they are defined in the pod specification. Each init container must complete successfully before the next one begins execution. This sequential execution pattern is where our problem manifests:
Root Cause Analysis
The core issue stems from the container injection order. When Agones adds the SDK init container to the final pod specification, it appends it to the existing init containers array rather than prepending it. This breaks the assumption that the Agones SDK will be available for other init containers that depend on it.
Solution
This PR modifies the container injection logic to ensure the Agones SDK init container is placed at the beginning of the init containers array, guaranteeing it initializes before any user-defined init containers that may depend on its functionality.
Impact & Benefits
Testing Performed