Skip to content

Commit

Permalink
enhance: labels from gs can be synced to pod (#160)
Browse files Browse the repository at this point in the history
Signed-off-by: ChrisLiu <[email protected]>
  • Loading branch information
chrisliu1995 authored Aug 16, 2024
1 parent 26fcaf7 commit 92475c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/controllers/gameserver/gameserver_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ func (manager GameServerManager) SyncGsToPod() error {
}
}

// sync labels from gs to pod
for gsKey, gsValue := range gs.GetLabels() {
if util.IsHasPrefixGsSyncToPod(gsKey) {
podValue, exist := pod.GetLabels()[gsKey]
if exist && (podValue == gsValue) {
continue
}
newLabels[gsKey] = gsValue
}
}

// sync pod containers when the containers(images) in GameServer are different from that in pod.
containers := manager.syncPodContainers(gs.Spec.Containers, pod.DeepCopy().Spec.Containers)

Expand Down
2 changes: 2 additions & 0 deletions pkg/controllers/gameserver/gameserver_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ func TestSyncGsToPod(t *testing.T) {
Name: "xxx-0",
Labels: map[string]string{
gameKruiseV1alpha1.GameServerOwnerGssKey: "xxx",
"gs-sync/pre-deleting": "false",
},
Annotations: map[string]string{
"meaningless-key": "meaningless-value",
Expand All @@ -488,6 +489,7 @@ func TestSyncGsToPod(t *testing.T) {
gameKruiseV1alpha1.GameServerDeletePriorityKey: dp.String(),
gameKruiseV1alpha1.GameServerUpdatePriorityKey: up.String(),
gameKruiseV1alpha1.GameServerStateKey: string(gameKruiseV1alpha1.Creating),
"gs-sync/pre-deleting": "false",
},
Annotations: map[string]string{
"gs-sync/match-id": "xxx-xxx-xx2",
Expand Down

0 comments on commit 92475c1

Please sign in to comment.