refactor: move host command execution to runtime

This commit is contained in:
joshsiv-mulga
2026-10-02 11:04:30 +10:00
parent 239b19f8f3
commit e2ac3dbed2
4 changed files with 11 additions and 11 deletions
+3 -2
View File
@@ -31,8 +31,8 @@ import (
"github.com/mulgadc/bluebottle/pkg/safecast"
"github.com/mulgadc/spinifex/spinifex/admin"
"github.com/mulgadc/spinifex/spinifex/bootstrap/config"
"github.com/mulgadc/spinifex/spinifex/foundation/state/clustersize"
"github.com/mulgadc/spinifex/spinifex/domains/ec2/ebs/metadata"
"github.com/mulgadc/spinifex/spinifex/foundation/state/clustersize"
handlers_ec2_vpc "github.com/mulgadc/spinifex/spinifex/handlers/ec2/vpc"
handlers_iam "github.com/mulgadc/spinifex/spinifex/handlers/iam"
"github.com/mulgadc/spinifex/spinifex/network/host"
@@ -40,6 +40,7 @@ import (
"github.com/mulgadc/spinifex/spinifex/providers/objectstore"
"github.com/mulgadc/spinifex/spinifex/runtime/compute/gpu"
"github.com/mulgadc/spinifex/spinifex/runtime/formation"
hostcommand "github.com/mulgadc/spinifex/spinifex/runtime/host/command"
"github.com/mulgadc/spinifex/spinifex/runtime/host/dns"
"github.com/mulgadc/spinifex/spinifex/services/viperblockd/vbwire"
"github.com/mulgadc/spinifex/spinifex/utils"
@@ -3533,7 +3534,7 @@ type dnsDetectionSources struct {
func detectDNSServers(iface string, excludedIPs ...string) []string {
return detectDNSServersWithSources(iface, excludedIPs, dnsDetectionSources{
queryResolvectl: func(args ...string) (string, error) {
return utils.RunCommandWithTimeout(dnsDetectionCommandTimeout, "resolvectl", args...)
return hostcommand.RunCommandWithTimeout(dnsDetectionCommandTimeout, "resolvectl", args...)
},
readResolvConf: func() (string, error) {
data, err := os.ReadFile("/etc/resolv.conf")
@@ -1,4 +1,5 @@
package utils
// Package command runs bounded host commands for node-local runtime work.
package command
import (
"bytes"
@@ -1,4 +1,4 @@
package utils
package command
import (
"context"
@@ -77,8 +77,6 @@ func childPIDFromOutput(t *testing.T, output string) int {
return 0
}
// processExitsWithin polls until pid is gone. One not-running observation is
// final: a re-check can catch a reaped task's brief "X" state and misreport it.
func processExitsWithin(pid int, timeout time.Duration) bool {
deadline := time.Now().Add(timeout)
for processRunning(pid) {
+5 -5
View File
@@ -24,7 +24,7 @@ import (
"strings"
"time"
"github.com/mulgadc/spinifex/spinifex/utils"
hostcommand "github.com/mulgadc/spinifex/spinifex/runtime/host/command"
)
// Host paths the resolver managers read. Joined onto configurator.root, which is
@@ -97,7 +97,7 @@ type configurator struct {
func newConfigurator() *configurator {
return &configurator{
resolvedActive: func() bool {
_, err := utils.RunCommandWithTimeout(resolverCommandTimeout, "systemctl", "is-active", "--quiet", "systemd-resolved")
_, err := hostcommand.RunCommandWithTimeout(resolverCommandTimeout, "systemctl", "is-active", "--quiet", "systemd-resolved")
return err == nil
},
hasResolvconf: func() bool {
@@ -105,15 +105,15 @@ func newConfigurator() *configurator {
return err == nil
},
restartResolved: func() error {
_, err := utils.RunCommandWithTimeout(resolverCommandTimeout, "systemctl", "restart", "systemd-resolved")
_, err := hostcommand.RunCommandWithTimeout(resolverCommandTimeout, "systemctl", "restart", "systemd-resolved")
return err
},
updateResolvconf: func() error {
_, err := utils.RunCommandWithTimeout(resolverCommandTimeout, "resolvconf", "-u")
_, err := hostcommand.RunCommandWithTimeout(resolverCommandTimeout, "resolvconf", "-u")
return err
},
resolvedStatus: func() (string, error) {
return utils.RunCommandWithTimeout(resolverCommandTimeout, "resolvectl", "status")
return hostcommand.RunCommandWithTimeout(resolverCommandTimeout, "resolvectl", "status")
},
}
}