Replace 'x.Sub(time.Now())' with 'time.Until(x)'

This commit is contained in:
tanjing2020 2021-07-23 10:03:36 +08:00
parent 8ac0fcdb74
commit 523b4c0918
2 changed files with 2 additions and 2 deletions

View File

@ -892,7 +892,7 @@ func buildKubeletClientConfig(ctx context.Context, s *options.KubeletServer, nod
},
func() float64 {
if c := clientCertificateManager.Current(); c != nil && c.Leaf != nil {
return math.Trunc(c.Leaf.NotAfter.Sub(time.Now()).Seconds())
return math.Trunc(time.Until(c.Leaf.NotAfter).Seconds())
}
return math.Inf(1)
},

View File

@ -141,7 +141,7 @@ func NewKubeletServerCertificateManager(kubeClient clientset.Interface, kubeCfg
},
func() float64 {
if c := m.Current(); c != nil && c.Leaf != nil {
return math.Trunc(c.Leaf.NotAfter.Sub(time.Now()).Seconds())
return math.Trunc(time.Until(c.Leaf.NotAfter).Seconds())
}
return math.Inf(1)
},