diff --git a/pkg/gameservers/controller.go b/pkg/gameservers/controller.go index 511d8a9877..f9c3fe0997 100644 --- a/pkg/gameservers/controller.go +++ b/pkg/gameservers/controller.go @@ -455,11 +455,6 @@ func (c *Controller) syncGameServerCreatingState(gs *v1alpha1.GameServer) (*v1al c.loggerForGameServer(gs).Info("Syncing Create State") - // Wait for pod cache sync, so that we don't end up with multiple pods for a GameServer - if !(cache.WaitForCacheSync(c.stop, c.podSynced)) { - return nil, errors.New("could not sync pod cache state") - } - // Maybe something went wrong, and the pod was created, but the state was never moved to Starting, so let's check ret, err := c.listGameServerPods(gs) if err != nil { @@ -734,7 +729,8 @@ func (c *Controller) syncGameServerRequestReadyState(gs *v1alpha1.GameServer) (* // syncGameServerShutdownState deletes the GameServer (and therefore the backing Pod) if it is in shutdown state func (c *Controller) syncGameServerShutdownState(gs *v1alpha1.GameServer) error { - if !(gs.Status.State == v1alpha1.GameServerStateShutdown && gs.ObjectMeta.DeletionTimestamp.IsZero()) { + if !gs.ObjectMeta.DeletionTimestamp.IsZero() || + (gs.Status.State != v1alpha1.GameServerStateShutdown && gs.Status.State != v1alpha1.GameServerStateUnhealthy) { return nil } diff --git a/test/e2e/gameserver_test.go b/test/e2e/gameserver_test.go index fc2c070795..98484574b8 100644 --- a/test/e2e/gameserver_test.go +++ b/test/e2e/gameserver_test.go @@ -23,6 +23,7 @@ import ( e2eframework "agones.dev/agones/test/e2e/framework" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" @@ -176,7 +177,11 @@ func TestUnhealthyGameServersWithoutFreePorts(t *testing.T) { assert.Nil(t, err) _, err = framework.WaitForGameServerState(newGs, v1alpha1.GameServerStateUnhealthy, 10*time.Second) - assert.Nil(t, err) + assert.NotNil(t, err) + + _, err = gameServers.Get(newGs.Name, metav1.GetOptions{}) + assert.NotNil(t, err) + assert.True(t, errors.IsNotFound(err)) } func TestGameServerUnhealthyAfterDeletingPod(t *testing.T) {