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

Improve crash on failed agent initialization #326

Merged
merged 3 commits into from
Mar 6, 2024
Merged

Conversation

rtorrero
Copy link
Contributor

@rtorrero rtorrero commented Mar 5, 2024

This PR:

  • Ensures that the agent doesn't start the discovery loop until the subscription to the facts engine is working

We achieve this by:

  • moving the facts service connection to the start of the agent Start()
  • taking the subscription to the facts service out of the Go routine to block the execution of the Start() until it is resolved. The listen part is the blocking part, so that needs to stay in the Go routine

NOTE: I also explored what would happen on wrong configuration files, e.g. following the example of the slack conversation from TRNT-2814, I removed facts-service-url and this seems that was already causing the agent to crash without a heartbeat nor discovery loops starting

(Addresses TRNT-2814)

@rtorrero rtorrero added enhancement New feature or request go Pull requests that update Go code labels Mar 5, 2024
@rtorrero rtorrero marked this pull request as ready for review March 5, 2024 14:52
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rtorrero The code looks ok.
Can we add a test for the failed scenario?

internal/agent/agent.go Show resolved Hide resolved
return err
}
g.Go(func() error {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this 86 empty line?
And maybe put a new line before g.Go

@rtorrero rtorrero merged commit 1564aea into main Mar 6, 2024
10 checks passed
@rtorrero rtorrero deleted the pre-discovery-checks branch March 6, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go Pull requests that update Go code
Development

Successfully merging this pull request may close these issues.

2 participants