Skip to content

Commit d9b6a62

Browse files
author
Jan Roehrich
committed
implemented some of modulitos' review proposals
1 parent 18f345b commit d9b6a62

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

pkg/cache/cache.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ type Request struct {
4949
func (r Request) CacheKey() string {
5050
return r.Namespace + "/" + r.Name
5151
}
52-
func (r Request) WithNotification() Request {
53-
r.RequestNotification = true
54-
return r
55-
}
5652

5753
type Response struct {
5854
RoleARN string

pkg/handler/handler.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,13 @@ func (m *Modifier) buildPodPatchConfig(pod *corev1.Pod) *podPatchConfig {
433433
}
434434

435435
// Use the STS WebIdentity method if set
436-
request := cache.Request{Namespace: pod.Namespace, Name: pod.Spec.ServiceAccountName}
437-
response := m.Cache.Get(request.WithNotification())
436+
request := cache.Request{Namespace: pod.Namespace, Name: pod.Spec.ServiceAccountName, RequestNotification: true}
437+
response := m.Cache.Get(request)
438438
if !response.FoundInCache && m.saLookupGraceTime > 0 {
439439
klog.Warningf("Service account %s not found in the cache. Waiting up to %s to be notified", request.CacheKey(), m.saLookupGraceTime)
440440
select {
441441
case <-response.Notifier:
442+
request = cache.Request{Namespace: pod.Namespace, Name: pod.Spec.ServiceAccountName, RequestNotification: false}
442443
response = m.Cache.Get(request)
443444
if !response.FoundInCache {
444445
klog.Warningf("Service account %s not found in the cache after being notified. Not mutating.", request.CacheKey())

0 commit comments

Comments
 (0)