-
Notifications
You must be signed in to change notification settings - Fork 820
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allocation is broken when using the generated go client
When attempting to create a fleet allocation through the generated go client the following error would occur: `"error: "Internal error occurred: Internal error occurred: jsonpatch replace operation does not apply: doc is missing key: /status/GameServer"` This is because we didn't mark pointers in `FleetAllocation` to be json, `omitempty`. When not using the client (either yaml, or rest) the following JSON is sent: ```json { "apiVersion": "stable.agones.dev/v1alpha1", "kind": "FleetAllocation", "metadata": { "generateName": "simple-udp-", "namespace": "default" }, "spec": { "fleetName": "simple-udp" } } ``` Previous to this fix, when calling through the go client, the following JSON would get generated: ```json { "apiVersion": "stable.agones.dev/v1alpha1", "kind": "FleetAllocation", "metadata": { "creationTimestamp": null, "generateName": "allocatioon-", "namespace": "default" }, "spec": { "fleetName": "simple-fleet-6fb7c", "metadata": {} }, "status": { "GameServer": null } } ``` That `nil` `GameServer` value messes up the library that creates the JSONPatch. Now we have the `omitempty` declarations in the correct places, this is working correctly. We also now have e2e tests to make sure the issue does not end up replicated. Need some user testing to determine if a hotfix is appropriate for this bug, or if a workaround can be applied/this library can be used without a need for a complete redeployment.
- Loading branch information
1 parent
3128070
commit 7fed6b4
Showing
7 changed files
with
87 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2018 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package e2e | ||
|
||
import ( | ||
"testing" | ||
|
||
"agones.dev/agones/pkg/apis/stable/v1alpha1" | ||
"github.com/stretchr/testify/assert" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestCreateFleetAndAllocate(t *testing.T) { | ||
t.Parallel() | ||
|
||
flt, err := framework.AgonesClient.StableV1alpha1().Fleets(defaultNs).Create(defaultFleet()) | ||
assert.Nil(t, err) | ||
|
||
err = framework.WaitForFleetReady(flt) | ||
assert.Nil(t, err, "fleet not ready") | ||
|
||
fa := &v1alpha1.FleetAllocation{ | ||
ObjectMeta: metav1.ObjectMeta{GenerateName: "allocatioon-", Namespace: defaultNs}, | ||
Spec: v1alpha1.FleetAllocationSpec{ | ||
FleetName: flt.ObjectMeta.Name, | ||
}, | ||
} | ||
|
||
fa, err = framework.AgonesClient.StableV1alpha1().FleetAllocations(defaultNs).Create(fa) | ||
assert.Nil(t, err) | ||
assert.Equal(t, v1alpha1.Allocated, fa.Status.GameServer.Status.State) | ||
} | ||
|
||
// defaultFleet returns a default fleet configuration | ||
func defaultFleet() *v1alpha1.Fleet { | ||
gs := defaultGameServer() | ||
|
||
return &v1alpha1.Fleet{ | ||
ObjectMeta: metav1.ObjectMeta{GenerateName: "simple-fleet-", Namespace: defaultNs}, | ||
Spec: v1alpha1.FleetSpec{ | ||
Replicas: 3, | ||
Template: v1alpha1.GameServerTemplateSpec{ | ||
Spec: gs.Spec, | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters