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

Fall back to os.Get[ug]id if user.Current() fails #28696

Merged
merged 1 commit into from
Oct 29, 2021

Conversation

david-kow
Copy link
Contributor

@david-kow david-kow commented Oct 28, 2021

What does this PR do?

In the case of user.Current() call failing with user.UnknownUserIdError we fallback to os.Getuid() and os.Getgid() to populate uid and gid values respectively.

Why is it important?

#28265 added populating username, uid and gid for diagnostic purposes. This information is taken from password database (eg. /etc/passwd file) based on uid. Unfortunately, in some cases an entry for current uid is not present there. This is the case in Kubernetes when user sets uid of their choice. This is currently breaking ECK E2E tests for 7.16.0-SNAPSHOT.

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.next.asciidoc or CHANGELOG-developer.next.asciidoc.

How to test this PR locally

Run the agent normally then use: elastic-agent diagnostics

Related issues

All credit goes to @barkbay 🙇

@david-kow david-kow added the bug label Oct 28, 2021
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 28, 2021
@mergify
Copy link
Contributor

mergify bot commented Oct 28, 2021

This pull request does not have a backport label. Could you fix it @david-kow? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Oct 28, 2021
@david-kow david-kow added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team and removed backport-skip Skip notification from the automated backport with mergify labels Oct 28, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Oct 28, 2021
@mergify
Copy link
Contributor

mergify bot commented Oct 28, 2021

This pull request does not have a backport label. Could you fix it @david-kow? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Oct 28, 2021
@elasticmachine
Copy link
Collaborator

💚 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: 2021-10-28T11:25:29.008+0000

  • Duration: 125 min 8 sec

  • Commit: 33b8da5

Test stats 🧪

Test Results
Failed 0
Passed 54138
Skipped 5359
Total 59497

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

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

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

Copy link
Contributor

@michel-laterman michel-laterman left a comment

Choose a reason for hiding this comment

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

lgtm

@axw axw added backport-v7.16.0 Automated backport with mergify backport-v8.0.0 Automated backport with mergify and removed backport-skip Skip notification from the automated backport with mergify labels Oct 29, 2021
@axw axw merged commit 7af0c20 into elastic:master Oct 29, 2021
mergify bot pushed a commit that referenced this pull request Oct 29, 2021
mergify bot pushed a commit that referenced this pull request Oct 29, 2021
axw pushed a commit that referenced this pull request Oct 29, 2021
(cherry picked from commit 7af0c20)

Co-authored-by: David Kowalski <[email protected]>
axw pushed a commit that referenced this pull request Oct 29, 2021
(cherry picked from commit 7af0c20)

Co-authored-by: David Kowalski <[email protected]>
@david-kow david-kow deleted the fix_libbeat_username_fetch branch October 29, 2021 05:00
Icedroid pushed a commit to Icedroid/beats that referenced this pull request Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v7.16.0 Automated backport with mergify backport-v8.0.0 Automated backport with mergify bug Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants