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 MustFindString returning override flags on external CLI commands #11237

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

brandond
Copy link
Member

@brandond brandond commented Nov 5, 2024

Proposed Changes

Fix MustFindString returning override flags on external CLI commands

External CLI actions cannot short-circuit on --help or --version, so we cannot skip loading the config file if these flags are present when running these wrapped commands. The behavior of just returning the override flag name instead of the requested flag value was breaking data-dir lookup when running wrapped commands.

This was introduced in #7683 - which did not account for some subcommands/wrapped commands needing to be unconditionally extracted out.

Types of Changes

bugfix

Verification

See linked issue

Testing

yes

Linked Issues

User-Facing Change

Further Comments

External CLI actions cannot short-circuit on --help or --version, so we
cannot skip loading the config file if these flags are present when
running these wrapped commands. The behavior of just returning the
override flag name instead of the requested flag value was breaking
data-dir lookup when running wrapped commands.

Signed-off-by: Brad Davidson <[email protected]>
@brandond brandond requested a review from a team as a code owner November 5, 2024 22:21
@brandond
Copy link
Member Author

brandond commented Nov 5, 2024

opensuse@systemd-node-1:~> K3S_DEBUG=true k3s server --version
Incorrect Usage: flag provided but not defined: -version

NAME:
   k3s server - Run management server
...
FATA[0000] flag provided but not defined: -version

opensuse@systemd-node-1:~> K3S_DEBUG=true k3s --version
k3s version v1.31.2+k3s-8c69ea76 (8c69ea76)
go version go1.22.8

opensuse@systemd-node-1:~> K3S_DEBUG=true k3s ctr --version
WARN[0000] open /etc/rancher/k3s/config.yaml: permission denied
INFO[0000] Acquiring lock file /home/opensuse/.rancher/k3s/data/.lock
INFO[0000] Preparing data dir /home/opensuse/.rancher/k3s/data/c5be0ae8d469281a9af254e304064d66b0874c393e880c9838dd43769d8deb5e   
...
DEBU[0002] Asset dir /home/opensuse/.rancher/k3s/data/c5be0ae8d469281a9af254e304064d66b0874c393e880c9838dd43769d8deb5e
WARN[0002] open /etc/rancher/k3s/config.yaml: permission denied
DEBU[0002] Running /home/opensuse/.rancher/k3s/data/c5be0ae8d469281a9af254e304064d66b0874c393e880c9838dd43769d8deb5e/bin/ctr [ctr --version]
ctr github.com/k3s-io/containerd v1.7.22-k3s1

opensuse@systemd-node-1:~> K3S_DEBUG=true ctr --version
WARN[0000] open /etc/rancher/k3s/config.yaml: permission denied
INFO[0000] Acquiring lock file /home/opensuse/.rancher/k3s/data/.lock
INFO[0000] Preparing data dir /home/opensuse/.rancher/k3s/data/c5be0ae8d469281a9af254e304064d66b0874c393e880c9838dd43769d8deb5e
...
DEBU[0002] Asset dir /home/opensuse/.rancher/k3s/data/c5be0ae8d469281a9af254e304064d66b0874c393e880c9838dd43769d8deb5e
WARN[0002] open /etc/rancher/k3s/config.yaml: permission denied
DEBU[0002] Running /home/opensuse/.rancher/k3s/data/c5be0ae8d469281a9af254e304064d66b0874c393e880c9838dd43769d8deb5e/bin/ctr [ctr --version]
ctr github.com/k3s-io/containerd v1.7.22-k3s1

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 72.22222% with 5 lines in your changes missing coverage. Please review.

Project coverage is 42.05%. Comparing base (917761c) to head (8c69ea7).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
pkg/configfilearg/defaultparser.go 72.22% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11237      +/-   ##
==========================================
- Coverage   47.03%   42.05%   -4.98%     
==========================================
  Files         179      179              
  Lines       18573    18587      +14     
==========================================
- Hits         8736     7817     -919     
- Misses       8480     9565    +1085     
+ Partials     1357     1205     -152     
Flag Coverage Δ
e2etests 33.97% <0.00%> (-8.22%) ⬇️
inttests 18.81% <0.00%> (-15.93%) ⬇️
unittests 13.64% <72.22%> (+0.04%) ⬆️

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.

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.

3 participants