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

Return the current agent state on Fixture.IsHealthy method #3982

Merged
merged 11 commits into from
Jan 8, 2024

Conversation

AndersonQ
Copy link
Member

What does this PR do?

Modifies Fixture.IsHealthy to return the current agent status if the agent isn't healthy.

Why is it important?

When debugging a failing test it's valuable to know the current status of the agent.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added an entry in ./changelog/fragments using the changelog tool
  • [ ] I have added an integration test or an E2E test

Related issues

  • N/A

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

@AndersonQ AndersonQ added enhancement New feature or request Team:Elastic-Agent Label for the Agent team skip-changelog Testing backport-v8.12.0 Automated backport with mergify labels Jan 2, 2024
@AndersonQ AndersonQ self-assigned this Jan 2, 2024
@AndersonQ AndersonQ requested a review from a team as a code owner January 2, 2024 15:35
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

return status.State == int(cproto.State_HEALTHY), nil
if status.State != int(cproto.State_HEALTHY) {
return false, fmt.Errorf("agent isn't health, current status: %s",
client.State(status.State))
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand the reason for adding this, but this kinda changes the meaning of the error in this function. The error was more that it failed to get the actual health. Now this changes it to return an error when its not healthy, that is probably not was the caller is expecting.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is true, but it's also why I changed it docs. Besides there is just one usage of it, that is the test which needed this change. I could change the function signature, but I believe the doc change clarifies what is returned in the error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the way your changing it, would you be willing to change it to EnsureHealthy and remove the boolean? Doesn't seem like true/false is relevant to what this function is even doing at more, so just have it return error or nil.

Copy link
Member Author

Choose a reason for hiding this comment

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

It does make sense, I just kept the name because it isn't ensuring anything, just checking the status

@AndersonQ AndersonQ requested a review from blakerouse January 2, 2024 16:58
Copy link

Quality Gate passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No Coverage information No data about Coverage
0.0% 0.0% Duplication on New Code

See analysis details on SonarQube

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

+1

@AndersonQ AndersonQ merged commit 58ef76d into elastic:main Jan 8, 2024
4 of 7 checks passed
mergify bot pushed a commit that referenced this pull request Jan 8, 2024
AndersonQ added a commit that referenced this pull request Jan 9, 2024
…4040)

(cherry picked from commit 58ef76d)

Co-authored-by: Anderson Queiroz <anderson.queiroz@elastic.co>
cmacknz pushed a commit that referenced this pull request Jan 17, 2024
…4040)

(cherry picked from commit 58ef76d)

Co-authored-by: Anderson Queiroz <anderson.queiroz@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.12.0 Automated backport with mergify enhancement New feature or request skip-changelog Team:Elastic-Agent Label for the Agent team Testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants