Skip to content

Commit

Permalink
feat(controller): support skipping rpaasinstance reconciliation w/ an…
Browse files Browse the repository at this point in the history
…notation
  • Loading branch information
nettoclaudio committed Jan 26, 2022
1 parent a57ee05 commit 951ce64
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const (

externalDNSHostnameLabel = "external-dns.alpha.kubernetes.io/hostname"
externalDNSTTLLabel = "external-dns.alpha.kubernetes.io/ttl"

skipReconcileLabel = "rpaas.extensions.tsuru.io/skip-reconcile"
)

var (
Expand Down
10 changes: 9 additions & 1 deletion controllers/rpaasinstance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"reflect"
"sort"
"strconv"

"github.com/go-logr/logr"
cmv1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
Expand Down Expand Up @@ -58,7 +59,7 @@ type RpaasInstanceReconciler struct {
// +kubebuilder:rbac:groups=extensions.tsuru.io,resources=rpaasinstances/status,verbs=get;update;patch

func (r *RpaasInstanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
_ = r.Log.WithValues("rpaasinstance", req.NamespacedName)
l := r.Log.WithValues("rpaasinstance", req.NamespacedName)

instance, err := r.getRpaasInstance(ctx, req.NamespacedName)
if k8serrors.IsNotFound(err) {
Expand All @@ -70,6 +71,13 @@ func (r *RpaasInstanceReconciler) Reconcile(ctx context.Context, req ctrl.Reques
return reconcile.Result{}, err
}

if s, ok := instance.Annotations[skipReconcileLabel]; ok {
if skipped, _ := strconv.ParseBool(s); skipped {
l.Info(fmt.Sprintf("Skipping reconciliation as %s=true annotation was found in the resource", skipReconcileLabel))
return reconcile.Result{Requeue: true}, nil
}
}

planName := types.NamespacedName{
Name: instance.Spec.PlanName,
Namespace: instance.Namespace,
Expand Down

0 comments on commit 951ce64

Please sign in to comment.