Skip to content

Commit 9096f9f

Browse files
committed
Look for default service account before marking cluster ready
This was failing from v1.31 onwards in CI. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent 9f541fe commit 9096f9f

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

cmd/ready.go

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ func MakeReady() *cobra.Command {
5656

5757
kubeconfig = os.ExpandEnv(kubeconfig)
5858

59-
// Inspired by Kind: https://github.com/kubernetes-sigs/kind/blob/master/pkg/cluster/internal/create/actions/waitforready/waitforready.go
59+
// Inspired by Kind: https://github.com/kubernetes-sigs/kind/blob/main/pkg/cluster/internal/create/actions/waitforready/waitforready.go
6060
for i := 0; i < attempts; i++ {
6161
if !quiet {
62-
fmt.Printf("Checking cluster status: %d/%d \n", i+1, attempts)
62+
fmt.Printf("Checking for nodes to be ready: %d/%d \n", i+1, attempts)
6363
}
6464

6565
task := execute.ExecTask{
@@ -89,9 +89,10 @@ func MakeReady() *cobra.Command {
8989
ready := true
9090
for _, part := range parts {
9191
trimmed := strings.TrimSpace(part)
92+
trimmed = strings.Trim(trimmed, "'")
9293

9394
// Note: The command is returning a single quoted string
94-
if len(trimmed) > 0 && trimmed != "'True'" {
95+
if len(trimmed) > 0 && trimmed != "True" {
9596
ready = false
9697
break
9798
}
@@ -107,6 +108,38 @@ func MakeReady() *cobra.Command {
107108
time.Sleep(pause)
108109
}
109110

111+
// Wait until the default service account is created. This was causing a failure during CI.
112+
for i := 0; i < attempts; i++ {
113+
if !quiet {
114+
fmt.Printf("Looking for default service account: %d/%d \n", i+1, attempts)
115+
}
116+
117+
task := execute.ExecTask{
118+
Command: "kubectl",
119+
Args: []string{
120+
"get",
121+
"serviceaccount",
122+
"default",
123+
"--kubeconfig=" + kubeconfig,
124+
"--context=" + contextName,
125+
},
126+
StreamStdio: false,
127+
}
128+
129+
res, err := task.Execute(cmd.Context())
130+
if err != nil {
131+
return err
132+
}
133+
134+
if res.ExitCode == 0 {
135+
if !quiet {
136+
fmt.Printf("Default service account is ready\n")
137+
}
138+
break
139+
}
140+
time.Sleep(pause)
141+
}
142+
110143
return nil
111144
}
112145
return command

0 commit comments

Comments
 (0)