Skip to content

Commit

Permalink
Update feature name and add new feature to make
Browse files Browse the repository at this point in the history
Run E2E tests with new feature.
  • Loading branch information
aLekSer committed Jun 26, 2020
1 parent b34b54c commit 445c52a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ KIND_CONTAINER_NAME=$(KIND_PROFILE)-control-plane
# Game Server image to use while doing end-to-end tests
GS_TEST_IMAGE ?= gcr.io/agones-images/udp-server:0.21

ALPHA_FEATURE_GATES ?= "PlayerTracking=true"
ALPHA_FEATURE_GATES ?= "PlayerTracking=true&FixRollingUpdateScaleDown=true"

# Directory that this Makefile is in.
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ steps:
#

- name: 'e2e-runner'
args: ['PlayerTracking=true&ContainerPortAllocation=true', 'e2e-test-cluster']
args: ['PlayerTracking=true&ContainerPortAllocation=true&FixRollingUpdateScaleDown=true', 'e2e-test-cluster']
id: e2e-feature-gates
waitFor:
- push-images
Expand Down
6 changes: 3 additions & 3 deletions pkg/fleets/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ func (c *Controller) rollingUpdateRest(fleet *agonesv1.Fleet, active *agonesv1.G
totalScaleDownCount := readyReplicasCount - minAvailable

for _, gsSet := range rest {
if runtime.FeatureEnabled(runtime.FeatureFixRollingUpdateRest) {
if runtime.FeatureEnabled(runtime.FeatureFixRollingUpdateScaleDown) {
if totalScaledDown >= totalScaleDownCount {
// No further scaling required.
break
Expand All @@ -515,7 +515,7 @@ func (c *Controller) rollingUpdateRest(fleet *agonesv1.Fleet, active *agonesv1.G
newReplicasCount := fleet.LowerBoundReplicas(gsSetCopy.Spec.Replicas - unavailable)
if gsSet.Status.ShutdownReplicas == 0 {
var scaleDownCount int32
if runtime.FeatureEnabled(runtime.FeatureFixRollingUpdateRest) {
if runtime.FeatureEnabled(runtime.FeatureFixRollingUpdateScaleDown) {
// Wait for new GameServers to become Ready before scaling down Inactive GameServerset
// Scale down.
scaleDownCount := int32(integer.IntMin(int(gsSet.Spec.Replicas), int(totalScaleDownCount-totalScaledDown)))
Expand All @@ -542,7 +542,7 @@ func (c *Controller) rollingUpdateRest(fleet *agonesv1.Fleet, active *agonesv1.G
c.recorder.Eventf(fleet, corev1.EventTypeNormal, "ScalingGameServerSet",
"Scaling inactive GameServerSet %s from %d to %d", gsSetCopy.ObjectMeta.Name, gsSet.Spec.Replicas, gsSetCopy.Spec.Replicas)

if runtime.FeatureEnabled(runtime.FeatureFixRollingUpdateRest) {
if runtime.FeatureEnabled(runtime.FeatureFixRollingUpdateScaleDown) {
totalScaledDown += scaleDownCount
} else {
// let's update just one at a time, slightly slower, but a simpler solution that doesn't require us
Expand Down
6 changes: 4 additions & 2 deletions pkg/fleets/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ func TestControllerSyncFleet(t *testing.T) {
})

t.Run("gameserverset with different image details", func(t *testing.T) {
assert.NoError(t, utilruntime.ParseFeatures(string(utilruntime.FeaturePlayerTracking)+"=true"))

f := defaultFixture()
f.Spec.Strategy.Type = appsv1.RollingUpdateDeploymentStrategyType
f.Spec.Template.Spec.Ports = []agonesv1.GameServerPort{{HostPort: 5555}}
Expand Down Expand Up @@ -999,13 +1001,13 @@ func TestControllerRollingUpdateDeploymentGSSUpdateFailedErrExpected(t *testing.
assert.EqualError(t, err, "error updating gameserverset inactive: random-err")
}

func TestFeatureFixRollingUpdateRest(t *testing.T) {
func TestFeatureFixRollingUpdateScaleDown(t *testing.T) {
t.Parallel()

utilruntime.FeatureTestMutex.Lock()
defer utilruntime.FeatureTestMutex.Unlock()

assert.NoError(t, utilruntime.ParseFeatures(string(utilruntime.FeatureFixRollingUpdateRest)+"=true"))
assert.NoError(t, utilruntime.ParseFeatures(string(utilruntime.FeatureFixRollingUpdateScaleDown)+"=true"))

type expected struct {
inactiveSpecReplicas int32
Expand Down
13 changes: 7 additions & 6 deletions pkg/util/runtime/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ const (
// FeatureContainerPortAllocation is a feature flag to enable/disable allocating ports to several containers in a pod
FeatureContainerPortAllocation Feature = "ContainerPortAllocation"

// FeatureFixRollingUpdateRest is a feature flag to enable/disable rolling update fixes
FeatureFixRollingUpdateRest Feature = "FixRollingUpdate"
// FeatureFixRollingUpdateScaleDown is a feature flag to enable/disable rolling update fix of scale down, when ReadyReplicas
// count is taken into account
FeatureFixRollingUpdateScaleDown Feature = "FixRollingUpdateScaleDown"
)

var (
// featureDefaults is a map of all Feature Gates that are
// operational in Agones, and what their default configuration is.
// alpha features are disabled
featureDefaults = map[Feature]bool{
FeatureExample: true,
FeaturePlayerTracking: false,
FeatureContainerPortAllocation: true,
FeatureFixRollingUpdateRest: false,
FeatureExample: true,
FeaturePlayerTracking: false,
FeatureContainerPortAllocation: true,
FeatureFixRollingUpdateScaleDown: false,
}

// featureGates is the storage of what features are enabled
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/Guides/feature-stages.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The current set of `alpha` and `beta` feature gates are:
| Example Gate (not in use) | `Example` | Disabled | None | 0.13.0 |
| [Port Allocations to Multiple Containers]({{< ref "/docs/Reference/gameserver.md" >}}) | `ContainerPortAllocation` | Enabled | `Beta` | 1.7.0 |
| [Player Tracking]({{< ref "/docs/Guides/player-tracking.md" >}}) | `PlayerTracking` | Disabled | `Alpha` | 1.6.0 |
| [Fix RollingUpdate Scaling Down ](https://github.com/googleforgames/agones/issues/1625) | `FeatureFixRollingUpdateRest` | Disabled | `Alpha` | 1.7.0 |
| [Fix RollingUpdate Scaling Down ](https://github.com/googleforgames/agones/issues/1625) | `FixRollingUpdateScaleDown` | Disabled | `Alpha` | 1.7.0 |
<sup>*</sup>Multicluster Allocation was started before this process was in place, and therefore does not have a
feature gate and cannot be disabled.
{{% /feature %}}
Expand Down

0 comments on commit 445c52a

Please sign in to comment.