Skip to content

Commit

Permalink
fix deletion logic (when cleanup is false)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkb0318 committed May 15, 2024
1 parent 0e56e4f commit 811d295
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
15 changes: 6 additions & 9 deletions internal/controller/irsasetup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package controller

import (
"context"
"errors"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -105,6 +104,11 @@ func (r *IRSASetupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (

if !obj.DeletionTimestamp.IsZero() {
err = r.reconcileDelete(ctx, obj, kubeClient)
if err != nil {
return ctrl.Result{}, err
}
controllerutil.RemoveFinalizer(obj, irsamanagerFinalizer)
err = r.Update(ctx, obj)
if err == nil {
log.Info("successfully deleted")
}
Expand Down Expand Up @@ -149,14 +153,7 @@ func (r *IRSASetupReconciler) reconcileDelete(ctx context.Context, obj *irsav1al
if err != nil {
return err
}
err = selfhosted.Delete(ctx, factory)
if err != nil {
return err
}
if !controllerutil.RemoveFinalizer(obj, irsamanagerFinalizer) {
return errors.New("failed to remove finalizer")
}
return r.Update(ctx, obj)
return selfhosted.Delete(ctx, factory)
}

// reconcileSelfhosted ensures that the self-hosted resources are set up correctly.
Expand Down
5 changes: 2 additions & 3 deletions internal/selfhosted/webhook/base_manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ func (b *baseManifestFactory) deployment() *appsv1.Deployment {
ServiceAccountName: b.serviceAccountMeta.Name,
Containers: []corev1.Container{
{
Name: "pod-identity-webhook",
Image: "amazon/amazon-eks-pod-identity-webhook:latest",

Name: "pod-identity-webhook",
Image: "amazon/amazon-eks-pod-identity-webhook:latest",
ImagePullPolicy: corev1.PullAlways,
// Command: []string{}, // Command must be patched
VolumeMounts: []corev1.VolumeMount{
Expand Down

0 comments on commit 811d295

Please sign in to comment.