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

Avoid data race by calling forceCompState only on commandRuntime.Run #3537

Merged
merged 2 commits into from
Oct 6, 2023

Conversation

AndersonQ
Copy link
Member

@AndersonQ AndersonQ commented Oct 5, 2023

What does this PR do?

Instead of using the component state to show the error, log it using the component stderr logger

Why is it important?

If forceCompState is called outside (*commandRuntime).Run it creates a data race.

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

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 bug Something isn't working Team:Elastic-Agent Label for the Agent team v8.12.0 backport-v8.11.0 Automated backport with mergify labels Oct 5, 2023
@AndersonQ AndersonQ requested a review from a team as a code owner October 5, 2023 14:29
@AndersonQ AndersonQ self-assigned this Oct 5, 2023
@AndersonQ AndersonQ requested review from blakerouse and faec October 5, 2023 14:29
@elasticmachine
Copy link
Contributor

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

Instead of using the component state to show the error, log it using the component stderr logger
@AndersonQ AndersonQ force-pushed the 3512-commandruntime-data-race branch 2 times, most recently from 8e330cb to 7a08cb1 Compare October 5, 2023 14:36
@elasticmachine
Copy link
Contributor

elasticmachine commented Oct 5, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-10-06T10:09:19.092+0000

  • Duration: 29 min 4 sec

Test stats 🧪

Test Results
Failed 0
Passed 6485
Skipped 59
Total 6544

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages.

  • run integration tests : Run the Elastic Agent Integration tests.

  • run end-to-end tests : Generate the packages and run the E2E Tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

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.

Looks good.

kind: bug

# Change summary; a 80ish characters long description of the change.
summary: Avoid possible data race when diring a component start the Elastic Agent fails to write to the component's stdin
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a changelog entry? Has this actually ever effected a user in a meaningful way?

@elasticmachine
Copy link
Contributor

elasticmachine commented Oct 5, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 98.78% (81/82) 👍
Files 67.003% (199/297) 👍
Classes 65.642% (363/553) 👍
Methods 52.976% (1148/2167) 👍
Lines 38.552% (13117/34024) 👎 -0.003
Conditionals 100.0% (0/0) 💚

@AndersonQ
Copy link
Member Author

buildkite test this

1 similar comment
@jlind23
Copy link
Contributor

jlind23 commented Oct 6, 2023

buildkite test this

@AndersonQ AndersonQ enabled auto-merge (squash) October 6, 2023 10:10
@AndersonQ AndersonQ disabled auto-merge October 6, 2023 10:10
@AndersonQ AndersonQ enabled auto-merge (squash) October 6, 2023 10:12
@elastic-sonarqube
Copy link

@AndersonQ AndersonQ merged commit 39f324f into elastic:main Oct 6, 2023
11 checks passed
mergify bot pushed a commit that referenced this pull request Oct 6, 2023
…ime.Run (#3537)

Instead of startWatcher setting the component state on comm.WriteConnInfo failure, now it logs the error using the component stderr logger.

(cherry picked from commit 39f324f)
AndersonQ added a commit that referenced this pull request Oct 6, 2023
…ime.Run (#3537) (#3555)

Instead of startWatcher setting the component state on comm.WriteConnInfo failure, now it logs the error using the component stderr logger.

(cherry picked from commit 39f324f)

Co-authored-by: Anderson Queiroz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.11.0 Automated backport with mergify bug Something isn't working skip-changelog Team:Elastic-Agent Label for the Agent team v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible data race when commandRuntime fails to write connection information
4 participants