fix: remove goroutine timeout, registration takes 30-60s normally

This commit is contained in:
admin 2026-08-01 20:29:47 +00:00
parent da56eaf164
commit e4b1021c52
2 changed files with 5 additions and 20 deletions

View file

@ -201,6 +201,7 @@ WALLARM_REGION=%s
return return
} }
fmt.Printf("Installing %d node(s)...\n", len(s.Nodes))
for _, node := range s.Nodes { for _, node := range s.Nodes {
if err := native.InstallNode(node, s.APIToken, s.APIHost, labels); err != nil { if err := native.InstallNode(node, s.APIToken, s.APIHost, labels); err != nil {
fmt.Fprintf(os.Stderr, "Deployment failed: %v\n", err) fmt.Fprintf(os.Stderr, "Deployment failed: %v\n", err)

View file

@ -83,30 +83,14 @@ func InstallNode(node state.Node, apiToken, apiHost, labels string) error {
exec.Command("bash", filepath.Join(DeployTo, "pick-module.sh")).Run() exec.Command("bash", filepath.Join(DeployTo, "pick-module.sh")).Run()
fmt.Printf("[%s] Registering node...\n", node.Name) fmt.Printf("[%s] Registering node...\n", node.Name)
fmt.Printf("[%s] Registering node...\n", node.Name) fmt.Printf("[%s] Registering node (this may take 30-60s)...\n", node.Name)
registerCmd := exec.Command("bash", "-c", registerCmd := exec.Command("bash", "-c",
fmt.Sprintf("source %s/env.list 2>/dev/null; %s/register-node job:register -token '%s' -host '%s'", fmt.Sprintf("source %s/env.list 2>/dev/null; %s/register-node job:register -token '%s' -host '%s'",
DeployTo, DeployTo, apiToken, apiHost)) DeployTo, DeployTo, apiToken, apiHost))
registerCmd.Dir = DeployTo registerCmd.Dir = DeployTo
out, regErr := registerCmd.CombinedOutput()
// Run with explicit timeout if regErr != nil {
type result struct { return fmt.Errorf("register: %w\n%s", regErr, string(out))
out []byte
err error
}
ch := make(chan result, 1)
go func() {
out, err := registerCmd.CombinedOutput()
ch <- result{out, err}
}()
select {
case r := <-ch:
if r.err != nil {
return fmt.Errorf("register: %w\n%s", r.err, string(r.out))
}
case <-time.After(60 * time.Second):
registerCmd.Process.Kill()
return fmt.Errorf("registration timed out")
} }
// 7. Stop our temporary NGINX, start Wallarm via supervisord // 7. Stop our temporary NGINX, start Wallarm via supervisord