Update appversion finalizer name (#2161)

* update appversion finalizer name

Signed-off-by: wenhaozhou <wenhaozhou@yunify.com>

* Update pkg/controller/application/appversion_contrlller.go

* Update pkg/controller/application/appversion_contrlller.go

* Update staging/src/kubesphere.io/api/application/v2/constants.go

* Update staging/src/kubesphere.io/api/application/v2/constants.go

---------

Signed-off-by: wenhaozhou <wenhaozhou@yunify.com>
Co-authored-by: hongming <coder.scala@gmail.com>
This commit is contained in:
Wenhao Zhou
2025-01-06 16:34:19 +08:00
committed by hongming
parent 96f85d4500
commit 9f6f781a39
3 changed files with 8 additions and 2 deletions

View File

@@ -66,6 +66,11 @@ func (r *AppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Request)
if err := r.Client.Get(ctx, req.NamespacedName, appVersion); err != nil {
return reconcile.Result{}, client.IgnoreNotFound(err)
}
if !controllerutil.ContainsFinalizer(appVersion, appv2.CleanupFinalizer) {
controllerutil.RemoveFinalizer(appVersion, appv2.StoreCleanFinalizer)
controllerutil.AddFinalizer(appVersion, appv2.CleanupFinalizer)
return ctrl.Result{}, r.Update(ctx, appVersion)
}
//Delete app files, non-important logic, errors will not affect the main process
if !appVersion.ObjectMeta.DeletionTimestamp.IsZero() {
@@ -80,7 +85,7 @@ func (r *AppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Request)
func (r *AppVersionReconciler) deleteFile(ctx context.Context, appVersion *appv2.ApplicationVersion) error {
defer func() {
controllerutil.RemoveFinalizer(appVersion, appv2.StoreCleanFinalizer)
controllerutil.RemoveFinalizer(appVersion, appv2.CleanupFinalizer)
err := r.Update(ctx, appVersion)
if err != nil {
klog.Errorf("Failed to remove finalizer from appversion %s: %v", appVersion.Name, err)

View File

@@ -219,7 +219,7 @@ func CreateOrUpdateAppVersion(ctx context.Context, client runtimeclient.Client,
Maintainer: vRequest.Maintainers,
PullUrl: vRequest.PullUrl,
}
appVersion.Finalizers = []string{appv2.StoreCleanFinalizer}
appVersion.Finalizers = []string{appv2.CleanupFinalizer}
labels := appVersion.GetLabels()
if labels == nil {

View File

@@ -38,6 +38,7 @@ const (
MaxImageWidth = 128
ApplicationNamespace = "extension-openpitrix"
StoreCleanFinalizer = "storeCleanFinalizer.application.kubesphere.io"
CleanupFinalizer = "application.kubesphere.io/cleanup"
SystemWorkspace = "system-workspace"
// App review status: draft, submitted, passed, rejected, suspended, active
ReviewStatusDraft = "draft"