Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First call of autodetect should be synchronous #1713

Merged
merged 2 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions pkg/autodetect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,12 @@ func WithClients(cl client.Client, dcl discovery.DiscoveryInterface, clr client.
func (b *Background) Start() {
// periodically attempts to auto detect all the capabilities for this operator
b.ticker = time.NewTicker(5 * time.Second)

done := make(chan bool)
go func() {
b.autoDetectCapabilities()
done <- true
}()
b.autoDetectCapabilities()
log.Trace("finished the first auto-detection")

go func() {
for {
select {
case <-done:
log.Trace("finished the first auto-detection")
case <-b.ticker.C:
b.autoDetectCapabilities()
}
Expand Down
11 changes: 6 additions & 5 deletions pkg/cmd/start/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ func bootstrap(ctx context.Context) manager.Manager {

mgr := createManager(ctx, cfg)

if d, err := autodetect.New(mgr); err != nil {
log.WithError(err).Warn("failed to start the background process to auto-detect the operator capabilities")
} else {
d.Start()
}

detectNamespacePermissions(ctx, mgr)
performUpgrades(ctx, mgr)
setupControllers(ctx, mgr)
Expand All @@ -113,11 +119,6 @@ func bootstrap(ctx context.Context) manager.Manager {
if err != nil {
log.WithError(err).Error("failed to initialize metrics")
}
if d, err := autodetect.New(mgr); err != nil {
log.WithError(err).Warn("failed to start the background process to auto-detect the operator capabilities")
} else {
d.Start()
}
return mgr
}

Expand Down