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

Fix K3S_DATA_DIR when running as non-root user #11378

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

unguiculus
Copy link

@unguiculus unguiculus commented Nov 27, 2024

Proposed Changes

When running the generated kill and uninstall scripts as non-root user, the environment variable K3S_DATA_DIR got lost, because sudo by default doesn't preserve the environment. This is fixed by adding the --preserve-env flag.

Types of Changes

Bugfix

Verification

  • Set environment variable K3S_DATA_DIR.
  • Run the generated k3s-uninstall.sh script as non-root user and check the log output.
  • Verify that the $K3S_DATA_DIR directory got cleaned.

Fixes: #11386

When running the generated kill and uninstall scripts, the environment
variable `K3S_DATA_DIR` got lost, because `sudo` by default doesn't
preserve the environment. This is fixed by adding the `--preserve-env`
flag.

Signed-off-by: Reinhard Nägele <[email protected]>
@unguiculus unguiculus requested a review from a team as a code owner November 27, 2024 16:35
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 42.51%. Comparing base (55cda22) to head (a9f711a).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11378      +/-   ##
==========================================
- Coverage   47.12%   42.51%   -4.61%     
==========================================
  Files         179      179              
  Lines       18600    18600              
==========================================
- Hits         8765     7908     -857     
- Misses       8481     9485    +1004     
+ Partials     1354     1207     -147     
Flag Coverage Δ
e2etests 34.20% <ø> (-8.00%) ⬇️
inttests 34.69% <ø> (-0.03%) ⬇️
unittests 13.82% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brandond
Copy link
Member

Thanks for the fix! Can you open an issue describing the problem this fixes, so our QA team can validate that the issue is resolved by this change?

Copy link
Member

@brandond brandond left a comment

Choose a reason for hiding this comment

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

I'd prefer to pass through only this one necessary env var, instead of passing through ALL of them.

install.sh Outdated Show resolved Hide resolved
install.sh Outdated Show resolved Hide resolved
unguiculus and others added 3 commits November 28, 2024 09:12
Co-authored-by: Brad Davidson <[email protected]>
Signed-off-by: Reinhard Nägele <[email protected]>
Co-authored-by: Brad Davidson <[email protected]>
Signed-off-by: Reinhard Nägele <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

K3S_DATA_DIR is lost when running kill and uninstall scripts as non-root user
2 participants