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

chore: use domain-qualified finalizer name #2304

Merged
merged 1 commit into from
Dec 25, 2024
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
10 changes: 8 additions & 2 deletions pkg/reconciler/isbsvc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ import (
)

const (
finalizerName = dfv1.ControllerISBSvc
finalizerName = "numaflow.numaproj.io/" + dfv1.ControllerISBSvc
// TODO: clean up the deprecated finalizer in v1.7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO: clean up the deprecated finalizer in v1.7
// DEPRECATE(1.7): clean up the deprecated finalizer in v1.7

Is this a simpler search pattern?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might get confused with Deprecated annotation. We could search Deprecated in the future.

deprecatedFinalizerName = dfv1.ControllerISBSvc
)

// interStepBufferReconciler reconciles an Inter-Step Buffer Service object.
Expand Down Expand Up @@ -97,19 +99,23 @@ func (r *interStepBufferServiceReconciler) reconcile(ctx context.Context, isbSvc
log := logging.FromContext(ctx)
if !isbSvc.DeletionTimestamp.IsZero() {
log.Info("Deleting ISB Service")
if controllerutil.ContainsFinalizer(isbSvc, finalizerName) {
if controllerutil.ContainsFinalizer(isbSvc, finalizerName) || controllerutil.ContainsFinalizer(isbSvc, deprecatedFinalizerName) {
// Finalizer logic should be added here.
if err := installer.Uninstall(ctx, isbSvc, r.client, r.kubeClient, r.config, log, r.recorder); err != nil {
log.Errorw("Failed to uninstall", zap.Error(err))
isbSvc.Status.SetPhase(dfv1.ISBSvcPhaseDeleting, err.Error())
return err
}
controllerutil.RemoveFinalizer(isbSvc, finalizerName)
controllerutil.RemoveFinalizer(isbSvc, deprecatedFinalizerName)
// Clean up metrics
_ = reconciler.ISBSvcHealth.DeleteLabelValues(isbSvc.Namespace, isbSvc.Name)
}
return nil
}
if controllerutil.ContainsFinalizer(isbSvc, deprecatedFinalizerName) { // Remove deprecated finalizer if exists
controllerutil.RemoveFinalizer(isbSvc, deprecatedFinalizerName)
}
if needsFinalizer(isbSvc) {
controllerutil.AddFinalizer(isbSvc, finalizerName)
}
Expand Down
11 changes: 9 additions & 2 deletions pkg/reconciler/pipeline/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ import (
)

const (
finalizerName = dfv1.ControllerPipeline
finalizerName = "numaflow.numaproj.io/" + dfv1.ControllerPipeline
// TODO: clean up the deprecated finalizer in v1.7
deprecatedFinalizerName = dfv1.ControllerPipeline

pauseTimestampPath = `/metadata/annotations/numaflow.numaproj.io~1pause-timestamp`
)
Expand Down Expand Up @@ -111,7 +113,7 @@ func (r *pipelineReconciler) reconcile(ctx context.Context, pl *dfv1.Pipeline) (
log := logging.FromContext(ctx)
if !pl.DeletionTimestamp.IsZero() {
log.Info("Deleting pipeline")
if controllerutil.ContainsFinalizer(pl, finalizerName) {
if controllerutil.ContainsFinalizer(pl, finalizerName) || controllerutil.ContainsFinalizer(pl, deprecatedFinalizerName) {
if time.Now().Before(pl.DeletionTimestamp.Add(time.Duration(pl.GetTerminationGracePeriodSeconds()) * time.Second)) {
safeToDelete, err := r.safeToDelete(ctx, pl)
if err != nil {
Expand All @@ -135,6 +137,7 @@ func (r *pipelineReconciler) reconcile(ctx context.Context, pl *dfv1.Pipeline) (

}
controllerutil.RemoveFinalizer(pl, finalizerName)
controllerutil.RemoveFinalizer(pl, deprecatedFinalizerName)
// Clean up metrics
_ = reconciler.PipelineHealth.DeleteLabelValues(pl.Namespace, pl.Name)
// Delete corresponding vertex metrics
Expand All @@ -155,6 +158,10 @@ func (r *pipelineReconciler) reconcile(ctx context.Context, pl *dfv1.Pipeline) (
pl.Status.InitConditions()
pl.Status.SetObservedGeneration(pl.Generation)

if controllerutil.ContainsFinalizer(pl, deprecatedFinalizerName) { // Remove deprecated finalizer if exists
controllerutil.RemoveFinalizer(pl, deprecatedFinalizerName)
}

if !controllerutil.ContainsFinalizer(pl, finalizerName) {
controllerutil.AddFinalizer(pl, finalizerName)
}
Expand Down
Loading