Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kale-amruta committed Feb 19, 2025
1 parent 066070e commit e18f610
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
10 changes: 10 additions & 0 deletions pkg/controllers/resources/pods/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,16 @@ func (s *podSyncer) Sync(ctx *synccontext.SyncContext, event *synccontext.SyncEv
return ctrl.Result{}, err
}

// ignore the QOSClass field while updating pod status when there is a
// mismatch in this field value on vcluster and host. This field
// has become immutable from k8s 1.32 version and patch fails if
// syncer tries to update this field.
// This needs to be done before patch object is created at
// NewSyncerPatcher is called so that there are no
// differences found in host QOSClass and virtual QOSClass and
// a patch event for this field is not created
event.Host.Status.QOSClass = event.VirtualOld.Status.QOSClass

// patch objects
patch, err := patcher.NewSyncerPatcher(ctx, event.Host, event.Virtual, patcher.TranslatePatches(ctx.Config.Sync.ToHost.Pods.Patches, false))
if err != nil {
Expand Down
6 changes: 0 additions & 6 deletions pkg/controllers/resources/pods/translate/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ import (
)

func (t *translator) Diff(ctx *synccontext.SyncContext, event *synccontext.SyncEvent[*corev1.Pod]) error {
// ignore the QOSClass field while updating pod status when there is a
// mismatch in this field value on vcluster and host. This field
// has become immutable from k8s 1.32 version and patch fails if
// syncer tries to update this field.
event.Host.Status.QOSClass = event.VirtualOld.Status.QOSClass

// sync conditions
event.Virtual.Status.Conditions, event.Host.Status.Conditions = patcher.CopyBidirectional(
event.VirtualOld.Status.Conditions,
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/syncer/pods/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ var _ = ginkgo.Describe("Pods are running in the host cluster", func() {

// ignore HostIP differences
resetHostIP(vpod, pod)

// Since k8s 1.32, status.QOSClass field has become immutable,
// hence we have stopeed syncing it. So ignore
// the differences in the status.QOSClass field
ignoreQOSClassDiff(vpod, pod)

framework.ExpectEqual(vpod.Status, pod.Status)

// check for ephemeralContainers subResource
Expand Down Expand Up @@ -694,3 +700,6 @@ func resetHostIP(vpod, pod *corev1.Pod) {
vpod.Status.HostIP, pod.Status.HostIP = "", ""
vpod.Status.HostIPs, pod.Status.HostIPs = nil, nil
}
func ignoreQOSClassDiff(vpod, pod *corev1.Pod) {
pod.Status.QOSClass = vpod.Status.QOSClass
}

0 comments on commit e18f610

Please sign in to comment.