diff --git a/pkg/cloudproduct/gke/gke.go b/pkg/cloudproduct/gke/gke.go index 22c1770bd9..a598db0f1f 100644 --- a/pkg/cloudproduct/gke/gke.go +++ b/pkg/cloudproduct/gke/gke.go @@ -162,7 +162,7 @@ func (*gkeAutopilot) MutateGameServerPod(gss *agonesv1.GameServerSpec, pod *core } // setPassthroughLabel sets the agones.dev/port: "autopilot-passthrough" label to the game server container. -// This will help to back the container port from the allocated port using an objectSelect of this label +// This will help to back the container port from the allocated port using an objectSelector of this label // in GameServers that are using Passthrough Port Policy func setPassthroughLabel(gs *agonesv1.GameServerSpec, pod *corev1.Pod) { if runtime.FeatureEnabled(runtime.FeatureAutopilotPassthroughPort) && hasPortPolicy(gs, agonesv1.Passthrough) { @@ -179,7 +179,6 @@ func setPrimaryContainer(pod *corev1.Pod, containerName string) { return } pod.ObjectMeta.Annotations[primaryContainerAnnotation] = containerName - } // podSpecSeccompUnconfined sets to seccomp profile to `Unconfined` to avoid serious performance diff --git a/pkg/cloudproduct/gke/gke_test.go b/pkg/cloudproduct/gke/gke_test.go index ea01254c55..8b90e49702 100644 --- a/pkg/cloudproduct/gke/gke_test.go +++ b/pkg/cloudproduct/gke/gke_test.go @@ -257,6 +257,54 @@ func TestSetPassthroughLabel(t *testing.T) { }, }, }, + "gameserver with Static port policy does not add label to pod": { + features: fmt.Sprintf("%s=true", runtime.FeatureAutopilotPassthroughPort), + + pod: &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{}, + Labels: map[string]string{}, + }, + }, + ports: []agonesv1.GameServerPort{ + { + Name: "awesome-udp", + PortPolicy: agonesv1.Static, + ContainerPort: 1234, + Protocol: corev1.ProtocolUDP, + }, + }, + wantPod: &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{}, + Labels: map[string]string{}, + }, + }, + }, + "gameserver, no feature gate, with Passthrough port policy does not add label to pod": { + features: fmt.Sprintf("%s=false", runtime.FeatureAutopilotPassthroughPort), + + pod: &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{}, + Labels: map[string]string{}, + }, + }, + ports: []agonesv1.GameServerPort{ + { + Name: "awesome-udp", + PortPolicy: agonesv1.Passthrough, + ContainerPort: 1234, + Protocol: corev1.ProtocolUDP, + }, + }, + wantPod: &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{}, + Labels: map[string]string{}, + }, + }, + }, } { t.Run(name, func(t *testing.T) { runtime.FeatureTestMutex.Lock() diff --git a/pkg/gameservers/controller.go b/pkg/gameservers/controller.go index 73c93aaac6..75afb42e0c 100644 --- a/pkg/gameservers/controller.go +++ b/pkg/gameservers/controller.go @@ -521,7 +521,6 @@ func (c *Controller) syncGameServerCreatingState(ctx context.Context, gs *agones }) } } - gs, err = c.createGameServerPod(ctx, gs) if err != nil || gs.Status.State == agonesv1.GameServerStateError { return gs, err