Skip to content

Commit

Permalink
fix: start plugins in parallel (#787)
Browse files Browse the repository at this point in the history
# Description

Plugins should be started as soon as possible, arbitrary delay based off
number of enabled plugins isn't helpful to getting metrics delayed from
retina start.

## Related Issue

If this pull request is related to any issue, please mention it here.
Additionally, make sure that the issue is assigned to you before
submitting this pull request.

## Checklist

- [ ] I have read the [contributing
documentation](https://retina.sh/docs/contributing).
- [ ] I signed and signed-off the commits (`git commit -S -s ...`). See
[this
documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
on signing commits.
- [ ] I have correctly attributed the author(s) of the code.
- [ ] I have tested the changes locally.
- [ ] I have followed the project's style guidelines.
- [ ] I have updated the documentation, if necessary.
- [ ] I have added tests, if applicable.

## Screenshots (if applicable) or Testing Completed

Please add any relevant screenshots or GIFs to showcase the changes
made.

## Additional Notes

Add any additional notes or context about the pull request here.

---

Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more
information on how to contribute to this project.
  • Loading branch information
matmerr authored Sep 30, 2024
1 parent a1a9825 commit da2acaa
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions pkg/managers/pluginmanager/pluginmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ const (
MAX_RECONCILE_TIME = 10 * time.Second
)

const (
MAX_STARTUP_TIME = 10 * time.Second
)

var (
ErrNilCfg = errors.New("pluginmanager requires a non-nil config")
ErrZeroInterval = errors.New("pluginmanager requires a positive MetricsInterval in its config")
Expand Down Expand Up @@ -128,14 +124,6 @@ func (p *PluginManager) Reconcile(ctx context.Context, plugin api.Plugin) error
// Note: This will block as long as main thread is running.
func (p *PluginManager) Start(ctx context.Context) error {
counter := p.tel.StartPerf("start-plugin-manager")
// start plugins evenly throughout the interval,
// if 2 plugins enabled, and 10 second interval
// 10 / 2 = 5, then after every start sleep 5s
// plugin 1 = 0s
// plugin 2 = 5s
// then the plugins won't awake at the same time and they'll have even execution time

delay := float32(MAX_STARTUP_TIME) / float32(len(p.plugins))
p.l.Info("Starting plugin manager ...")
var err error

Expand Down Expand Up @@ -184,8 +172,6 @@ func (p *PluginManager) Start(ctx context.Context) error {
p.l.Info(fmt.Sprintf("starting plugin %s", plug.Name()))
return errors.Wrapf(plug.Start(ctx), "failed to start plugin %s", plug.Name())
})

time.Sleep(time.Duration(delay))
}

p.tel.StopPerf(counter)
Expand Down

0 comments on commit da2acaa

Please sign in to comment.