Merge pull request #441 from abansal4032/custom-plugin-log-fix

Generate new status log only on condition change
This commit is contained in:
Kubernetes Prow Robot
2020-07-28 09:45:48 -07:00
committed by GitHub
2 changed files with 10 additions and 3 deletions

View File

@@ -135,7 +135,7 @@ func (c *customPluginMonitor) monitorLoop() {
}
glog.V(3).Infof("Receive new plugin result for %s: %+v", c.configPath, result)
status := c.generateStatus(result)
glog.Infof("New status generated: %+v", status)
glog.V(3).Infof("New status generated: %+v", status)
c.statusChan <- status
case <-c.tomb.Stopping():
c.plugin.Stop()
@@ -263,12 +263,17 @@ func (c *customPluginMonitor) generateStatus(result cpmtypes.Result) *types.Stat
}
}
}
return &types.Status{
status := &types.Status{
Source: c.config.Source,
// TODO(random-liu): Aggregate events and conditions and then do periodically report.
Events: append(activeProblemEvents, inactiveProblemEvents...),
Conditions: c.conditions,
}
// Log only if condition has changed
if len(activeProblemEvents) != 0 || len(inactiveProblemEvents) != 0 {
glog.Infof("New status generated: %+v", status)
}
return status
}
func toConditionStatus(s cpmtypes.Status) types.ConditionStatus {

View File

@@ -107,7 +107,9 @@ func (p *Plugin) runRules() {
p.resultChan <- result
glog.Infof("Add check result %+v for rule %+v", result, rule)
// Let the result be logged at a higher verbosity level. If there is a change in status it is logged later.
glog.V(3).Infof("Add check result %+v for rule %+v", result, rule)
glog.Infof("Ran rule %+v", rule)
}(rule)
}