Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kale-amruta committed Feb 18, 2025
1 parent f2c9309 commit a345049
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions pkg/controllers/resources/csinodes/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ func (s *csinodeSyncer) Sync(ctx *synccontext.SyncContext, event *synccontext.Sy

func (s *csinodeSyncer) SyncToHost(ctx *synccontext.SyncContext, event *synccontext.SyncToHostEvent[*storagev1.CSINode]) (ctrl.Result, error) {
if event.HostOld == nil {
ManagedByLabelDoesNotExist := event.Virtual.GetLabels() == nil || (event.Virtual.GetLabels() != nil && event.Virtual.GetLabels()[translate.MarkerLabel] != translate.VClusterName)
if ManagedByLabelDoesNotExist {
if event.Virtual.GetLabels() == nil || (event.Virtual.GetLabels() != nil && event.Virtual.GetLabels()[translate.MarkerLabel] != translate.VClusterName) {
return ctrl.Result{}, nil
}
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/controllers/resources/nodes/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ func registerIndices(ctx *synccontext.RegisterContext) error {

func (s *nodeSyncer) SyncToHost(ctx *synccontext.SyncContext, event *synccontext.SyncToHostEvent[*corev1.Node]) (ctrl.Result, error) {
if event.HostOld == nil {
ManagedByLabelDoesNotExist := event.Virtual.GetLabels() == nil || (event.Virtual.GetLabels() != nil && event.Virtual.GetLabels()[translate.MarkerLabel] != translate.VClusterName)
if ManagedByLabelDoesNotExist {
if event.Virtual.GetLabels() == nil || (event.Virtual.GetLabels() != nil && event.Virtual.GetLabels()[translate.MarkerLabel] != translate.VClusterName) {
return ctrl.Result{}, nil
}
}
Expand Down
6 changes: 0 additions & 6 deletions pkg/controllers/resources/pods/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,6 @@ 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.
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: 6 additions & 0 deletions pkg/controllers/resources/pods/translate/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ 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

0 comments on commit a345049

Please sign in to comment.