@@ -109,11 +109,11 @@ type IssuingManager struct {
109109}
110110
111111type projectionKey struct {
112- namespace string
113- podName string
114- podUID string
115- volumeName string
116- sourceIndex int
112+ Namespace string
113+ PodName string
114+ PodUID string
115+ VolumeName string
116+ SourceIndex int
117117}
118118
119119type projectionRecord struct {
@@ -259,13 +259,14 @@ func (m *IssuingManager) queueAllProjectionsForPod(uid types.UID) {
259259 continue
260260 }
261261
262- m .projectionQueue .Add (projectionKey {
263- namespace : pod .ObjectMeta .Namespace ,
264- podName : pod .ObjectMeta .Name ,
265- podUID : string (pod .ObjectMeta .UID ),
266- volumeName : v .Name ,
267- sourceIndex : sourceIndex ,
268- })
262+ key := projectionKey {
263+ Namespace : pod .ObjectMeta .Namespace ,
264+ PodName : pod .ObjectMeta .Name ,
265+ PodUID : string (pod .ObjectMeta .UID ),
266+ VolumeName : v .Name ,
267+ SourceIndex : sourceIndex ,
268+ }
269+ m .projectionQueue .Add (key )
269270 }
270271 }
271272}
@@ -298,7 +299,7 @@ func (m *IssuingManager) processNextProjection(ctx context.Context) bool {
298299
299300 err := m .handleProjection (ctx , key )
300301 if err != nil {
301- utilruntime .HandleErrorWithContext (ctx , err , "while handling podCertificate projected volume source" , "namespace" , key .namespace , "pod" , key .podName , "volume" , key .volumeName , "sourceIndex" , key .sourceIndex )
302+ utilruntime .HandleErrorWithContext (ctx , err , "while handling podCertificate projected volume source" , "namespace" , key .Namespace , "pod" , key .PodName , "volume" , key .VolumeName , "sourceIndex" , key .SourceIndex )
302303 m .projectionQueue .AddRateLimited (key )
303304 return true
304305 }
@@ -311,7 +312,7 @@ func (m *IssuingManager) handleProjection(ctx context.Context, key projectionKey
311312 // Remember, returning nil from this function indicates that the work item
312313 // was successfully processed, and should be dropped from the queue.
313314
314- pod , ok := m .podManager .GetPodByUID (types .UID (key .podUID ))
315+ pod , ok := m .podManager .GetPodByUID (types .UID (key .PodUID ))
315316 if ! ok {
316317 // If we can't find the pod anymore, it's been deleted. Clear all our
317318 // internal state associated with the pod and return a nil error so it
@@ -320,7 +321,7 @@ func (m *IssuingManager) handleProjection(ctx context.Context, key projectionKey
320321 m .lock .Lock ()
321322 defer m .lock .Unlock ()
322323 for k := range m .credStore {
323- if k .namespace == key .namespace && k .podName == key .podName && k .podUID == key .podUID {
324+ if k .Namespace == key .Namespace && k .PodName == key .PodName && k .PodUID == key .PodUID {
324325 delete (m .credStore , k )
325326 }
326327 }
@@ -330,9 +331,9 @@ func (m *IssuingManager) handleProjection(ctx context.Context, key projectionKey
330331
331332 var source * corev1.PodCertificateProjection
332333 for _ , vol := range pod .Spec .Volumes {
333- if vol .Name == key .volumeName && vol .Projected != nil {
334+ if vol .Name == key .VolumeName && vol .Projected != nil {
334335 for i , volumeSource := range vol .Projected .Sources {
335- if i == key .sourceIndex && volumeSource .PodCertificate != nil {
336+ if i == key .SourceIndex && volumeSource .PodCertificate != nil {
336337 source = volumeSource .PodCertificate
337338 }
338339 }
@@ -409,7 +410,7 @@ func (m *IssuingManager) handleProjection(ctx context.Context, key projectionKey
409410 // We are working through the initial issuance. We created a PCR, now
410411 // we need to wait for it to reach a terminal state.
411412
412- pcr , err := m .pcrLister .PodCertificateRequests (key .namespace ).Get (state .pcrName )
413+ pcr , err := m .pcrLister .PodCertificateRequests (key .Namespace ).Get (state .pcrName )
413414 if k8serrors .IsNotFound (err ) && m .clock .Now ().After (state .pcrAbandonAt ) {
414415 // "Not Found" could be due to informer lag, or because someone
415416 // deleted the PodCertificateRequest. In the first case, the
@@ -423,7 +424,7 @@ func (m *IssuingManager) handleProjection(ctx context.Context, key projectionKey
423424 rec .curState = & credStateInitial {}
424425 return fmt .Errorf ("PodCertificateRequest %q appears to have been deleted" , pcr .ObjectMeta .Namespace + "/" + pcr .ObjectMeta .Name )
425426 } else if err != nil {
426- return fmt .Errorf ("while getting PodCertificateRequest %q: %w" , key .namespace + "/" + state .pcrName , err )
427+ return fmt .Errorf ("while getting PodCertificateRequest %q: %w" , key .Namespace + "/" + state .pcrName , err )
427428 }
428429
429430 // If the PodCertificateRequest has moved to a terminal state, update
@@ -525,7 +526,7 @@ func (m *IssuingManager) handleProjection(ctx context.Context, key projectionKey
525526
526527 case * credStateWaitRefresh :
527528 // Check the refresh PodCertificateRequest
528- pcr , err := m .pcrLister .PodCertificateRequests (key .namespace ).Get (state .refreshPCRName )
529+ pcr , err := m .pcrLister .PodCertificateRequests (key .Namespace ).Get (state .refreshPCRName )
529530 if k8serrors .IsNotFound (err ) && m .clock .Now ().After (state .refreshPCRAbandonAt ) {
530531 // "Not Found" could be due to informer lag, or because someone
531532 // deleted the PodCertificateRequest. In the first case, the
@@ -543,7 +544,7 @@ func (m *IssuingManager) handleProjection(ctx context.Context, key projectionKey
543544 }
544545 return fmt .Errorf ("PodCertificateRequest appears to have been deleted" )
545546 } else if err != nil {
546- return fmt .Errorf ("while getting PodCertificateRequest %q: %w" , key .namespace + "/" + state .refreshPCRName , err )
547+ return fmt .Errorf ("while getting PodCertificateRequest %q: %w" , key .Namespace + "/" + state .refreshPCRName , err )
547548 }
548549
549550 // If the PodCertificateRequest has moved to a terminal state, update
@@ -675,24 +676,23 @@ func (m *IssuingManager) createPodCertificateRequest(
675676}
676677
677678func (m * IssuingManager ) GetPodCertificateCredentialBundle (ctx context.Context , namespace , podName , podUID , volumeName string , sourceIndex int ) ([]byte , []byte , error ) {
679+ credKey := projectionKey {
680+ Namespace : namespace ,
681+ PodName : podName ,
682+ PodUID : podUID ,
683+ VolumeName : volumeName ,
684+ SourceIndex : sourceIndex ,
685+ }
686+
678687 var rec * projectionRecord
679688 func () {
680689 m .lock .Lock ()
681690 defer m .lock .Unlock ()
682-
683- credKey := projectionKey {
684- namespace : namespace ,
685- podName : podName ,
686- podUID : podUID ,
687- volumeName : volumeName ,
688- sourceIndex : sourceIndex ,
689- }
690691 rec = m .credStore [credKey ]
691-
692692 }()
693693
694694 if rec == nil {
695- return nil , nil , fmt .Errorf ("no credentials yet" )
695+ return nil , nil , fmt .Errorf ("no credentials yet for key=%v" , credKey )
696696 }
697697
698698 rec .lock .Lock ()
0 commit comments