Skip to content

KAAP-657: Remove pf9 cluster label as a part of scaling down or byoh cluster deletion #38

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions apis/infrastructure/v1beta1/byohost_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const (
AttachedByoMachineLabel = "byoh.infrastructure.cluster.x-k8s.io/byomachine-name"
// BundleLookupBaseRegistryAnnotation annotation used to store the base registry for the bundle lookup
BundleLookupBaseRegistryAnnotation = "byoh.infrastructure.cluster.x-k8s.io/bundle-registry"
// ClusterLabel label is used to mark a cluster where it is attached to
ClusterLabel = "kaapi.pf9.io/cluster-name"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a constant defined in a common global module?

)

// ByoHostSpec defines the desired state of ByoHost
Expand Down
5 changes: 5 additions & 0 deletions controllers/infrastructure/byomachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,13 +602,18 @@ func ByoHostToByoMachineMapFunc(gvk schema.GroupVersionKind) handler.MapFunc {
}

func (r *ByoMachineReconciler) markHostForCleanup(ctx context.Context, machineScope *byoMachineScope) error {
logger := log.FromContext(ctx).WithValues("cluster", machineScope.Cluster.Name)
helper, _ := patch.NewHelper(machineScope.ByoHost, r.Client)

if machineScope.ByoHost.Annotations == nil {
machineScope.ByoHost.Annotations = map[string]string{}
}
machineScope.ByoHost.Annotations[infrav1.HostCleanupAnnotation] = ""

// remove the pf9 cluster label
logger.Info("Removing pf9 cluster label %s from ByoHost %s", infrav1.ClusterLabel, machineScope.ByoHost.Name)
delete(machineScope.ByoHost.Labels, infrav1.ClusterLabel)

// Issue the patch for byohost
return helper.Patch(ctx, machineScope.ByoHost)
}
Expand Down