Skip to content

Commit

Permalink
Clusterctl move operation clean up plus adding necessary labels for o…
Browse files Browse the repository at this point in the history
…bj and vpc (#228)

* Adding labels for to CRDs so clusterctl discovery mechnism works

---------

Co-authored-by: Khaja Omer <[email protected]>
  • Loading branch information
2 people authored and AshleyDumaine committed Apr 19, 2024
1 parent 834b18f commit e8704a4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions api/v1alpha1/linodeobjectstoragebucket_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type LinodeObjectStorageBucketStatus struct {
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=linodeobjectstoragebuckets,scope=Namespaced,shortName=lobj
// +kubebuilder:subresource:status
// +kubebuilder:metadata:labels="clusterctl.cluster.x-k8s.io/move-hierarchy=true"
// +kubebuilder:printcolumn:name="Label",type="string",JSONPath=".spec.label",description="The name of the bucket"
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".spec.cluster",description="The ID of the Object Storage cluster for the bucket"
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Bucket and keys have been provisioned"
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/linodevpc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type LinodeVPCStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:metadata:labels="clusterctl.cluster.x-k8s.io/move-hierarchy=true"

// LinodeVPC is the Schema for the linodemachines API
type LinodeVPC struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
labels:
clusterctl.cluster.x-k8s.io/move-hierarchy: "true"
name: linodeobjectstoragebuckets.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
labels:
clusterctl.cluster.x-k8s.io/move-hierarchy: "true"
name: linodevpcs.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
Expand Down
6 changes: 1 addition & 5 deletions controller/linodecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
cerrs "sigs.k8s.io/cluster-api/errors"
kutil "sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/annotations"
"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/cluster-api/util/predicates"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -84,11 +83,7 @@ func (r *LinodeClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reques

return ctrl.Result{}, nil
}
if annotations.IsPaused(cluster, linodeCluster) {
logger.Info("LinodeCluster of linked Cluster is marked as paused. Won't reconcile")

return ctrl.Result{}, nil
}
// Create the cluster scope.
clusterScope, err := scope.NewClusterScope(
ctx,
Expand Down Expand Up @@ -136,6 +131,7 @@ func (r *LinodeClusterReconciler) reconcile(
if err := clusterScope.AddFinalizer(ctx); err != nil {
return res, err
}

// Create
if clusterScope.LinodeCluster.Spec.ControlPlaneEndpoint.Host == "" {
if err := r.reconcileCreate(ctx, logger, clusterScope); err != nil {
Expand Down
7 changes: 6 additions & 1 deletion controller/linodemachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,14 @@ func (r *LinodeMachineReconciler) SetupWithManager(mgr ctrl.Manager) error {
return fmt.Errorf("failed to build controller: %w", err)
}

return controller.Watch(
err = controller.Watch(
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
handler.EnqueueRequestsFromMapFunc(r.requeueLinodeMachinesForUnpausedCluster(mgr.GetLogger())),
predicates.ClusterUnpausedAndInfrastructureReady(mgr.GetLogger()),
)
if err != nil {
return fmt.Errorf("failed adding a watch for ready clusters: %w", err)
}

return nil
}

0 comments on commit e8704a4

Please sign in to comment.