fix: wait for talos control plane
This commit is contained in:
parent
afcc4bb389
commit
99da6fa027
|
|
@ -77,6 +77,9 @@ func (r Runner) Run() error {
|
||||||
if err := utils.RunCommandInDir(generatedDir, "talosctl", "bootstrap", "--talosconfig=./clusterconfig/talosconfig", "--endpoints="+r.Config.Talos.BootstrapEndpoint, "--nodes="+r.Config.Talos.BootstrapNode); err != nil {
|
if err := utils.RunCommandInDir(generatedDir, "talosctl", "bootstrap", "--talosconfig=./clusterconfig/talosconfig", "--endpoints="+r.Config.Talos.BootstrapEndpoint, "--nodes="+r.Config.Talos.BootstrapNode); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := utils.RunCommandInDir(generatedDir, "talosctl", "health", "--talosconfig=./clusterconfig/talosconfig", "--endpoints="+r.Config.Talos.BootstrapEndpoint, "--nodes="+r.Config.Talos.BootstrapNode, "--wait-timeout=2m"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := utils.RunCommandInDir(generatedDir, "talosctl", "kubeconfig", "--talosconfig=./clusterconfig/talosconfig", "--nodes="+r.Config.Talos.KubeconfigNode, "."); err != nil {
|
if err := utils.RunCommandInDir(generatedDir, "talosctl", "kubeconfig", "--talosconfig=./clusterconfig/talosconfig", "--nodes="+r.Config.Talos.KubeconfigNode, "."); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -93,10 +96,10 @@ func waitForTalosReboot(dir string, cfg config.Config) error {
|
||||||
deadline := time.Now().Add(5 * time.Minute)
|
deadline := time.Now().Add(5 * time.Minute)
|
||||||
offline := false
|
offline := false
|
||||||
for time.Now().Before(deadline) {
|
for time.Now().Before(deadline) {
|
||||||
err := utils.RunCommandQuietInDir(dir, "talosctl", "get", "machinestatus", "--talosconfig=./clusterconfig/talosconfig", "--endpoints="+cfg.Talos.BootstrapEndpoint, "--nodes="+cfg.Talos.BootstrapNode)
|
output, err := utils.RunCommandQuietOutputInDir(dir, "talosctl", "get", "machinestatus", "--output=json", "--talosconfig=./clusterconfig/talosconfig", "--endpoints="+cfg.Talos.BootstrapEndpoint, "--nodes="+cfg.Talos.BootstrapNode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
offline = true
|
offline = true
|
||||||
} else if offline {
|
} else if offline && strings.Contains(string(output), `"stage": "running"`) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ func RunCommandInDir(dir string, name string, args ...string) error {
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunCommandQuietInDir(dir string, name string, args ...string) error {
|
func RunCommandQuietOutputInDir(dir string, name string, args ...string) ([]byte, error) {
|
||||||
cmd := exec.Command(name, args...)
|
cmd := exec.Command(name, args...)
|
||||||
cmd.Dir = dir
|
cmd.Dir = dir
|
||||||
return cmd.Run()
|
return cmd.Output()
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunCommandOutput(name string, args ...string) ([]byte, error) {
|
func RunCommandOutput(name string, args ...string) ([]byte, error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue