Skip to content

Commit

Permalink
Fixed the condition on GameServerShutdown to include the undeleted Un…
Browse files Browse the repository at this point in the history
…healthy GSs
  • Loading branch information
ilkercelikyilmaz committed Apr 25, 2019
1 parent da4fb8d commit 72ca155
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 2 additions & 6 deletions pkg/gameservers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down
7 changes: 6 additions & 1 deletion test/e2e/gameserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 72ca155

Please sign in to comment.