Skip to content

Commit d4ebae5

Browse files
Merge pull request openshift#7492 from kevydotvinu/ocpbugs-19086
OCPBUGS-19086: Check if nmstatectl executable exists in the system
2 parents 17379ae + 1d044aa commit d4ebae5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/asset/agent/manifests/staticnetworkconfig/generator.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,14 @@ func (s *staticNetworkConfigGenerator) executeNMStatectl(ctx context.Context, ho
123123
s.log.WithError(err).Warn("Failed to close file")
124124
}
125125

126+
// Check if nmstatectl executable exists in the system
127+
nmstatectlPath, err := exec.LookPath("nmstatectl")
128+
if err != nil {
129+
return "", fmt.Errorf("install nmstate package, %w", err)
130+
}
131+
126132
var stdoutBytes, stderrBytes bytes.Buffer
127-
cmd := exec.CommandContext(ctx, "nmstatectl", "gc", f.Name()) //nolint:gosec
133+
cmd := exec.CommandContext(ctx, nmstatectlPath, "gc", f.Name()) //nolint:gosec
128134
cmd.Stdout = &stdoutBytes
129135
cmd.Stderr = &stderrBytes
130136

0 commit comments

Comments
 (0)