Skip to content

Commit

Permalink
Merge pull request #63 from SOF3/monitor-blocking
Browse files Browse the repository at this point in the history
fix(generator): MonitorWorkload should be called in the background
  • Loading branch information
SOF3 authored Jan 7, 2025
2 parents f836099 + 5fae79a commit 3003b28
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions generator/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,18 @@ var New = component.Declare[Args, Options, Deps, State, util.Empty](
component.Lifecycle[Args, Options, Deps, State]{
Start: func(ctx context.Context, _ *Args, options *Options, deps *Deps, state *State) error {
if *options.Enable {
deps.observer.Get().MonitorWorkloads(ctx, util.Empty{}, func() observer.MonitorWorkloads {
state.statusMu.Lock()
defer state.statusMu.Unlock()
go func() {
deps.podseidonInformers.Get().WaitForCacheSync(ctx.Done())

return state.status
})
if ctx.Err() == nil {
deps.observer.Get().MonitorWorkloads(ctx, util.Empty{}, func() observer.MonitorWorkloads {
state.statusMu.Lock()
defer state.statusMu.Unlock()

return state.status
})
}
}()
}

return nil
Expand Down

0 comments on commit 3003b28

Please sign in to comment.