-
Notifications
You must be signed in to change notification settings - Fork 890
fix: Ensure we set ports / addresses while waiting for pod IPs #4095
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?
Changes from all commits
5944adc
fc9b8d2
70cd30f
3e1a602
329bf81
f55f2e1
37dcef7
359abf6
e8646ad
2eeb51e
095cd3c
2667a7c
3c4dc9a
13dd475
9312bcd
0023936
d83d0e2
8c66673
8971843
7c44bbd
6309f55
20b89a4
ae72407
9730c94
49c911f
4b6d17d
23f928d
8d8c27c
fd467fd
a6af646
a491f30
5c45723
d6293c6
aabd5fb
0b66d2f
010a278
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -576,9 +576,8 @@ func (c *Controller) syncGameServerCreatingState(ctx context.Context, gs *agones | |
| loggerForGameServer(gs, c.baseLogger).Debug("Syncing Create State") | ||
|
|
||
| // Maybe something went wrong, and the pod was created, but the state was never moved to Starting, so let's check | ||
| _, err := c.gameServerPod(gs) | ||
| pod, err := c.gameServerPod(gs) | ||
| if k8serrors.IsNotFound(err) { | ||
|
|
||
| for i := range gs.Spec.Ports { | ||
| if gs.Spec.Ports[i].PortPolicy == agonesv1.Static && gs.Spec.Ports[i].Protocol == agonesv1.ProtocolTCPUDP { | ||
| name := gs.Spec.Ports[i].Name | ||
|
|
@@ -607,6 +606,9 @@ func (c *Controller) syncGameServerCreatingState(ctx context.Context, gs *agones | |
| } | ||
|
|
||
| gsCopy := gs.DeepCopy() | ||
|
|
||
| gsCopy, _ = applyGameServerPodIP(gsCopy, pod) | ||
|
|
||
| gsCopy.Status.State = agonesv1.GameServerStateStarting | ||
| gs, err = c.gameServerGetter.GameServers(gs.ObjectMeta.Namespace).Update(ctx, gsCopy, metav1.UpdateOptions{}) | ||
| if err != nil { | ||
|
|
@@ -906,11 +908,6 @@ func (c *Controller) syncGameServerStartingState(ctx context.Context, gs *agones | |
| return gs, workerqueue.NewTraceError(errors.Errorf("node not yet populated for Pod %s", pod.ObjectMeta.Name)) | ||
| } | ||
|
|
||
| // Ensure the pod IPs are populated | ||
| if len(pod.Status.PodIPs) == 0 { | ||
| return gs, workerqueue.NewTraceError(errors.Errorf("pod IPs not yet populated for Pod %s", pod.ObjectMeta.Name)) | ||
| } | ||
|
|
||
| node, err := c.nodeLister.Get(pod.Spec.NodeName) | ||
| if err != nil { | ||
| return gs, errors.Wrapf(err, "error retrieving node %s for Pod %s", pod.Spec.NodeName, pod.ObjectMeta.Name) | ||
|
|
@@ -921,6 +918,8 @@ func (c *Controller) syncGameServerStartingState(ctx context.Context, gs *agones | |
| return gs, err | ||
| } | ||
|
|
||
| gsCopy, _ = applyGameServerPodIP(gsCopy, pod) | ||
|
|
||
| gsCopy.Status.State = agonesv1.GameServerStateScheduled | ||
| gs, err = c.gameServerGetter.GameServers(gs.ObjectMeta.Namespace).Update(ctx, gsCopy, metav1.UpdateOptions{}) | ||
| if err != nil { | ||
|
|
@@ -954,12 +953,28 @@ func (c *Controller) syncGameServerRequestReadyState(ctx context.Context, gs *ag | |
| return nil, err | ||
| } | ||
|
|
||
| var gsUpdated bool | ||
|
|
||
| gsCopy, podIPUpdated := applyGameServerPodIP(gsCopy, pod) | ||
| if podIPUpdated { | ||
| // defer the update of the GameServer until the end of this function | ||
| // in case there is no gs state update and the podIP is available and populated | ||
| defer func(gs *agonesv1.GameServer, alreadyUpdated *bool) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This freaks me out a bunch 😆 - but you still end up with a double update, which seems unnecessary. The way I wanted to this work was that whenever the Pod IP is updated, then the GameServer gets updated - unless it's already captured in an existing status update. We shouldn't need to have a double updated if it's already seen inside one of these status change sync functions. |
||
| // Only update if the GameServer is not already updated | ||
| if alreadyUpdated == nil || *alreadyUpdated { | ||
| return | ||
| } | ||
| _, _ = c.gameServerGetter.GameServers(gs.ObjectMeta.Namespace).Update(ctx, gs, metav1.UpdateOptions{}) | ||
| }(gsCopy, &gsUpdated) | ||
| } | ||
|
|
||
| // if the address hasn't been populated, and the Ready request comes | ||
| // before the controller has had a chance to do it, then | ||
| // do it here instead | ||
| addressPopulated := false | ||
| if gs.Status.NodeName == "" { | ||
| if gsCopy.Status.NodeName == "" { | ||
| addressPopulated = true | ||
|
|
||
| if pod.Spec.NodeName == "" { | ||
| return gs, workerqueue.NewTraceError(errors.Errorf("node not yet populated for Pod %s", pod.ObjectMeta.Name)) | ||
| } | ||
|
|
@@ -978,6 +993,9 @@ func (c *Controller) syncGameServerRequestReadyState(ctx context.Context, gs *ag | |
| return gs, err | ||
| } | ||
|
|
||
| // if the address is already populated, then we don't need to re-update for podIPs | ||
| gsUpdated = true | ||
|
|
||
| gsCopy.Status.State = agonesv1.GameServerStateReady | ||
| gs, err = c.gameServerGetter.GameServers(gs.ObjectMeta.Namespace).Update(ctx, gsCopy, metav1.UpdateOptions{}) | ||
| if err != nil { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.