Skip to content

Commit

Permalink
Merge pull request #719 from rancher/fix-1106
Browse files Browse the repository at this point in the history
Tidy up logging plugin conditions and shutdown
  • Loading branch information
dbason authored Oct 26, 2022
2 parents 5a60610 + 6e738ae commit 1e7a1e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/logging/pkg/agent/drivers/events/event_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func NewEventCollector(
return &EventCollector{
EventCollectorOptions: options,
clientset: clientset,
queue: workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()),
informer: informer,
logger: logger,
namespace: namespace,
Expand All @@ -133,6 +132,7 @@ func (c *EventCollector) ConfigureNode(config *node.LoggingCapabilityConfig) {
return
}
c.state.stopCh = make(chan struct{})
c.queue = workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter())
go func() {
err := c.run(c.state.stopCh)
if err != nil {
Expand All @@ -149,6 +149,7 @@ func (c *EventCollector) ConfigureNode(config *node.LoggingCapabilityConfig) {

if c.state.running {
close(c.state.stopCh)
c.queue.ShutDown()
c.state.running = false
}

Expand Down Expand Up @@ -207,6 +208,7 @@ func (c *EventCollector) enqueueEvent(obj interface{}) {
func (c *EventCollector) processNextItem() bool {
event, shutdown := c.queue.Get()
if shutdown {
c.logger.Info("queue shutdown, halting event shipping")
return false
}
defer c.queue.Done(event)
Expand Down
6 changes: 6 additions & 0 deletions plugins/logging/pkg/agent/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ func (m *LoggingNode) updateConfig(config *node.LoggingCapabilityConfig) {

m.config = config

if !m.config.Enabled && len(m.config.Conditions) > 0 {
m.conditions.Set(health.CondBackend, health.StatusDisabled, strings.Join(m.config.Conditions, ", "))
} else {
m.conditions.Clear(health.CondBackend)
}

for _, ch := range m.listeners {
clone := util.ProtoClone(config)
select {
Expand Down

0 comments on commit 1e7a1e0

Please sign in to comment.