Skip to content

Commit

Permalink
Destroy event history collectors
Browse files Browse the repository at this point in the history
The EventHistoryCollector objects are tied to a session and there is a max per-session.
Without destroying the collectors, we could max out the collectors causing 'govc events' to return empty.

Fixes #948
Fixes #961
  • Loading branch information
dougm committed Dec 13, 2017
1 parent cabbd96 commit 4fb5034
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions event/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,7 @@ func (m Manager) Events(ctx context.Context, objects []types.ManagedObjectRefere
proc.addObject(ctx, o)
}

defer proc.destroy()

return proc.run(ctx, tail)
}
12 changes: 9 additions & 3 deletions event/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
type tailInfo struct {
t *eventTailer
obj types.ManagedObjectReference
collector types.ManagedObjectReference
collector *HistoryCollector
}

type eventProcessor struct {
Expand Down Expand Up @@ -68,20 +68,26 @@ func (p *eventProcessor) addObject(ctx context.Context, obj types.ManagedObjectR
p.tailers[collector.Reference()] = &tailInfo{
t: newEventTailer(),
obj: obj,
collector: collector.Reference(),
collector: collector,
}

return nil
}

func (p *eventProcessor) destroy() {
for _, info := range p.tailers {
_ = info.collector.Destroy(context.Background())
}
}

func (p *eventProcessor) run(ctx context.Context, tail bool) error {
if len(p.tailers) == 0 {
return nil
}

var collectors []types.ManagedObjectReference
for _, t := range p.tailers {
collectors = append(collectors, t.collector)
collectors = append(collectors, t.collector.Reference())
}

c := property.DefaultCollector(p.mgr.Client())
Expand Down

0 comments on commit 4fb5034

Please sign in to comment.