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

Detect status before enable/disable addon #4424

Merged
merged 1 commit into from
Jun 14, 2019

Conversation

fenglixa
Copy link
Contributor

@fenglixa fenglixa commented Jun 5, 2019

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 5, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @fenglixa. 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 k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 5, 2019
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@RA489
Copy link

RA489 commented Jun 5, 2019

@minikube-bot ok-to-test

1 similar comment
@medyagh
Copy link
Member

medyagh commented Jun 5, 2019

@minikube-bot ok-to-test

cmd/minikube/cmd/config/util.go Outdated Show resolved Hide resolved
cmd/minikube/cmd/config/util.go Outdated Show resolved Hide resolved
cmd/minikube/cmd/config/util.go Outdated Show resolved Hide resolved
@fenglixa
Copy link
Contributor Author

fenglixa commented Jun 6, 2019

@minikube-bot OK to test

@medyagh
Copy link
Member

medyagh commented Jun 6, 2019

Thanks for contribution, could you pleas add unit testint ? Maybe have a mock enabled addon and try to enable it

@fenglixa
Copy link
Contributor Author

fenglixa commented Jun 6, 2019

Thanks for contribution, could you pleas add unit testint ? Maybe have a mock enabled addon and try to enable it

Thanks @medyagh Did you mean following? I think I appended it already. : )

 > ~/Documents/GitHub/minikube >> minikube addons list |grep enable
- addon-manager: enabled
- dashboard: enabled
- default-storageclass: enabled
- storage-provisioner: enabled
 ~/Documents/GitHub/minikube>> minikube addons enable dashboard
💥  addon dashboard was already enabled. 

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contribution, could you pleas add unit testint ? Maybe have a mock enabled addon and try to enable it

Thanks @medyagh Did you mean following? I think I appended it already. : )

 > ~/Documents/GitHub/minikube >> minikube addons list |grep enable
- addon-manager: enabled
- dashboard: enabled
- default-storageclass: enabled
- storage-provisioner: enabled
 ~/Documents/GitHub/minikube>> minikube addons enable dashboard
💥  addon dashboard was already enabled. 

I meant like for example for this logic in your code

	if addonStatus && enable {
		console.ErrStyle(console.Conflict, "addon %s was already enabled.", addon.GetAddon())
		os.Exit(exit.Unavailable)
	} else if !addonStatus && !enable {
		console.ErrStyle(console.Conflict, "addon %s was already disabled.", addon.GetAddon())
		os.Exit(exit.Unavailable)
	}

you could put it in a func and then add a TestFunc for it.
that you could do unit testing for that func, here are some example unit tests in minikube. https://github.com/kubernetes/minikube/blob/master/cmd/minikube/cmd/config/util_test.go#L69

you could have a unit test that tries to disable an already disabled addon, and expects it to get err

cmd/minikube/cmd/config/util.go Show resolved Hide resolved
@medyagh
Copy link
Member

medyagh commented Jun 6, 2019

Thanks for contribution, could you pleas add unit testint ? Maybe have a mock enabled addon and try to enable it

Thanks @medyagh Did you mean following? I think I appended it already. : )

 > ~/Documents/GitHub/minikube >> minikube addons list |grep enable
- addon-manager: enabled
- dashboard: enabled
- default-storageclass: enabled
- storage-provisioner: enabled
 ~/Documents/GitHub/minikube>> minikube addons enable dashboard
💥  addon dashboard was already enabled. 

I meant like for example for this logic in your code

	if addonStatus && enable {
		console.ErrStyle(console.Conflict, "addon %s was already enabled.", addon.GetAddon())
		os.Exit(exit.Unavailable)
	} else if !addonStatus && !enable {
		console.ErrStyle(console.Conflict, "addon %s was already disabled.", addon.GetAddon())
		os.Exit(exit.Unavailable)
	}

you could put it in a func and then add a TestFunc for it.
that you could do unit testing for that func, here are some example unit tests in minikube. https://github.com/kubernetes/minikube/blob/master/cmd/minikube/cmd/config/util_test.go#L69

you could have a unit test that tries to disable an already disabled addon, and expects it to get err
@fenglixa for example you could have a func called

func isAddonAlreadySet(addon *assets.Addon, enable bool) bool
and then you can move the logic of addonStatus, err := addon.IsEnabled() inside that func

and you would write a unit test for this func in cmd/minikube/cmd/config/util_test.go

TestIsAddonAlreadySet(....)

please let me know if you have any other questions :)

@sharifelgamal
Copy link
Collaborator

@minikube-bot OK to test

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 10, 2019
@fenglixa
Copy link
Contributor Author

@medyagh Thanks for your comments. I added unit test cases for the new added func. Please help check & review.
@sharifelgamal I addressed the issue in the result of integration test, please help check again. Thanks.
(the reason is get dashboard url will enable dashboard always, which will be failed as it was already enabled)

BR
-Francis

@fenglixa
Copy link
Contributor Author

09:34:38 | >   - error: failed to create listener: failed to listen on 0.0.0.0:8443: listen tcp 0.0.0.0:8443: bind: address already in use
--- FAIL: TestVersionUpgrade (127.96s)

should be case issue related to #4418

@fenglixa
Copy link
Contributor Author

@minikube-bot OK to test

@RA489
Copy link

RA489 commented Jun 10, 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 Jun 10, 2019
Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for improvements you made, it looks a lot better just a few more changes.

cmd/minikube/cmd/config/util_test.go Outdated Show resolved Hide resolved
pkg/minikube/assets/addons.go Outdated Show resolved Hide resolved
cmd/minikube/cmd/config/util.go Outdated Show resolved Hide resolved
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fenglixa
To complete the pull request process, please assign ra489
You can assign the PR to them by writing /assign @ra489 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

@fenglixa
Copy link
Contributor Author

/retest

@fenglixa
Copy link
Contributor Author

Test failed is not related to my modification.

/retest

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the changes, please change this to Name(). I think after this change it will be good to go !

pkg/minikube/assets/addons.go Outdated Show resolved Hide resolved
@RA489
Copy link

RA489 commented Jun 12, 2019

@fenglixa can you please squash the commit to one

@fenglixa
Copy link
Contributor Author

@RA489 squashed done. Thanks

@RA489
Copy link

RA489 commented Jun 12, 2019

@fenglixa Thanks!

@fenglixa
Copy link
Contributor Author

Seems it can not take effect when I provide /retest command. Could someone help trigger retest of integration? Thanks

@RA489
Copy link

RA489 commented Jun 13, 2019

/retest

@fenglixa
Copy link
Contributor Author

Thanks @RA489. but seems it is also not take effect.

@sharifelgamal
Copy link
Collaborator

@minikube-bot OK to test

@fenglixa
Copy link
Contributor Author

@minikube-bot okay to test

@medyagh
Copy link
Member

medyagh commented Jun 14, 2019

@minikube-bot OK to test

@medyagh medyagh merged commit 31ab527 into kubernetes:master Jun 14, 2019
@medyagh
Copy link
Member

medyagh commented Jun 14, 2019

@fenglixa Thank you so much for patiently making all the required changes and sorry for the unrelated failing tests. Thank you for the contribution

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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Usability: check addon status before disable.
7 participants