@@ -269,14 +269,14 @@ func (r *Reconciler) reconcile(ctx context.Context, spcps *secretsstorev1.Secret
269
269
err = r .cache .Get (
270
270
ctx ,
271
271
client.ObjectKey {
272
- Namespace : spcps . Namespace ,
273
- Name : spcps . Status . PodName ,
272
+ Namespace : podNamespace ,
273
+ Name : podName ,
274
274
},
275
275
pod ,
276
276
)
277
277
if err != nil {
278
278
errorReason = internalerrors .PodNotFound
279
- return fmt .Errorf ("failed to get pod %s/%s, err: %w" , spcps . Namespace , spcps . Status . PodName , err )
279
+ return fmt .Errorf ("failed to get pod %s/%s, err: %w" , podNamespace , podName , err )
280
280
}
281
281
// skip rotation if the pod is being terminated
282
282
// or the pod is in succeeded state (for jobs that complete aren't gc yet)
@@ -292,14 +292,14 @@ func (r *Reconciler) reconcile(ctx context.Context, spcps *secretsstorev1.Secret
292
292
err = r .cache .Get (
293
293
ctx ,
294
294
client.ObjectKey {
295
- Namespace : spcps . Namespace ,
296
- Name : spcps . Status . SecretProviderClassName ,
295
+ Namespace : podNamespace ,
296
+ Name : secretProviderClass ,
297
297
},
298
298
spc ,
299
299
)
300
300
if err != nil {
301
301
errorReason = internalerrors .SecretProviderClassNotFound
302
- return fmt .Errorf ("failed to get secret provider class %s/%s, err: %w" , spcps . Namespace , spcps . Status . SecretProviderClassName , err )
302
+ return fmt .Errorf ("failed to get secret provider class %s/%s, err: %w" , podNamespace , secretProviderClass , err )
303
303
}
304
304
305
305
// determine which pod volume this is associated with
@@ -362,16 +362,16 @@ func (r *Reconciler) reconcile(ctx context.Context, spcps *secretsstorev1.Secret
362
362
// This comprises the secret parameter in the MountRequest to the provider
363
363
if nodePublishSecretRef != nil {
364
364
// read secret from the informer cache
365
- secret , err := r .secretStore .GetNodePublishSecretRefSecret (nodePublishSecretRef .Name , spcps . Namespace )
365
+ secret , err := r .secretStore .GetNodePublishSecretRefSecret (nodePublishSecretRef .Name , podNamespace )
366
366
if err != nil {
367
367
if apierrors .IsNotFound (err ) {
368
368
klog .ErrorS (err ,
369
- fmt .Sprintf ("nodePublishSecretRef not found. If the secret with name exists in namespace, label the secret by running 'kubectl label secret %s %s=true -n %s" , nodePublishSecretRef .Name , controllers .SecretUsedLabel , spcps . Namespace ),
370
- "name" , nodePublishSecretRef .Name , "namespace" , spcps . Namespace )
369
+ fmt .Sprintf ("nodePublishSecretRef not found. If the secret with name exists in namespace, label the secret by running 'kubectl label secret %s %s=true -n %s" , nodePublishSecretRef .Name , controllers .SecretUsedLabel , podNamespace ),
370
+ "name" , nodePublishSecretRef .Name , "namespace" , podNamespace )
371
371
}
372
372
errorReason = internalerrors .NodePublishSecretRefNotFound
373
- r .generateEvent (pod , corev1 .EventTypeWarning , mountRotationFailedReason , fmt .Sprintf ("failed to get node publish secret %s/%s, err: %+v" , spcps . Namespace , nodePublishSecretRef .Name , err ))
374
- return fmt .Errorf ("failed to get node publish secret %s/%s, err: %w" , spcps . Namespace , nodePublishSecretRef .Name , err )
373
+ r .generateEvent (pod , corev1 .EventTypeWarning , mountRotationFailedReason , fmt .Sprintf ("failed to get node publish secret %s/%s, err: %+v" , podNamespace , nodePublishSecretRef .Name , err ))
374
+ return fmt .Errorf ("failed to get node publish secret %s/%s, err: %w" , podNamespace , nodePublishSecretRef .Name , err )
375
375
}
376
376
377
377
for k , v := range secret .Data {
@@ -404,7 +404,7 @@ func (r *Reconciler) reconcile(ctx context.Context, spcps *secretsstorev1.Secret
404
404
newObjectVersions , errorReason , err := secretsstore .MountContent (ctx , providerClient , string (paramsJSON ), string (secretsJSON ), spcps .Status .TargetPath , string (permissionJSON ), oldObjectVersions )
405
405
if err != nil {
406
406
r .generateEvent (pod , corev1 .EventTypeWarning , mountRotationFailedReason , fmt .Sprintf ("provider mount err: %+v" , err ))
407
- return fmt .Errorf ("failed to rotate objects for pod %s/%s, err: %w" , spcps . Namespace , spcps . Status . PodName , err )
407
+ return fmt .Errorf ("failed to rotate objects for pod %s/%s, err: %w" , podNamespace , podName , err )
408
408
}
409
409
410
410
// compare the old object versions and new object versions to check if any of the objects
@@ -491,7 +491,7 @@ func (r *Reconciler) reconcile(ctx context.Context, spcps *secretsstorev1.Secret
491
491
492
492
patchFn := func () (bool , error ) {
493
493
// patch secret data with the new contents
494
- if err := r .patchSecret (ctx , secretObj .SecretName , spcps . Namespace , datamap ); err != nil {
494
+ if err := r .patchSecret (ctx , secretObj .SecretName , podNamespace , datamap ); err != nil {
495
495
// syncSecret.enabled is set to false by default in the helm chart for installing the driver in v0.0.23+
496
496
// that would result in a forbidden error, so generate a warning that can be helpful for debugging
497
497
if apierrors .IsForbidden (err ) {
0 commit comments