Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/controllers/resources/nodes/fake_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ func (r *fakeNodeSyncer) FakeSync(ctx *synccontext.SyncContext, vObj client.Obje
return ctrl.Result{}, fmt.Errorf("%#v is not a node", vObj)
}

if node.GetLabels() == nil || (node.GetLabels() != nil && node.GetLabels()[translate.MarkerLabel] != translate.VClusterName) {
// This node is not managed by vcluster, doing nothing to it.
ctx.Log.Infof("Unmanaged fake node %s, doing nothing.", vObj.GetName())
return ctrl.Result{}, nil
}

needed, err := r.nodeNeeded(ctx, node.Name)
if err != nil {
return ctrl.Result{}, err
Expand Down Expand Up @@ -164,6 +170,7 @@ func createFakeNode(
"kubernetes.io/arch": runtime.GOARCH,
"kubernetes.io/hostname": translate.SafeConcatName("fake", name),
"kubernetes.io/os": "linux",
translate.MarkerLabel: translate.VClusterName,
},
Annotations: map[string]string{
"node.alpha.kubernetes.io/ttl": "0",
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/resources/nodes/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,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 {
if event.Virtual.GetLabels() == nil || (event.Virtual.GetLabels() != nil && event.Virtual.GetLabels()[translate.MarkerLabel] != translate.VClusterName) {
ctx.Log.Infof("Unmanaged virtual node %s, doing nothing.", event.Virtual.Name)
return ctrl.Result{}, nil
}
}
Expand Down