Skip to content

Commit f80f3e0

Browse files
committed
Generate status generation logs from custom plugin run only on condition change.
1 parent 061e977 commit f80f3e0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pkg/custompluginmonitor/custom_plugin_monitor.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (c *customPluginMonitor) monitorLoop() {
135135
}
136136
glog.V(3).Infof("Receive new plugin result for %s: %+v", c.configPath, result)
137137
status := c.generateStatus(result)
138-
glog.Infof("New status generated: %+v", status)
138+
glog.V(3).Infof("New status generated: %+v", status)
139139
c.statusChan <- status
140140
case <-c.tomb.Stopping():
141141
c.plugin.Stop()
@@ -263,12 +263,17 @@ func (c *customPluginMonitor) generateStatus(result cpmtypes.Result) *types.Stat
263263
}
264264
}
265265
}
266-
return &types.Status{
266+
status := &types.Status{
267267
Source: c.config.Source,
268268
// TODO(random-liu): Aggregate events and conditions and then do periodically report.
269269
Events: append(activeProblemEvents, inactiveProblemEvents...),
270270
Conditions: c.conditions,
271271
}
272+
// Log only if condition has changed
273+
if len(activeProblemEvents) != 0 || len(inactiveProblemEvents) != 0 {
274+
glog.Infof("New status generated: %+v", status)
275+
}
276+
return status
272277
}
273278

274279
func toConditionStatus(s cpmtypes.Status) types.ConditionStatus {

pkg/custompluginmonitor/plugin/plugin.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ func (p *Plugin) runRules() {
107107

108108
p.resultChan <- result
109109

110-
glog.Infof("Add check result %+v for rule %+v", result, rule)
110+
// Let the result be logged at a higher verbosity level. If there is a change in status it is logged later.
111+
glog.V(3).Infof("Add check result %+v for rule %+v", result, rule)
112+
glog.Infof("Ran rule %+v", rule)
111113
}(rule)
112114
}
113115

0 commit comments

Comments
 (0)