Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach a byomachine to multiple byohost in some condition by mistake #185

Merged
merged 7 commits into from
Oct 29, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
comment from anusha
Signed-off-by: Hui Chen <huchen@huchen-a01.vmware.com>
Hui Chen committed Oct 29, 2021
commit 5d7d1d557f00718eba1e60ba88d204df9806ef44
2 changes: 1 addition & 1 deletion agent/reconciler/host_reconciler.go
Original file line number Diff line number Diff line change
@@ -193,7 +193,7 @@ func (r *HostReconciler) hostCleanUp(ctx context.Context, byoHost *infrastructur
delete(byoHost.Labels, clusterv1.ClusterLabelName)

// Remove Byomachine-name label
delete(byoHost.Labels, infrastructurev1beta1.AttachedByoMachineName)
delete(byoHost.Labels, infrastructurev1beta1.AttachedByoMachineLabel)
dharmjit marked this conversation as resolved.
Show resolved Hide resolved

// Remove the EndPointIP annotation
delete(byoHost.Annotations, infrastructurev1beta1.EndPointIPAnnotation)
6 changes: 3 additions & 3 deletions apis/infrastructure/v1beta1/byohost_types.go
Original file line number Diff line number Diff line change
@@ -10,9 +10,9 @@ import (
)

const (
HostCleanupAnnotation = "byoh.infrastructure.cluster.x-k8s.io/unregistering"
EndPointIPAnnotation = "byoh.infrastructure.cluster.x-k8s.io/endpointip"
K8sVersionAnnotation = "byoh.infrastructure.cluster.x-k8s.io/k8sversion"
HostCleanupAnnotation = "byoh.infrastructure.cluster.x-k8s.io/unregistering"
EndPointIPAnnotation = "byoh.infrastructure.cluster.x-k8s.io/endpointip"
K8sVersionAnnotation = "byoh.infrastructure.cluster.x-k8s.io/k8sversion"
AttachedByoMachineLabel = "byoh.infrastructure.cluster.x-k8s.io/byomachine-name"
dharmjit marked this conversation as resolved.
Show resolved Hide resolved
)

4 changes: 2 additions & 2 deletions controllers/infrastructure/byomachine_controller.go
Original file line number Diff line number Diff line change
@@ -168,7 +168,7 @@ func (r *ByoMachineReconciler) FetchAttachedByoHost(ctx context.Context, byomach
logger.Info("Fetching an attached ByoHost")

selector := labels.NewSelector()
byohostLabels, _ := labels.NewRequirement(infrav1.AttachedByoMachineName, selection.Equals, []string{byomachineNamespace + "." + byomachineName})
byohostLabels, _ := labels.NewRequirement(infrav1.AttachedByoMachineLabel, selection.Equals, []string{byomachineNamespace + "." + byomachineName})
selector = selector.Add(*byohostLabels)
hostsList := &infrav1.ByoHostList{}
err := r.Client.List(
@@ -444,7 +444,7 @@ func (r *ByoMachineReconciler) attachByoHost(ctx context.Context, machineScope *
hostLabels = make(map[string]string)
}
hostLabels[clusterv1.ClusterLabelName] = machineScope.ByoMachine.Labels[clusterv1.ClusterLabelName]
hostLabels[infrav1.AttachedByoMachineName] = machineScope.ByoMachine.Namespace + "." + machineScope.ByoMachine.Name
hostLabels[infrav1.AttachedByoMachineLabel] = machineScope.ByoMachine.Namespace + "." + machineScope.ByoMachine.Name
host.Labels = hostLabels

host.Spec.BootstrapSecret = &corev1.ObjectReference{
2 changes: 1 addition & 1 deletion controllers/infrastructure/byomachine_controller_test.go
Original file line number Diff line number Diff line change
@@ -250,7 +250,7 @@ var _ = Describe("Controllers/ByomachineController", func() {
if byoHost.Labels == nil {
byoHost.Labels = make(map[string]string)
}
byoHost.Labels[infrastructurev1beta1.AttachedByoMachineName] = byoMachine.Namespace + "." + byoMachine.Name
byoHost.Labels[infrastructurev1beta1.AttachedByoMachineLabel] = byoMachine.Namespace + "." + byoMachine.Name
dharmjit marked this conversation as resolved.
Show resolved Hide resolved
Expect(ph.Patch(ctx, byoHost, patch.WithStatusObservedGeneration{})).Should(Succeed())

WaitForObjectToBeUpdatedInCache(byoHost, func(object client.Object) bool {