Skip to content

Commit

Permalink
kinder: retry the 'etcd --version' during 'cluster-info'
Browse files Browse the repository at this point in the history
During CI the cluster-info fails with 'etcd --version' exiting with
status 1, but locally this cannot be reproduced.

Retry the command 10 times to try to avoid flakes.
  • Loading branch information
neolit123 committed Dec 8, 2021
1 parent dd0cc31 commit 6fe0dde
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions kinder/pkg/cluster/manager/actions/cluster-info.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package actions

import (
"fmt"
"github.com/pkg/errors"
"strings"

"github.com/pkg/errors"

versionutils "k8s.io/apimachinery/pkg/util/version"
"k8s.io/kubeadm/kinder/pkg/cluster/status"
)
Expand Down Expand Up @@ -66,12 +67,25 @@ func CluterInfo(c *status.Cluster) error {
"--",
}

var lines []string
var err error

// Get the version of etcdctl from the etcd binary
// Retry the version command for a while to avoid "exec" flakes
versionArgs := append(etcdArgs, "etcd", "--version")
lines, err := cp1.Command("kubectl", versionArgs...).RunAndCapture()
versionArgs = append([]string{"--request-timeout=2"}, versionArgs...) // Ensure shorter timeout
for i := 0; i < 10; i++ {
lines, err = cp1.Command("kubectl", versionArgs...).RunAndCapture()
if err == nil {
break
}
cp1.Infof("Could not execute 'etcd --version' inside %q (attempt %d/%d): %v\n", cp1.Name(), i+1, 10,
errors.Wrap(err, strings.Join(lines, "\n")))
}
if err != nil {
return err
}

etcdctlVersion, err := parseEtcdctlVersion(lines)
if err != nil {
return err
Expand Down

0 comments on commit 6fe0dde

Please sign in to comment.