diff --git a/internal/executables/build.go b/internal/executables/build.go index 2792e5f06..5656ed4f9 100644 --- a/internal/executables/build.go +++ b/internal/executables/build.go @@ -91,7 +91,7 @@ func build(debug bool, gitCommit, version, githubClientID, githubClientSecret st builtTuple := builtTupleFunc(bin) - args := []string{"build", "-o", bin.OutDir} + args := []string{"build", "-race", "-o", bin.OutDir} ldflags := "-s -w " if debug { @@ -107,6 +107,7 @@ func build(debug bool, gitCommit, version, githubClientID, githubClientSecret st for k, v := range bin.Env { cmdEnv = append(cmdEnv, fmt.Sprintf("%s=%s", k, v)) } + cmdEnv = append(cmdEnv, "CGO_ENABLED=1") cmd := exec.Command("go", append(args, "-ldflags", ldflags, bin.MainDir)...) cmd.Env = cmdEnv diff --git a/internal/operator/orbiter/kinds/clusters/kubernetes/machines.go b/internal/operator/orbiter/kinds/clusters/kubernetes/machines.go index 5e6ad6eae..eb59d424b 100644 --- a/internal/operator/orbiter/kinds/clusters/kubernetes/machines.go +++ b/internal/operator/orbiter/kinds/clusters/kubernetes/machines.go @@ -24,7 +24,8 @@ func alignMachines( }).Debug("Ensuring scale") var machines []*initializedMachine - upscalingDone := true + + upscalingUndone := make(chan bool) var ( wg sync.WaitGroup err error @@ -33,7 +34,7 @@ func alignMachines( defer wg.Done() if pool.upscaling > 0 { - upscalingDone = false + upscalingUndone <- true machines, alignErr := newMachines(pool.infra, pool.upscaling, pool.desired.Nodes) if alignErr != nil { err = helpers.Concat(err, alignErr) @@ -62,7 +63,21 @@ func alignMachines( wg.Add(1) go alignPool(workerPool) } + + upscalingDone := true + go func() { + for { + select { + case undone := <-upscalingUndone: + if upscalingDone { + upscalingDone = undone + } + } + } + }() + wg.Wait() + close(upscalingUndone) if err != nil { return false, machines, err } diff --git a/internal/operator/orbiter/kinds/providers/core/nodeagent.go b/internal/operator/orbiter/kinds/providers/core/nodeagent.go index 41d48485c..5d9ffb4d7 100644 --- a/internal/operator/orbiter/kinds/providers/core/nodeagent.go +++ b/internal/operator/orbiter/kinds/providers/core/nodeagent.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "strings" + "sync" "time" "github.com/caos/orbos/internal/executables" @@ -96,11 +97,11 @@ func NodeAgentFuncs( systemdEntry := "node-agentd" systemdPath := fmt.Sprintf("/lib/systemd/system/%s.service", systemdEntry) - systemdUnitCache := make(map[string]string) + systemdUnitCache := sync.Map{} systemdUnitFile := func(machine infra.Machine) string { - if cached, ok := systemdUnitCache[machine.ID()]; ok { - return cached + if cached, ok := systemdUnitCache.Load(machine.ID()); ok { + return cached.(string) } newFile := fmt.Sprintf(`[Unit] @@ -122,7 +123,7 @@ KillMode=mixed [Install] WantedBy=multi-user.target `, binary, machine.ID(), pprofStr, verboseStr, sentryEnvironment) - systemdUnitCache[machine.ID()] = newFile + systemdUnitCache.Store(machine.ID(), newFile) return newFile }