mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 22:20:51 +00:00
Fix time.Since() in defer. Wrap in anonymous function
Function arguments in defer evaluated during definition of defer, not during execution
This commit is contained in:
@@ -435,7 +435,9 @@ func (e *execPlugin) ExecPlugin(ctx context.Context, image string) (*credentialp
|
||||
|
||||
func (e *execPlugin) runPlugin(ctx context.Context, cmd *exec.Cmd, image string) error {
|
||||
startTime := time.Now()
|
||||
defer kubeletCredentialProviderPluginDuration.WithLabelValues(e.name).Observe(time.Since(startTime).Seconds())
|
||||
defer func() {
|
||||
kubeletCredentialProviderPluginDuration.WithLabelValues(e.name).Observe(time.Since(startTime).Seconds())
|
||||
}()
|
||||
|
||||
err := cmd.Run()
|
||||
if ctx.Err() != nil {
|
||||
|
Reference in New Issue
Block a user