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

Inconsistent behavior listing profiles in json when none exist #5898

Closed
cheeseandcereal opened this issue Nov 13, 2019 · 2 comments · Fixed by #5955
Closed

Inconsistent behavior listing profiles in json when none exist #5898

cheeseandcereal opened this issue Nov 13, 2019 · 2 comments · Fixed by #5955
Assignees
Labels
area/profiles issues related to profile handling good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@cheeseandcereal
Copy link
Contributor

cheeseandcereal commented Nov 13, 2019

Using minikube version 1.5.2 tested on Linux and Windows 10 with the same behavior:

The command minikube profile list -o json provides inconsistent behavior whether or not the $MINIKUBE_HOME/profiles folder exists or not.

When $MINIKUBE_HOME/profiles does not exist, the command outputs: {"error":{"Op":"open","Path":"/root/.minikube/profiles","Err":2}} and minikube exits with status 1

When that folder does exist, the command outputs: {"invalid":[],"valid":[]} with exit status 0 (as expected).

This seems like undesirable behavior, especially because minikube profile list (without json output) is consistent in both scenarios, outputting the generic * No minikube profile was found. You can create one using `minikube start`. error message and exiting with status code 64 regardless of whether the $MINIKUBE_HOME/profiles folder exists or not

Example of full replication output in bash:

root@d3a5e2df82d8:/# minikube profile list
* No minikube profile was found. You can create one using `minikube start`.
root@d3a5e2df82d8:/# echo $?
64
root@d3a5e2df82d8:/# minikube profile list -o json
{"error":{"Op":"open","Path":"/root/.minikube/profiles","Err":2}}
root@d3a5e2df82d8:/# echo $?
1
root@d3a5e2df82d8:/# mkdir ~/.minikube/profiles
root@d3a5e2df82d8:/# minikube profile list
* No minikube profile was found. You can create one using `minikube start`.
root@d3a5e2df82d8:/# echo $?
64
root@d3a5e2df82d8:/# minikube profile list -o json
{"invalid":[],"valid":[]}
root@d3a5e2df82d8:/# echo $?
0

Minikube should probably ensure that the $MINIKUBE_HOME/profiles folder exists (and create it if missing) before the profile list operation in order to provide consistent, expected behavior.

@tstromberg tstromberg added area/profiles issues related to profile handling kind/bug Categorizes issue or PR as related to a bug. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. priority/backlog Higher priority than priority/awaiting-more-evidence. labels Nov 15, 2019
@priyawadhwa
Copy link

Hey @cheeseandcereal thanks for opening this issue. Definitely agree the behavior is a bit confusing and could be improved.

WDYT of outputting:

* No minikube profile was found. You can create one using 'minikube start'. to STDOUT
{"invalid":[],"valid":[]} for -o json
and exit code 0

for both cases (when $MINIKUBE_HOME/profiles exists and when it doesn't`)?

If you, or anyone else would be interested in submitting a PR for this, that would be great! You can assign yourself to this issue by commenting /assign.

@cheeseandcereal
Copy link
Contributor Author

cheeseandcereal commented Nov 20, 2019

/assign

Yeah I can do that

nirs added a commit to nirs/minikube that referenced this issue Jan 4, 2023
This was reported in kubernetes#5898 and fixed in kubernetes#5955 in 2019. However the fix
assumed that `listProfiles()` can return `config.ErrNotExists` while it
returns `os.ErrNotExist` from `os.ReadDir`.

Fixes kubernetes#15593
nirs added a commit to nirs/minikube that referenced this issue Jan 4, 2023
This was reported in [1] and fixed in [2] in 2019. However the fix
assumed that `listProfiles()` can return `config.ErrNotExists` while it
returns `os.ErrNotExist` from `os.ReadDir`.

[1] kubernetes#5898
[2] kubernetes#5955
nirs added a commit to nirs/minikube that referenced this issue Jan 4, 2023
This was reported in [1] and fixed in [2] in 2019, but later it was
broken by [3] in commit c3aafae.

`listProfiles()` can return `os.ErrNotExist` from `os.ReadDir()` so it
must be tested with `os.IsNotExist()`.

[1] kubernetes#5898
[2] kubernetes#5955
[3] kubernetes#6440
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/profiles issues related to profile handling good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants