mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-04 08:35:10 +00:00
client-go exec: fix metrics related to plugin not found
These were missed because our tests did not pass in the correct test data input (the command to execute). Signed-off-by: Monis Khan <mok@vmware.com> Kubernetes-commit: a6ac42082b4d7c0057b52900736bd7fbc2c44241
This commit is contained in:
committed by
Kubernetes Publisher
parent
7a90b08589
commit
ef1d5d2691
@@ -18,6 +18,7 @@ package exec
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/fs"
|
||||
"os/exec"
|
||||
"reflect"
|
||||
"sync"
|
||||
@@ -92,6 +93,7 @@ func (c *certificateExpirationTracker) set(a *Authenticator, t time.Time) {
|
||||
func incrementCallsMetric(err error) {
|
||||
execExitError := &exec.ExitError{}
|
||||
execError := &exec.Error{}
|
||||
pathError := &fs.PathError{}
|
||||
switch {
|
||||
case err == nil: // Binary execution succeeded.
|
||||
metrics.ExecPluginCalls.Increment(successExitCode, noError)
|
||||
@@ -99,7 +101,7 @@ func incrementCallsMetric(err error) {
|
||||
case errors.As(err, &execExitError): // Binary execution failed (see "os/exec".Cmd.Run()).
|
||||
metrics.ExecPluginCalls.Increment(execExitError.ExitCode(), pluginExecutionError)
|
||||
|
||||
case errors.As(err, &execError): // Binary does not exist (see exec.Error).
|
||||
case errors.As(err, &execError), errors.As(err, &pathError): // Binary does not exist (see exec.Error, fs.PathError).
|
||||
metrics.ExecPluginCalls.Increment(failureExitCode, pluginNotFoundError)
|
||||
|
||||
default: // We don't know about this error type.
|
||||
|
Reference in New Issue
Block a user