-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]>
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 |
Codecov ReportAttention: Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
dereknola
approved these changes
Nov 5, 2024
manuelbuil
approved these changes
Nov 6, 2024
This was referenced Nov 6, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
--help
or --version
flags #11235User-Facing Change
Further Comments