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 profile list for non existenting folder #5955

Merged
merged 1 commit into from
Nov 25, 2019
Merged

Fix profile list for non existenting folder #5955

merged 1 commit into from
Nov 25, 2019

Conversation

cheeseandcereal
Copy link
Contributor

Fixes #5898

Behavior of minikube profile list -o json was dependent whether or not the $MINIKUBE_HOME/profiles folder exists or not.

This small update simply checks if the error is due to the folder not existing, and if so, simply returns the normal empty array results with a normal exit code

Before:

$ ls ~/.minikube/profiles
ls: cannot access '/home/adam/.minikube/profiles': No such file or directory
$ minikube profile list -o json
{"error":{"Op":"open","Path":"/root/.minikube/profiles","Err":2}}
$ echo $?
1
$ mkdir ~/.minikube/profiles
$ minikube profile list -o json
{"invalid":[],"valid":[]}
$ echo $?
0

After:

$ ls ~/.minikube/profiles
ls: cannot access '/home/adam/.minikube/profiles': No such file or directory
$ minikube profile list -o json
{"invalid":[],"valid":[]}
$ echo $?
0
$ mkdir ~/.minikube/profiles
$ minikube profile list -o json
{"invalid":[],"valid":[]}
$ echo $?
0

Signed-off-by: Adam Crowder <adam@adamcrowder.net>
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Nov 20, 2019
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@k8s-ci-robot
Copy link
Contributor

Welcome @cheeseandcereal!

It looks like this is your first PR to kubernetes/minikube 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/minikube has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 20, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @cheeseandcereal. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cheeseandcereal
To complete the pull request process, please assign medyagh
You can assign the PR to them by writing /assign @medyagh in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 20, 2019
@cheeseandcereal
Copy link
Contributor Author

/assign @medyagh

@codecov-io
Copy link

Codecov Report

Merging #5955 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5955   +/-   ##
=======================================
  Coverage   36.09%   36.09%           
=======================================
  Files         110      110           
  Lines        8208     8208           
=======================================
  Hits         2963     2963           
  Misses       4854     4854           
  Partials      391      391
Impacted Files Coverage Δ
cmd/minikube/cmd/config/profile_list.go 5.26% <0%> (ø) ⬆️

@cheeseandcereal
Copy link
Contributor Author

Also I signed the CLA before submitting, not sure why it's showing up as not signed. My git and github email are both the same as what's in the linux foundation account

@medyagh
Copy link
Member

medyagh commented Nov 22, 2019

/check-cla

@medyagh
Copy link
Member

medyagh commented Nov 22, 2019

@cheeseandcereal thanks for this PR, do you mind sharing the output Before and After this PR ?

@cheeseandcereal
Copy link
Contributor Author

cheeseandcereal commented Nov 22, 2019

@cheeseandcereal thanks for this PR, do you mind sharing the output Before and After this PR ?

It's in the PR description

@medyagh
Copy link
Member

medyagh commented Nov 22, 2019

@cheeseandcereal yes please

@medyagh
Copy link
Member

medyagh commented Nov 22, 2019

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 22, 2019
@RA489
Copy link

RA489 commented Nov 22, 2019

/check-cla

@medyagh
Copy link
Member

medyagh commented Nov 25, 2019

@cheeseandcereal do you mind contacting the support or try again to make sure the CLA is signed ?

here is the link https://identity.linuxfoundation.org/?destination=node/285/individual-signup

once CLA is signed it would be good to merge

@cheeseandcereal
Copy link
Contributor Author

/check-cla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 25, 2019
@cheeseandcereal
Copy link
Contributor Author

@medyagh Should be good now

@medyagh
Copy link
Member

medyagh commented Nov 25, 2019

Thank you for this improvement this will make minikube looks better

@medyagh medyagh merged commit 72e9730 into kubernetes:master Nov 25, 2019
@medyagh medyagh changed the title Fix profile list json command output Fix profile list json when folder doesn't exist Nov 25, 2019
@medyagh medyagh changed the title Fix profile list json when folder doesn't exist Fix profile list for non existenting folder Nov 25, 2019
nirs added a commit to nirs/minikube that referenced this pull request 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 pull request 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 pull request 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
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent behavior listing profiles in json when none exist
6 participants