diff --git a/pkg/controllers/gameserver/gameserver_manager.go b/pkg/controllers/gameserver/gameserver_manager.go index 3e0bfe0..e10542c 100644 --- a/pkg/controllers/gameserver/gameserver_manager.go +++ b/pkg/controllers/gameserver/gameserver_manager.go @@ -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) diff --git a/pkg/controllers/gameserver/gameserver_manager_test.go b/pkg/controllers/gameserver/gameserver_manager_test.go index 9ed3312..80974d5 100644 --- a/pkg/controllers/gameserver/gameserver_manager_test.go +++ b/pkg/controllers/gameserver/gameserver_manager_test.go @@ -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", @@ -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",