enhance: labels from gs can be synced to pod (#160)
Signed-off-by: ChrisLiu <chrisliu1995@163.com>
This commit is contained in:
parent
26fcaf7889
commit
92475c1451
|
|
@ -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.
|
// 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)
|
containers := manager.syncPodContainers(gs.Spec.Containers, pod.DeepCopy().Spec.Containers)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -464,6 +464,7 @@ func TestSyncGsToPod(t *testing.T) {
|
||||||
Name: "xxx-0",
|
Name: "xxx-0",
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
gameKruiseV1alpha1.GameServerOwnerGssKey: "xxx",
|
gameKruiseV1alpha1.GameServerOwnerGssKey: "xxx",
|
||||||
|
"gs-sync/pre-deleting": "false",
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"meaningless-key": "meaningless-value",
|
"meaningless-key": "meaningless-value",
|
||||||
|
|
@ -488,6 +489,7 @@ func TestSyncGsToPod(t *testing.T) {
|
||||||
gameKruiseV1alpha1.GameServerDeletePriorityKey: dp.String(),
|
gameKruiseV1alpha1.GameServerDeletePriorityKey: dp.String(),
|
||||||
gameKruiseV1alpha1.GameServerUpdatePriorityKey: up.String(),
|
gameKruiseV1alpha1.GameServerUpdatePriorityKey: up.String(),
|
||||||
gameKruiseV1alpha1.GameServerStateKey: string(gameKruiseV1alpha1.Creating),
|
gameKruiseV1alpha1.GameServerStateKey: string(gameKruiseV1alpha1.Creating),
|
||||||
|
"gs-sync/pre-deleting": "false",
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"gs-sync/match-id": "xxx-xxx-xx2",
|
"gs-sync/match-id": "xxx-xxx-xx2",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue