Skip to content

Commit f8f8dd9

Browse files
committed
fix: make status.QOS immutable during pod sync
1 parent ef750ea commit f8f8dd9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/controllers/resources/pods/syncer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ func (s *podSyncer) Sync(ctx *synccontext.SyncContext, event *synccontext.SyncEv
312312
if !equality.Semantic.DeepEqual(event.Virtual.Status, event.Host.Status) {
313313
updated := event.Virtual.DeepCopy()
314314
updated.Status = *event.Host.Status.DeepCopy()
315+
// QOSClass is immutable in newer Kubernetes versions; preserve the existing value.
316+
updated.Status.QOSClass = event.Virtual.Status.QOSClass
315317
ctx.Log.Infof("update virtual pod %s, because status has changed", event.Virtual.Name)
316318
err := ctx.VirtualClient.Status().Update(ctx, updated)
317319
if err != nil && !kerrors.IsNotFound(err) {
@@ -376,6 +378,9 @@ func (s *podSyncer) Sync(ctx *synccontext.SyncContext, event *synccontext.SyncEv
376378
// differences found in host QOSClass and virtual QOSClass and
377379
// a patch event for this field is not created
378380
event.Host.Status.QOSClass = event.VirtualOld.Status.QOSClass
381+
if event.HostOld != nil {
382+
event.Virtual.Status.QOSClass = event.HostOld.Status.QOSClass
383+
}
379384

380385
// patch objects
381386
patch, err := patcher.NewSyncerPatcher(ctx, event.Host, event.Virtual, patcher.TranslatePatches(ctx.Config.Sync.ToHost.Pods.Patches, false))

0 commit comments

Comments
 (0)