This repository has been archived by the owner on Oct 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix/Operator] Parameter context controller case spam (#152)
* add feature and bump version * append changelog * fix parameter context & set requeue configuration #124 * bump version & append changelog
- Loading branch information
Showing
19 changed files
with
222 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,9 +48,11 @@ var parameterContextFinalizer = "nifiparametercontexts.nifi.orange.com/finalizer | |
// NifiParameterContextReconciler reconciles a NifiParameterContext object | ||
type NifiParameterContextReconciler struct { | ||
client.Client | ||
Log logr.Logger | ||
Scheme *runtime.Scheme | ||
Recorder record.EventRecorder | ||
Log logr.Logger | ||
Scheme *runtime.Scheme | ||
Recorder record.EventRecorder | ||
RequeueInterval int | ||
RequeueOffset int | ||
} | ||
|
||
// +kubebuilder:rbac:groups=nifi.orange.com,resources=nifiparametercontexts,verbs=get;list;watch;create;update;patch;delete | ||
|
@@ -68,7 +70,7 @@ type NifiParameterContextReconciler struct { | |
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *NifiParameterContextReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
_ = r.Log.WithValues("nifiparametercontext", req.NamespacedName) | ||
|
||
interval := util.GetRequeueInterval(r.RequeueInterval, r.RequeueOffset) | ||
var err error | ||
|
||
// Fetch the NifiParameterContext instance | ||
|
@@ -185,7 +187,7 @@ func (r *NifiParameterContextReconciler) Reconcile(ctx context.Context, req ctrl | |
instance.Spec.ClusterRef.Name, clusterConnect.Id())) | ||
|
||
// the cluster does not exist - should have been caught pre-flight | ||
return RequeueAfter(time.Duration(15) * time.Second) | ||
return RequeueAfter(interval) | ||
} | ||
|
||
// Ìn case of the cluster reference changed. | ||
|
@@ -204,7 +206,7 @@ func (r *NifiParameterContextReconciler) Reconcile(ctx context.Context, req ctrl | |
if err := r.Client.Update(ctx, current); err != nil { | ||
return RequeueWithError(r.Log, "failed to update NifiParameterContext", err) | ||
} | ||
return RequeueAfter(time.Duration(15) * time.Second) | ||
return RequeueAfter(interval) | ||
} | ||
|
||
r.Recorder.Event(instance, corev1.EventTypeNormal, "Reconciling", | ||
|
@@ -248,7 +250,7 @@ func (r *NifiParameterContextReconciler) Reconcile(ctx context.Context, req ctrl | |
if err != nil { | ||
switch errors.Cause(err).(type) { | ||
case errorfactory.NifiParameterContextUpdateRequestRunning: | ||
return RequeueAfter(time.Duration(5) * time.Second) | ||
return RequeueAfter(interval/3) | ||
default: | ||
r.Recorder.Event(instance, corev1.EventTypeNormal, "SynchronizingFailed", | ||
fmt.Sprintf("Synchronizing parameter context %s failed", instance.Name)) | ||
|
@@ -280,7 +282,7 @@ func (r *NifiParameterContextReconciler) Reconcile(ctx context.Context, req ctrl | |
|
||
r.Log.Info("Ensured Parameter Context") | ||
|
||
return RequeueAfter(time.Duration(15) * time.Second) | ||
return RequeueAfter(interval) | ||
} | ||
|
||
// SetupWithManager sets up the controller with the Manager. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,11 @@ var registryClientFinalizer = "nifiregistryclients.nifi.orange.com/finalizer" | |
// NifiRegistryClientReconciler reconciles a NifiRegistryClient object | ||
type NifiRegistryClientReconciler struct { | ||
client.Client | ||
Log logr.Logger | ||
Scheme *runtime.Scheme | ||
Recorder record.EventRecorder | ||
Log logr.Logger | ||
Scheme *runtime.Scheme | ||
Recorder record.EventRecorder | ||
RequeueInterval int | ||
RequeueOffset int | ||
} | ||
|
||
// +kubebuilder:rbac:groups=nifi.orange.com,resources=nifiregistryclients,verbs=get;list;watch;create;update;patch;delete | ||
|
@@ -66,7 +68,7 @@ type NifiRegistryClientReconciler struct { | |
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *NifiRegistryClientReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
_ = r.Log.WithValues("nifiregistryclient", req.NamespacedName) | ||
|
||
interval := util.GetRequeueInterval(r.RequeueInterval, r.RequeueOffset) | ||
var err error | ||
|
||
// Fetch the NifiRegistryClient instance | ||
|
@@ -160,7 +162,7 @@ func (r *NifiRegistryClientReconciler) Reconcile(ctx context.Context, req ctrl.R | |
fmt.Sprintf("The referenced cluster is not ready yet : %s in %s", | ||
instance.Spec.ClusterRef.Name, clusterConnect.Id())) | ||
// the cluster does not exist - should have been caught pre-flight | ||
return RequeueAfter(time.Duration(15) * time.Second) | ||
return RequeueAfter(interval) | ||
} | ||
|
||
// Ìn case of the cluster reference changed. | ||
|
@@ -179,7 +181,7 @@ func (r *NifiRegistryClientReconciler) Reconcile(ctx context.Context, req ctrl.R | |
if err := r.Client.Update(ctx, current); err != nil { | ||
return RequeueWithError(r.Log, "failed to update NifiRegistryClient", err) | ||
} | ||
return RequeueAfter(time.Duration(15) * time.Second) | ||
return RequeueAfter(interval) | ||
} | ||
|
||
r.Recorder.Event(instance, corev1.EventTypeNormal, "Reconciling", | ||
|
@@ -254,7 +256,7 @@ func (r *NifiRegistryClientReconciler) Reconcile(ctx context.Context, req ctrl.R | |
|
||
r.Log.Info("Ensured Registry Client") | ||
|
||
return RequeueAfter(time.Duration(15) * time.Second) | ||
return RequeueAfter(interval) | ||
} | ||
|
||
// SetupWithManager sets up the controller with the Manager. | ||
|
Oops, something went wrong.