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

Add retries retrieving kubeconfig #83

Merged
merged 2 commits into from
Mar 30, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,26 @@ func (a *action) Execute(ctx *actions.ActionContext) error {
return errors.Wrap(err, "failed to create the worker Cluster")
}

// Get the workload cluster kubeconfig
// Wait for the control plane initialization
raw = bytes.Buffer{}
cmd = node.Command("sh", "-c", "clusterctl -n "+capiClustersNamespace+" get kubeconfig "+descriptorFile.ClusterID+" | tee "+kubeconfigPath)
cmd = node.Command("kubectl", "-n", capiClustersNamespace, "wait", "--for=condition=ControlPlaneInitialized", "--timeout", "5m", "cluster", descriptorFile.ClusterID)
if err := cmd.SetStdout(&raw).Run(); err != nil {
return errors.Wrap(err, "failed to get workload cluster kubeconfig")
return errors.Wrap(err, "failed to create the worker Cluster")
}
kubeconfig := raw.String()

ctx.Status.End(true) // End Creating the workload cluster

ctx.Status.Start("Saving the workload cluster kubeconfig 📝")
defer ctx.Status.End(false)

// Get the workload cluster kubeconfig
raw = bytes.Buffer{}
cmd = node.Command("sh", "-c", "clusterctl -n "+capiClustersNamespace+" get kubeconfig "+descriptorFile.ClusterID+" | tee "+kubeconfigPath)
stg-0 marked this conversation as resolved.
Show resolved Hide resolved
if err := cmd.SetStdout(&raw).SetStderr(&raw).Run(); err != nil || strings.Contains(raw.String(), "Error:") || raw.String() == "" {
return errors.Wrap(err, "failed to get workload cluster kubeconfig")
}
kubeconfig := raw.String()

workKubeconfigBasePath := strings.Split(workKubeconfigPath, "/")[0]
_, err = os.Stat(workKubeconfigBasePath)
if err != nil {
Expand Down