Skip to content

Commit

Permalink
e2e fix: add service account log
Browse files Browse the repository at this point in the history
Signed-off-by: tao.yang <[email protected]>
  • Loading branch information
ty-dc committed May 6, 2024
1 parent 71bf7b1 commit 345be8c
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions framework/serviceaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ package framework

import (
"context"
"fmt"
"time"

corev1 "k8s.io/api/core/v1"
api_errors "k8s.io/apimachinery/pkg/api/errors"
"sigs.k8s.io/controller-runtime/pkg/client"
"time"
)

func (f *Framework) GetServiceAccount(saName, namespace string) (*corev1.ServiceAccount, error) {
Expand Down Expand Up @@ -36,13 +39,26 @@ func (f *Framework) WaitServiceAccountReady(saName, namespace string, timeout ti
for {
select {
default:
as, _ := f.GetServiceAccount(saName, namespace)
as, err := f.GetServiceAccount(saName, namespace)
b := api_errors.IsNotFound(err)
if b {
f.Log("service account: %s/%s not found", namespace, saName)
time.Sleep(time.Second)
continue
}

if err != nil {
f.Log("failed to get service account, error %v ", err)
time.Sleep(time.Second)
continue
}

if as != nil {
return nil
}
time.Sleep(time.Second)

case <-ctx.Done():
return ErrTimeOut
return fmt.Errorf("%w: failed to wait for service account to be ready", ErrTimeOut)
}
}
}

0 comments on commit 345be8c

Please sign in to comment.