Skip to content

Commit 724affc

Browse files
committed
Implement pause
1 parent 45c2589 commit 724affc

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

internal/controller/scalewaycluster_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
corev1 "k8s.io/api/core/v1"
99
apierrors "k8s.io/apimachinery/pkg/api/errors"
1010
"sigs.k8s.io/cluster-api/util"
11+
"sigs.k8s.io/cluster-api/util/annotations"
1112
"sigs.k8s.io/cluster-api/util/patch"
1213
"sigs.k8s.io/cluster-api/util/predicates"
1314
ctrl "sigs.k8s.io/controller-runtime"
@@ -87,6 +88,11 @@ func (r *ScalewayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Requ
8788
}
8889
}()
8990

91+
if annotations.IsPaused(cluster, scalewayCluster) {
92+
log.Info("ScalewayCluster or linked Cluster is marked as paused. Won't reconcile normally")
93+
return ctrl.Result{}, nil
94+
}
95+
9096
if err := r.claimScalewaySecret(ctx, scalewayCluster); err != nil {
9197
return ctrl.Result{}, fmt.Errorf("unable to claim ScalewaySecret: %w", err)
9298
}

internal/controller/scalewaymachine_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
apierrors "k8s.io/apimachinery/pkg/api/errors"
1010
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1111
"sigs.k8s.io/cluster-api/util"
12+
"sigs.k8s.io/cluster-api/util/annotations"
1213
ctrl "sigs.k8s.io/controller-runtime"
1314
"sigs.k8s.io/controller-runtime/pkg/builder"
1415
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -119,6 +120,11 @@ func (r *ScalewayMachineReconciler) Reconcile(ctx context.Context, req ctrl.Requ
119120
}
120121
}()
121122

123+
if annotations.IsPaused(cluster, scalewayMachine) {
124+
log.Info("ScalewayMachine or linked Cluster is marked as paused. Won't reconcile normally")
125+
return ctrl.Result{}, nil
126+
}
127+
122128
// Handle deleted machines
123129
if !scalewayMachine.ObjectMeta.DeletionTimestamp.IsZero() {
124130
return r.reconcileDelete(ctx, machineScope)

0 commit comments

Comments
 (0)