Skip to content

Commit

Permalink
fix panics in manager
Browse files Browse the repository at this point in the history
  • Loading branch information
barrettj12 committed Jul 6, 2023
1 parent 24ca2c1 commit 9b1d45e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions internals/overlord/logstate/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ func (c *bufferingClient) Flush() error {
for _, entry := range c.entries {
fmt.Printf("%v [%s] %s", entry.Time, entry.Service, entry.Message)
}
fmt.Println()
c.entries = c.entries[:0]
return nil
}
16 changes: 13 additions & 3 deletions internals/overlord/logstate/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func NewLogManager() *LogManager {
return &LogManager{
gatherers: map[string]*logGatherer{},
newGatherer: newLogGatherer,
buffers: map[string]*servicelog.RingBuffer{},
}
}

Expand Down Expand Up @@ -78,8 +79,10 @@ func (m *LogManager) PlanChanged(pl *plan.Plan) {
buffer, ok := m.buffers[service.Name]
if ok {
iterator = buffer.TailIterator()
parser := servicelog.NewParser(iterator, parserSize)
iterator.Notify(gatherer.notifyChan)
newIterators[service.Name] = iterator

parser := servicelog.NewParser(iterator, parserSize)
newParsers[service.Name] = parser
}
} else {
Expand Down Expand Up @@ -110,11 +113,18 @@ func (m *LogManager) ServiceStarted(service *plan.Service, buffer *servicelog.Ri
m.buffers[service.Name] = buffer
for _, target := range m.plan.LogTargets {
if service.LogsTo(target) {
gatherer := m.gatherers[service.Name]
gatherer := m.gatherers[target.Name]
if gatherer == nil {
logger.Noticef("Internal error: couldn't find gatherer for target %q", target.Name)
continue
}

gatherer.itLock.Lock()
iterator := buffer.TailIterator()
parser := servicelog.NewParser(iterator, parserSize)
iterator.Notify(gatherer.notifyChan)
gatherer.iterators[service.Name] = iterator

parser := servicelog.NewParser(iterator, parserSize)
gatherer.parsers[service.Name] = parser
gatherer.itLock.Unlock()
}
Expand Down

0 comments on commit 9b1d45e

Please sign in to comment.