Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/build/agones-bot/golan…
Browse files Browse the repository at this point in the history
…g.org/x/crypto-0.31.0
  • Loading branch information
gongmax authored Dec 16, 2024
2 parents f852cba + 3795372 commit e8832fe
Show file tree
Hide file tree
Showing 25 changed files with 1,221 additions and 148 deletions.
20 changes: 12 additions & 8 deletions .github/ISSUE_TEMPLATE/golang_version_upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@ assignees: ''


Steps to upgrade Golang version:
- [ ] Update `go.mod` and `go.sum`. At the root of the directory, run:
- [ ] Update `go.mod` and `go.sum`. At the root (agones) directory, run:
- [ ] `find . -name 'go.mod' -not -path '*/\.*' -execdir go mod edit -go=<NEW_GOLANG_VERSION_WITHOUT_PATCH> \;`
- [ ] `find . -name 'go.mod' -not -path '*/\.*' -execdir go mod tidy \;`

- [ ] Update the Dockerfiles for `build` directory.

- [ ] At the root of the directory, run: `find build -type f \( -not -path '*/\.*' -and -not -path 'build/tmp/*' \) -exec sed -i 's/GO_VERSION=[0-9]\+\.[0-9]\+\.[0-9]\+/GO_VERSION=<NEW_GOLANG_VERSION>/g' {} \;`
- [ ] Update the Dockerfiles for `build` directory.
- [ ] At the root directory, run: `find build -type f \( -not -path '*/\.*' -and -not -path 'build/tmp/*' \) -exec sed -i 's/GO_VERSION=[0-9]\+\.[0-9]\+\.[0-9]\+/GO_VERSION=<NEW_GOLANG_VERSION>/g' {} \;`
- [ ] Update the `golang` version for file `build/agones-bot/Dockerfile` to <NEW_GOLANG_VERSION_WITHOUT_PATCH>

- [ ] Update the Dockerfiles for `examples` directory. At the root of the directory, run:

- [ ] Update the Dockerfiles for `test` directory.
- [ ] At the root directory, run: `find test -type f -exec sed -i 's/golang:[0-9]\+\.[0-9]\+\.[0-9]\+/golang:<NEW_GOLANG_VERSION>/g' {} \;`
- [ ] At the root directory, run: `find test -type f -exec sed -i 's/go [0-9]\+\.[0-9]\+\.[0-9]\+/go <NEW_GOLANG_VERSION>/g' {} \;`
- [ ] At the root directory, run: `find test -type f -name 'go.mod' -execdir go mod tidy \;`

- [ ] Update the Dockerfiles for `examples` directory. At the root directory, run:
- [ ] `find examples -name Dockerfile -exec sed -i 's/golang:[0-9]\+\.[0-9]\+-alpine/golang:<NEW_GOLANG_VERSION_WITHOUT_PATCH>-alpine/g' {} \;`
- [ ] `find examples \( -name Dockerfile -o -name Dockerfile.windows \) -exec sed -i 's/golang:[0-9]\+\.[0-9]\+\.[0-9]\+/golang:<NEW_GOLANG_VERSION>/g' {} \;`

- [ ] Update the example images tag. At `build` directory, run:
- [ ] `make bump-image IMAGENAME=allocation-endpoint-proxy VERSION=<current-image-version>`
- [ ] `make bump-image IMAGENAME=autoscaler-webhook VERSION=<current-image-version>`
Expand All @@ -44,4 +48,4 @@ Steps to upgrade Golang version:

- [ ] Create a PR for the above changes and send for review

- [ ] Merge the above PR after it is approved
- [ ] Merge the above PR after it is approved
172 changes: 116 additions & 56 deletions .github/ISSUE_TEMPLATE/kubernetes_update.md

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion docs/governance/templates/release_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ and copy it into a release issue. Fill in relevant values, found inside {}
- [ ] config.toml updates:
- [ ] Run `make site-config-update-version` to update the release version and sync data between dev and prod.
- [ ] Update documentation with updated example images tags.
- [ ] Ensure that the `alphaGates` and `betaGates` for `"Dev"` in `test/upgrade/versionMap.yaml`
match the Alpha features and Beta features in `pkg/util/runtime/features.go`.
- [ ] Create PR with these changes, and merge them with an approval.
- [ ] Run `git remote update && git checkout main && git reset --hard upstream/main` to ensure your code is in line
with upstream (unless this is a hotfix, then do the same, but for the release branch)
Expand All @@ -56,12 +58,19 @@ and copy it into a release issue. Fill in relevant values, found inside {}
- [ ] Copy any review changes from the release blog post into the draft GitHub release.
- [ ] Publish the draft GitHub Release.
- [ ] Run `make release-branch` to create a release branch and run `gcloud config configurations activate <your development project>` to switch Agones development tooling off of the `agones-images` project.
- [ ] Email mailing lists with the release details (copy-paste the release blog post). Refer to the [Internal Mailing list posting guide][Internal Mailing list posting guide] for details.
- [ ] Email mailing lists with the release details (copy-paste the release blog post). Refer to the [Internal Mailing list posting guide][Internal Mailing list posting guide] for details.
- [ ] Paste the announcement blog post to the #users Slack group.
- [ ] Post to the [agonesdev](https://twitter.com/agonesdev) Twitter account.
- [ ] Run `git checkout main`.
- [ ] Run `make sdk-publish-rust`. This command executes `cargo login` for authentication, performs a dry-run publish, and if that succeeds, does the actual publish. Will need [crate's API TOKEN](https://crates.io/settings/tokens) from your crate's account.
- [ ] Run `make sdk-update-version release_stage=after version={version}` file. This command will update the SDKs and install directories files with `{version}+1-dev` and will also set `{version}+1` in `build/Makefile`.
- [ ] In `test/sdk/go/Makefile` change `release_version` to `{version}`.
- [ ] Run `make shell` and run `gcloud config configurations activate agones-images`.
- [ ] Within the shell `cd` to the `test/sdk/go/` directory and run `make cloud-build`.
- [ ] In `test/upgrade/Makefile` change `base_version` to `{version}`.
- [ ] In `test/upgrade/versionMap.yaml` change `ReleaseVersion` to `{version}`.
- [ ] In `test/upgrade/versionMap.yaml` copy and paste `“Dev”` in `agonesVersionFeatureGates` map.
- [ ] Change one of the `“Dev”` in `agonesVersionFeatureGates` to `{version}`.
- [ ] Create PR with these changes, and merge them with approval
- [ ] Close this issue. _Congratulations!_ - the release is now complete! :tada: :clap: :smile: :+1:

Expand Down
3 changes: 3 additions & 0 deletions examples/gameserverallocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,6 @@ spec:
- x7un
- 8inz
capacity: 40 # Updates the maximum capacity of the Counter to this number. Min 0, Max 1000.
deleteValues: # removes values from a List's Valules array. Any nonexistant values are ignored.
- alice
- bob
11 changes: 11 additions & 0 deletions pkg/allocation/converters/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,12 @@ func convertAllocationListsToGSAListActions(in map[string]*pb.ListAction) map[st
copy(copyValues, addValues)
la.AddValues = copyValues
}
if v.DeleteValues != nil {
deleteValues := v.GetDeleteValues()
copyValues := make([]string, len(deleteValues))
copy(copyValues, deleteValues)
la.DeleteValues = copyValues
}
if v.Capacity != nil {
capacity := v.Capacity.GetValue()
la.Capacity = &capacity
Expand All @@ -639,6 +645,11 @@ func convertGSAListActionsToAllocationLists(in map[string]allocationv1.ListActio
copy(copyValues, v.AddValues)
la.AddValues = copyValues
}
if v.DeleteValues != nil {
copyValues := make([]string, len(v.DeleteValues))
copy(copyValues, v.DeleteValues)
la.DeleteValues = copyValues
}
if v.Capacity != nil {
la.Capacity = wrapperspb.Int64(*v.Capacity)
}
Expand Down
16 changes: 12 additions & 4 deletions pkg/allocation/converters/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ func TestConvertAllocationRequestToGameServerAllocation(t *testing.T) {
},
Lists: map[string]*pb.ListAction{
"p": {
AddValues: []string{"foo", "bar", "baz"},
Capacity: wrapperspb.Int64(10),
AddValues: []string{"foo", "bar", "baz"},
Capacity: wrapperspb.Int64(10),
DeleteValues: []string{"alice", "bob", "cat"},
},
},
Scheduling: pb.AllocationRequest_Packed,
Expand Down Expand Up @@ -217,8 +218,9 @@ func TestConvertAllocationRequestToGameServerAllocation(t *testing.T) {
},
Lists: map[string]allocationv1.ListAction{
"p": {
AddValues: []string{"foo", "bar", "baz"},
Capacity: &ten,
AddValues: []string{"foo", "bar", "baz"},
Capacity: &ten,
DeleteValues: []string{"alice", "bob", "cat"},
},
},
Selectors: []allocationv1.GameServerSelector{
Expand Down Expand Up @@ -742,6 +744,9 @@ func TestConvertGSAToAllocationRequest(t *testing.T) {
"d": {
Capacity: &two,
},
"c": {
DeleteValues: []string{"good", "bye"},
},
},
Scheduling: apis.Distributed,
},
Expand Down Expand Up @@ -821,6 +826,9 @@ func TestConvertGSAToAllocationRequest(t *testing.T) {
"d": {
Capacity: wrapperspb.Int64(two),
},
"c": {
DeleteValues: []string{"good", "bye"},
},
},
},
},
Expand Down
61 changes: 36 additions & 25 deletions pkg/allocation/go/allocation.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion pkg/allocation/go/allocation.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,15 @@
"capacity": {
"type": "string",
"format": "int64"
},
"deleteValues": {
"type": "array",
"items": {
"type": "string"
}
}
},
"description": "ListAction is an optional action that can be performed on a List at allocation.\nAddValues: Append values to a List's Values array (optional). Any duplicate values will be ignored.\nCapacity: Update the maximum capacity of the Counter to this number (optional). Min 0, Max 1000."
"description": "ListAction is an optional action that can be performed on a List at allocation.\nAddValues: Append values to a List's Values array (optional). Any duplicate values will be ignored.\nCapacity: Update the maximum capacity of the Counter to this number (optional). Min 0, Max 1000.\nDeleteValues: Remove values from a List's Values array (optional). Any nonexistant values will be ignored."
},
"allocationListSelector": {
"type": "object",
Expand Down
31 changes: 31 additions & 0 deletions pkg/apis/agones/v1/gameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,37 @@ func (gs *GameServer) AppendListValues(name string, values []string) error {
return errors.Errorf("unable to AppendListValues: Name %s, Values %s. List not found in GameServer %s", name, values, gs.ObjectMeta.GetName())
}

// DeleteListValues removes values from the ListStatus Values list. Values in the DeleteListValues
// list that are not in the ListStatus Values list are ignored.
func (gs *GameServer) DeleteListValues(name string, values []string) error {
if values == nil {
return errors.Errorf("unable to DeleteListValues: Name %s, Values %s. Values must not be nil", name, values)
}
if list, ok := gs.Status.Lists[name]; ok {
deleteValuesMap := make(map[string]bool)
for _, value := range values {
deleteValuesMap[value] = true
}
newList := deleteValues(list.Values, deleteValuesMap)
list.Values = newList
gs.Status.Lists[name] = list
return nil
}
return errors.Errorf("unable to DeleteListValues: Name %s, Values %s. List not found in GameServer %s", name, values, gs.ObjectMeta.GetName())
}

// deleteValues returns a new list with all the values in valuesList that are not keys in deleteValuesMap.
func deleteValues(valuesList []string, deleteValuesMap map[string]bool) []string {
newValuesList := []string{}
for _, value := range valuesList {
if _, ok := deleteValuesMap[value]; ok {
continue
}
newValuesList = append(newValuesList, value)
}
return newValuesList
}

// truncateList truncates the list to the given capacity
func truncateList(capacity int64, list []string) []string {
if list == nil || len(list) <= int(capacity) {
Expand Down
57 changes: 57 additions & 0 deletions pkg/apis/agones/v1/gameserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,63 @@ func TestGameServerAppendListValues(t *testing.T) {
}
}

func TestGameServerDeleteListValues(t *testing.T) {
t.Parallel()

testCases := map[string]struct {
gs GameServer
name string
want ListStatus
values []string
wantErr bool
}{
"list not in game server no-op and error": {
gs: GameServer{Status: GameServerStatus{
Lists: map[string]ListStatus{
"foos": {
Values: []string{"foo", "bar", "bax"},
Capacity: 100,
},
},
}},
name: "foo",
values: []string{"bar", "baz"},
wantErr: true,
},
"delete list value - one value not present": {
gs: GameServer{Status: GameServerStatus{
Lists: map[string]ListStatus{
"foo": {
Values: []string{"foo", "bar", "bax"},
Capacity: 100,
},
},
}},
name: "foo",
values: []string{"bar", "baz"},
wantErr: false,
want: ListStatus{
Values: []string{"foo", "bax"},
Capacity: 100,
},
},
}

for test, testCase := range testCases {
t.Run(test, func(t *testing.T) {
err := testCase.gs.DeleteListValues(testCase.name, testCase.values)
if err != nil {
assert.True(t, testCase.wantErr)
} else {
assert.False(t, testCase.wantErr)
}
if list, ok := testCase.gs.Status.Lists[testCase.name]; ok {
assert.Equal(t, testCase.want, list)
}
})
}
}

func TestMergeRemoveDuplicates(t *testing.T) {
t.Parallel()

Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/allocation/v1/gameserverallocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ type ListAction struct {
// AddValues appends values to a List's Values array. Any duplicate values will be ignored.
// +optional
AddValues []string `json:"addValues,omitempty"`
// DeleteValues removes values from a List's Values array. Any nonexistant values will be ignored.
// +optional
DeleteValues []string `json:"deleteValues,omitempty"`
// Capacity updates the maximum capacity of the Counter to this number. Min 0, Max 1000.
// +optional
Capacity *int64 `json:"capacity,omitempty"`
Expand Down Expand Up @@ -349,6 +352,12 @@ func (la *ListAction) ListActions(list string, gs *agonesv1.GameServer) error {
errs = errors.Join(errs, cntErr)
}
}
if len(la.DeleteValues) > 0 {
cntErr := gs.DeleteListValues(list, la.DeleteValues)
if cntErr != nil {
errs = errors.Join(errs, cntErr)
}
}
return errs
}

Expand Down
Loading

0 comments on commit e8832fe

Please sign in to comment.