Change time.Now().Sub(x) to time.Since(x) for cleanup

Kubernetes-commit: 878548ceac9c109881c379911b8b0d8fce5ea68e
This commit is contained in:
c00522440
2021-04-12 10:27:54 +08:00
committed by Kubernetes Publisher
parent 47b3cad4de
commit ca138c86e8
3 changed files with 3 additions and 3 deletions

View File

@@ -461,7 +461,7 @@ func (a *Authenticator) refreshCredsLocked(r *clientauthentication.Response) err
if oldCreds != nil && !reflect.DeepEqual(oldCreds.cert, a.cachedCreds.cert) {
// Can be nil if the exec auth plugin only returned token auth.
if oldCreds.cert != nil && oldCreds.cert.Leaf != nil {
metrics.ClientCertRotationAge.Observe(time.Now().Sub(oldCreds.cert.Leaf.NotBefore))
metrics.ClientCertRotationAge.Observe(time.Since(oldCreds.cert.Leaf.NotBefore))
}
a.connTracker.CloseAll()
}