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

⚠️ Updated function name HasPausedAnnotation to HasPaused and HasSkipRemediationAnnotation to HasSkipRemediation #5545

Merged
merged 1 commit into from
Dec 14, 2021
Merged
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
4 changes: 2 additions & 2 deletions controllers/machinehealthcheck_targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,11 @@ func minDuration(durations []time.Duration) time.Duration {
// shouldSkipRemediation checks if the machine should be skipped for remediation.
// Returns true if it should be skipped along with the reason for skipping.
func shouldSkipRemediation(m *clusterv1.Machine) (bool, string) {
if annotations.HasPausedAnnotation(m) {
if annotations.HasPaused(m) {
return true, fmt.Sprintf("machine has %q annotation", clusterv1.PausedAnnotation)
}

if annotations.HasSkipRemediationAnnotation(m) {
if annotations.HasSkipRemediation(m) {
return true, fmt.Sprintf("machine has %q annotation", clusterv1.MachineSkipRemediationAnnotation)
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/topology/clusterclass_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (r *ClusterClassReconciler) Reconcile(ctx context.Context, req ctrl.Request
}

// Return early if the ClusterClass is paused.
if annotations.HasPausedAnnotation(clusterClass) {
if annotations.HasPaused(clusterClass) {
log.Info("Reconciliation is paused for this object")
return ctrl.Result{}, nil
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func (r *ClusterClassReconciler) reconcileExternal(ctx context.Context, clusterC
}

// If external ref is paused, return early.
if annotations.HasPausedAnnotation(obj) {
if annotations.HasPaused(obj) {
log.V(3).Info("External object referenced is paused", "refGroupVersionKind", ref.GroupVersionKind(), "refName", ref.Name)
return nil
}
Expand Down
14 changes: 13 additions & 1 deletion util/annotations/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func IsPaused(cluster *clusterv1.Cluster, o metav1.Object) bool {
if cluster.Spec.Paused {
return true
}
return HasPausedAnnotation(o)
return HasPaused(o)
}

// IsExternallyManaged returns true if the object has the `managed-by` annotation.
Expand All @@ -38,15 +38,27 @@ func IsExternallyManaged(o metav1.Object) bool {
}

// HasPausedAnnotation returns true if the object has the `paused` annotation.
// Deprecated: this is going to be removed in a next release. Please use `HasPaused` instead.
func HasPausedAnnotation(o metav1.Object) bool {
return hasAnnotation(o, clusterv1.PausedAnnotation)
}

// HasPaused returns true if the object has the `paused` annotation.
func HasPaused(o metav1.Object) bool {
return hasAnnotation(o, clusterv1.PausedAnnotation)
}

// HasSkipRemediationAnnotation returns true if the object has the `skip-remediation` annotation.
// Deprecated: this is going to be removed in a next release. Please use `HasSkipRemediation` instead.
func HasSkipRemediationAnnotation(o metav1.Object) bool {
return hasAnnotation(o, clusterv1.MachineSkipRemediationAnnotation)
}

// HasSkipRemediation returns true if the object has the `skip-remediation` annotation.
func HasSkipRemediation(o metav1.Object) bool {
return hasAnnotation(o, clusterv1.MachineSkipRemediationAnnotation)
}

// HasWithPrefix returns true if at least one of the annotations has the prefix specified.
func HasWithPrefix(prefix string, annotations map[string]string) bool {
for key := range annotations {
Expand Down
2 changes: 1 addition & 1 deletion util/predicates/generic_predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func ResourceNotPausedAndHasFilterLabel(logger logr.Logger, labelValue string) p
func processIfNotPaused(logger logr.Logger, obj client.Object) bool {
kind := strings.ToLower(obj.GetObjectKind().GroupVersionKind().Kind)
log := logger.WithValues("namespace", obj.GetNamespace(), kind, obj.GetName())
if annotations.HasPausedAnnotation(obj) {
if annotations.HasPaused(obj) {
log.V(4).Info("Resource is paused, will not attempt to map resource")
return false
}
Expand Down