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

wrong error message when using kubeadm with unknown phase sub commands #3093

Closed
akhilerm opened this issue Aug 5, 2024 · 9 comments
Closed
Labels
area/cli area/phases kind/bug Categorizes issue or PR as related to a bug. priority/backlog Higher priority than priority/awaiting-more-evidence.
Milestone

Comments

@akhilerm
Copy link
Member

akhilerm commented Aug 5, 2024

What happened?

When executing the below kubeadm join command

akhil@akhilerm:/t/t/k/n/bin $ ./kubeadm join phase control-plane-join update-status --config=/run/kubeadm/kubeadm-join-config.yaml
unknown flag: --config
To see the stack trace of this error execute with --v=5 or higher

it gives the unknown flag error even though its a subcommand error.

  • If the command is run without the flag at the end , proper error message is shown
akhil@akhilerm:/t/t/k/n/bin $ ./kubeadm join phase control-plane-join update-status
unknown command "update-status" for "kubeadm join phase control-plane-join"
To see the stack trace of this error execute with --v=5 or higher

What did you expect to happen?

Executing ./kubeadm join phase control-plane-join update-status --config=/run/kubeadm/kubeadm-join-config.yaml should also give the unknown command error

How can we reproduce it (as minimally and precisely as possible)?

  1. Checkout to the master branch of k/k
  2. make WHAT=cmd/kubeadm
  3. _output/bin/kubeadm join phase control-plain-join update-status --config=/run/kubeadm/kubeadm-join-config.yaml

Anything else we need to know?

update-status was removed in kubernetes/kubernetes#124373

Kubernetes version

akhil@akhilerm:~/g/s/g/k/kubernetes (master)$ _output/bin/kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"32+", GitVersion:"v1.32.0-alpha.0.18+00236ae0d73d24", GitCommit:"00236ae0d73d2455a2470469ed1005674f8ed61f", GitTreeState:"clean", BuildDate:"2024-08-05T12:11:11Z", GoVersion:"go1.22.5", Compiler:"gc", Platform:"linux/amd64"}

Cloud provider

OS version

# On Linux:
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
$ uname -a
Linux sjc-ubu-eng-106 5.15.0-117-generic kubernetes/kubernetes#127-Ubuntu SMP Fri Jul 5 20:13:28 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

@akhilerm akhilerm added the kind/bug Categorizes issue or PR as related to a bug. label Aug 5, 2024
@k8s-ci-robot
Copy link
Contributor

There are no sig labels on this issue. Please add an appropriate label by using one of the following commands:

  • /sig <group-name>
  • /wg <group-name>
  • /committee <group-name>

Please see the group list for a listing of the SIGs, working groups, and committees available.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Aug 5, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Aug 5, 2024
@akhilerm
Copy link
Member Author

akhilerm commented Aug 5, 2024

@neolit123 Wanted to know if this is relevant enough to be fixed in the kubeadm side, or has more to do with how the flags are parsed.

@neolit123
Copy link
Member

/transfer kubeadm

@k8s-ci-robot k8s-ci-robot transferred this issue from kubernetes/kubernetes Aug 5, 2024
@neolit123
Copy link
Member

Executing ./kubeadm join phase control-plane-join update-status --config=/run/kubeadm/kubeadm-join-config.yaml should also give the unknown command error

i don't know if that is an easy fix.
PRs welcome.

@neolit123 neolit123 added area/phases area/cli priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 5, 2024
@neolit123 neolit123 modified the milestones: v1.31, v1.32 Aug 5, 2024
@pacoxu
Copy link
Member

pacoxu commented Aug 6, 2024

This seems to a general issue with many subcommands.

[root@node ~]# kubeadm config images  list --v1
unknown flag: --v1
To see the stack trace of this error execute with --v=5 or higher
[root@node ~]# kubeadm config images  list2 --v1
unknown flag: --v1
To see the stack trace of this error execute with --v=5 or higher

@neolit123
Copy link
Member

/retitle wrong error message when using kubeadm with unknown phase sub commands

@k8s-ci-robot k8s-ci-robot changed the title wrong error message when using kubeadm with unknown command in kubadm join phase wrong error message when using kubeadm with unknown phase sub commands Aug 7, 2024
@neolit123
Copy link
Member

did some investigation and this seems to be standard cobra behavior. flags are processed before sub-commands and arguments of a parent command.

to illustrate:

$ kubeadm init foo --bar
unknown flag: --bar
To see the stack trace of this error execute with --v=5 or higher

$ kubeadm init foo
unknown command "foo" for "kubeadm init"
To see the stack trace of this error execute with --v=5 or higher

the unknown flag --bar is processed first and if the invalid flag is removed the unknown command is then detected.
i.e. this is not something caused by the kubeadm phase logic, which is a bit complicated.

i think it's fine for us to acknowledge this issue, but i don't think we need to make any fixes for it in kubeadm or cobra.

@neolit123
Copy link
Member

something that we should probably fix is the following:

$ kubeadm init phase foo && echo ok

...

ok

i.e. the unknown command returns exit code 0.

i will send a PR for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli area/phases kind/bug Categorizes issue or PR as related to a bug. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

4 participants