Skip to content

Commit

Permalink
Patch legacy annotation on pre 0.3 RKE2 control planes
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev committed Oct 10, 2024
1 parent 4412d79 commit 53398ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions controlplane/api/v1alpha1/rke2controlplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const (
// RKE2ServerConfigurationAnnotation is a machine annotation that stores the json-marshalled string of RKE2Config
// This annotation is used to detect any changes in RKE2Config and trigger machine rollout.
RKE2ServerConfigurationAnnotation = "controlplane.cluster.x-k8s.io/rke2-server-configuration"

// LegacyRKE2ControlPlane is a controlplane annotation that marks the CP as legacy. This CP will not provide
// etcd certificate management or etcd membership management.
LegacyRKE2ControlPlane = "controlplane.cluster.x-k8s.io/legacy"
)

// RKE2ControlPlaneSpec defines the desired state of RKE2ControlPlane.
Expand Down
12 changes: 12 additions & 0 deletions controlplane/internal/controllers/rke2controlplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ func (r *RKE2ControlPlaneReconciler) reconcileNormal(
logger := log.FromContext(ctx)
logger.Info("Reconcile RKE2 Control Plane")

if rcp.Annotations == nil {
rcp.Annotations = map[string]string{}
}

rcp.Annotations[controlplanev1.LegacyRKE2ControlPlane] = ""

// Wait for the cluster infrastructure to be ready before creating machines
if !cluster.Status.InfrastructureReady {
logger.Info("Cluster infrastructure is not ready yet")
Expand Down Expand Up @@ -527,6 +533,12 @@ func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context,
) (res ctrl.Result, err error) {
logger := log.FromContext(ctx)

if rcp.Annotations == nil {
rcp.Annotations = map[string]string{}
}

rcp.Annotations[controlplanev1.LegacyRKE2ControlPlane] = ""

// Gets all machines, not just control plane machines.
allMachines, err := r.managementCluster.GetMachinesForCluster(ctx, util.ObjectKey(cluster))
if err != nil {
Expand Down

0 comments on commit 53398ea

Please sign in to comment.