@@ -123,6 +123,13 @@ func (r *VaultDynamicSecretReconciler) Reconcile(ctx context.Context, req ctrl.R
123
123
return ctrl.Result {}, r .handleDeletion (ctx , o )
124
124
}
125
125
126
+ if addedFinalizer , err := maybeAddFinalizer (ctx , r .Client , o , vaultDynamicSecretFinalizer ); err != nil {
127
+ return ctrl.Result {}, err
128
+ } else if addedFinalizer {
129
+ // the finalizer was added, requeue the request.
130
+ return ctrl.Result {Requeue : true }, nil
131
+ }
132
+
126
133
r .referenceCache .Set (SecretTransformation , req .NamespacedName ,
127
134
helpers .GetTransformationRefObjKeys (
128
135
o .Spec .Destination .Transformation , o .Namespace )... )
@@ -150,15 +157,6 @@ func (r *VaultDynamicSecretReconciler) Reconcile(ctx context.Context, req ctrl.R
150
157
o .Status .VaultClientMeta .CacheKey = clientCacheKey .String ()
151
158
o .Status .VaultClientMeta .ID = vClient .ID ()
152
159
153
- if ! o .Spec .AllowStaticCreds && o .Status .LastGeneration != o .GetGeneration () && o .Status .SecretLease .ID == "" {
154
- logger .Info ("short circuting sync, initial generation with empty lease" )
155
- o .Status .LastGeneration = o .GetGeneration ()
156
- if err := r .updateStatus (ctx , o ); err != nil {
157
- return ctrl.Result {}, err
158
- }
159
- return ctrl.Result {RequeueAfter : computeHorizonWithJitter (requeueDurationOnError )}, nil
160
- }
161
-
162
160
var syncReason string
163
161
// doSync indicates that the controller should perform the secret sync,
164
162
switch {
@@ -188,12 +186,6 @@ func (r *VaultDynamicSecretReconciler) Reconcile(ctx context.Context, req ctrl.R
188
186
}
189
187
190
188
doSync := syncReason != ""
191
- logger .Info ("Reconciling" ,
192
- "generation" , o .GetGeneration (),
193
- "lastGeneration" , o .Status .LastGeneration ,
194
- "leaseID" , o .Status .SecretLease .ID ,
195
- "doSync" , doSync ,
196
- )
197
189
leaseID := o .Status .SecretLease .ID
198
190
if ! doSync && r .runtimePodUID != "" && r .runtimePodUID != o .Status .LastRuntimePodUID {
199
191
// don't take part in the thundering herd on start up,
@@ -563,12 +555,6 @@ func (r *VaultDynamicSecretReconciler) awaitVaultSecretRotation(ctx context.Cont
563
555
}
564
556
565
557
func (r * VaultDynamicSecretReconciler ) updateStatus (ctx context.Context , o * secretsv1beta1.VaultDynamicSecret ) error {
566
- logger := log .FromContext (ctx ).WithName ("updateStatus" )
567
- logger .Info ("Updating status" ,
568
- "settingLastGeneration" , o .GetGeneration (),
569
- "existingLastGeneration" , o .Status .LastGeneration ,
570
- )
571
-
572
558
if r .runtimePodUID != "" {
573
559
o .Status .LastRuntimePodUID = r .runtimePodUID
574
560
}
@@ -579,8 +565,7 @@ func (r *VaultDynamicSecretReconciler) updateStatus(ctx context.Context, o *secr
579
565
"Failed to update the resource's status, err=%s" , err )
580
566
}
581
567
582
- _ , err := maybeAddFinalizer (ctx , r .Client , o , vaultDynamicSecretFinalizer )
583
- return err
568
+ return nil
584
569
}
585
570
586
571
func (r * VaultDynamicSecretReconciler ) getVaultSecretLease (resp * api.Secret ) * secretsv1beta1.VaultSecretLease {
0 commit comments