Skip to content

Commit

Permalink
nit and added negative tests
Browse files Browse the repository at this point in the history
nit
  • Loading branch information
vicentefb committed May 1, 2024
1 parent 3f537cb commit 20c9c79
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
1 change: 0 additions & 1 deletion pkg/cloudproduct/gke/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions pkg/cloudproduct/gke/gke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion pkg/gameservers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 20c9c79

Please sign in to comment.