MCPcopy
hub / github.com/kubernetes/node-problem-detector / execCommand

Function execCommand

pkg/healthchecker/health_checker.go:188–199  ·  view source on GitHub ↗

execCommand executes the bash command and returns the (output, error) from command, error if timeout occurs.

(timeout time.Duration, command string, args ...string)

Source from the content-addressed store, hash-verified

186
187// execCommand executes the bash command and returns the (output, error) from command, error if timeout occurs.
188func execCommand(timeout time.Duration, command string, args ...string) (string, error) {
189 ctx, cancel := context.WithTimeout(context.Background(), timeout)
190 defer cancel()
191 cmd := exec.CommandContext(ctx, command, args...)
192 out, err := cmd.CombinedOutput()
193 if err != nil {
194 klog.Infof("command %v failed: %v, %s\n", cmd, err, string(out))
195 return "", err
196 }
197
198 return strings.TrimSuffix(string(out), "\n"), nil
199}

Callers 4

getHealthCheckFuncFunction · 0.85
getUptimeFuncFunction · 0.85
getRepairFuncFunction · 0.85
checkForPatternFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected