Skip to content

Commit

Permalink
fix placeholder pod cleanup return bug
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverMKing committed Jul 10, 2024
1 parent faca74b commit 895cb29
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pkg/controller/keyvault/placeholder_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ import (
"github.com/Azure/aks-app-routing-operator/pkg/util"
)

var (
placeholderPodControllerName = controllername.New("keyvault", "placeholder", "pod")
)
var placeholderPodControllerName = controllername.New("keyvault", "placeholder", "pod")

// PlaceholderPodController manages a single-replica deployment of no-op pods that mount the
// Keyvault secrets referenced by each secret provider class managed by IngressSecretProviderClassReconciler.
Expand Down Expand Up @@ -68,10 +66,10 @@ func (p *PlaceholderPodController) Reconcile(ctx context.Context, req ctrl.Reque

// do metrics
defer func() {
//placing this call inside a closure allows for result and err to be bound after Reconcile executes
//this makes sure they have the proper value
//just calling defer metrics.HandleControllerReconcileMetrics(controllerName, result, err) would bind
//the values of result and err to their zero values, since they were just instantiated
// placing this call inside a closure allows for result and err to be bound after Reconcile executes
// this makes sure they have the proper value
// just calling defer metrics.HandleControllerReconcileMetrics(controllerName, result, err) would bind
// the values of result and err to their zero values, since they were just instantiated
metrics.HandleControllerReconcileMetrics(placeholderPodControllerName, result, err)
}()

Expand Down Expand Up @@ -166,7 +164,7 @@ func (p *PlaceholderPodController) reconcileObjectDeployment(dep *appsv1.Deploym
}

if cleanPod {
logger.Info("cleaning unused placeholder pod deployment")
logger.Info("attempting to clean unused placeholder pod deployment")
logger.Info("getting placeholder deployment")
toCleanDeployment := &appsv1.Deployment{}
if err = p.client.Get(ctx, client.ObjectKeyFromObject(dep), toCleanDeployment); err != nil {
Expand All @@ -177,6 +175,9 @@ func (p *PlaceholderPodController) reconcileObjectDeployment(dep *appsv1.Deploym
err = p.client.Delete(ctx, toCleanDeployment)
return result, client.IgnoreNotFound(err)
}

logger.Info("deployment found but it's not managed by us, skipping cleaning")
return result, nil
}

// Manage a deployment resource
Expand Down

0 comments on commit 895cb29

Please sign in to comment.