Skip to content

Commit

Permalink
Merge pull request #54 from kinarashah/124
Browse files Browse the repository at this point in the history
  • Loading branch information
kinarashah authored Jun 28, 2022
2 parents 3d379c3 + 3c8925c commit dbf9ef8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/podimpersonation/podimpersonation.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,19 @@ func (s *PodImpersonation) createPod(ctx context.Context, user user.Info, role *
if err != nil {
return nil, err
}

if _, ok := tokenSecret.Data[v1.ServiceAccountTokenKey]; !ok {
for {
logrus.Debugf("wait for svc account secret to be populated with token %s", tokenSecret.Name)
time.Sleep(2 * time.Second)
tokenSecret, err = client.CoreV1().Secrets(sa.Namespace).Get(ctx, sc.Name, metav1.GetOptions{})
if err != nil {
return nil, err
}
if _, ok := tokenSecret.Data[v1.ServiceAccountTokenKey]; ok {
break
}
}
}
pod = s.augmentPod(pod, sa, tokenSecret, podOptions.ImageOverride)

if err := s.createConfigMaps(ctx, user, role, pod, podOptions, client); err != nil {
Expand All @@ -358,7 +370,6 @@ func (s *PodImpersonation) createPod(ctx context.Context, user user.Info, role *
if err := s.createSecrets(ctx, role, pod, podOptions, client); err != nil {
return nil, err
}

pod.OwnerReferences = ref(role)
if pod.Annotations == nil {
pod.Annotations = map[string]string{}
Expand Down

0 comments on commit dbf9ef8

Please sign in to comment.