Skip to content

Commit 7dc84e8

Browse files
authored
Merge pull request #395 from yuzhiquan/patch
Using time.Since(t) instead of t.Sub(time.Now())
2 parents 11e3509 + 9c24be2 commit 7dc84e8

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

pkg/custompluginmonitor/plugin/plugin.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ func (p *Plugin) runRules() {
9696

9797
start := time.Now()
9898
exitStatus, message := p.run(*rule)
99-
end := time.Now()
10099

101-
glog.V(3).Infof("Rule: %+v. Start time: %v. End time: %v. Duration: %v", rule, start, end, end.Sub(start))
100+
glog.V(3).Infof("Rule: %+v. Start time: %v. End time: %v. Duration: %v", rule, start, time.Now(), time.Since(start))
102101

103102
result := cpmtypes.Result{
104103
Rule: rule,

pkg/exporters/k8sexporter/condition/manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ func (c *conditionManager) needUpdates() bool {
141141
// needResync checks whether a resync is needed.
142142
func (c *conditionManager) needResync() bool {
143143
// Only update when resync is needed.
144-
return c.clock.Now().Sub(c.latestTry) >= resyncPeriod && c.resyncNeeded
144+
return c.clock.Since(c.latestTry) >= resyncPeriod && c.resyncNeeded
145145
}
146146

147147
// needHeartbeat checks whether a forcible heartbeat is needed.
148148
func (c *conditionManager) needHeartbeat() bool {
149-
return c.clock.Now().Sub(c.latestTry) >= c.heartbeatPeriod
149+
return c.clock.Since(c.latestTry) >= c.heartbeatPeriod
150150
}
151151

152152
// sync synchronizes node conditions with the apiserver.

0 commit comments

Comments
 (0)