Merge pull request #100915 from lojies/timesince

Replace time.Now().Sub(x) with time.Since(x)
This commit is contained in:
Kubernetes Prow Robot 2021-04-10 19:05:02 -07:00 committed by GitHub
commit d402cfa1ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -716,7 +716,7 @@ func nodeReadyConditionStatus(node *v1.Node) v1.ConditionStatus {
func (s *Controller) nodeSyncInternal(workers int) {
startTime := time.Now()
defer func() {
latency := time.Now().Sub(startTime).Seconds()
latency := time.Since(startTime).Seconds()
klog.V(4).Infof("It took %v seconds to finish nodeSyncInternal", latency)
nodeSyncLatency.Observe(latency)
}()
@ -785,7 +785,7 @@ func (s *Controller) updateLoadBalancerHosts(services []*v1.Service, workers int
func (s *Controller) lockedUpdateLoadBalancerHosts(service *v1.Service, hosts []*v1.Node) error {
startTime := time.Now()
defer func() {
latency := time.Now().Sub(startTime).Seconds()
latency := time.Since(startTime).Seconds()
klog.V(4).Infof("It took %v seconds to update load balancer hosts for service %s/%s", latency, service.Namespace, service.Name)
updateLoadBalancerHostLatency.Observe(latency)
}()