Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e fix: add service account log #224

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
}
Loading