-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Allow addon enabling and disabling when minikube is not running #5565
Allow addon enabling and disabling when minikube is not running #5565
Conversation
Welcome @RickyRajinder! |
Hi @RickyRajinder. 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 Once the patch is verified, the new status will be reflected by the 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: RickyRajinder 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 |
Can one of the admins verify this patch? |
Travis tests have failedHey @RickyRajinder, 1st Buildmake test
2nd Buildmake test
TravisBuddy Request Identifier: 553fdab0-e97e-11e9-93dd-b3a5547eb4f4 |
Travis tests have failedHey @RickyRajinder, 1st Buildmake test
2nd Buildmake test
TravisBuddy Request Identifier: 6272b0c0-e980-11e9-93dd-b3a5547eb4f4 |
Travis tests have failedHey @RickyRajinder, 1st Buildmake test
2nd Buildmake test
TravisBuddy Request Identifier: d2a5d8f0-e984-11e9-93dd-b3a5547eb4f4 |
Travis tests have failedHey @RickyRajinder, 1st Buildmake test
2nd Buildmake test
TravisBuddy Request Identifier: 434be400-e985-11e9-93dd-b3a5547eb4f4 |
e935188
to
042fd29
Compare
Travis tests have failedHey @RickyRajinder, 1st Buildmake test
2nd Buildmake test
TravisBuddy Request Identifier: bc7d9950-e989-11e9-93dd-b3a5547eb4f4 |
It appears the test is failing because there is no existing minikube machine in Travis. Could anyone suggest a workaround to this? |
first of all thank you for making this contribution :) for the unit test failure, maybe you could use the Mock Machine as seen in the the other uni tests? ( I haven't had chance to study your PR yet to give more precise advice but maybe that is helpful ?) alternatively you could use a testdata folder and put a fake .minikube profile data in there and point minikube home to that test data... |
042fd29
to
8519853
Compare
Travis tests have failedHey @RickyRajinder, 1st Buildmake test
2nd Buildmake test
TravisBuddy Request Identifier: 230838c0-e98e-11e9-93dd-b3a5547eb4f4 |
Travis tests have failedHey @RickyRajinder, 1st Buildmake test
2nd Buildmake test
TravisBuddy Request Identifier: baaac4b0-eab3-11e9-90a0-7556777797a6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea is sound, but let's let the caller make the determination on whether or not it needs a command runner if the cluster is up or not. Otherwise the caller will never know that it is sending commands to a mock.
|
||
func TestEnableUnknownAddon(t *testing.T) { | ||
if err := Set("InvalidAddon", "false"); err == nil { | ||
t.Fatalf("Enable did not return error for unknown addon") | ||
} | ||
} | ||
func TestEnableAddon(t *testing.T) { | ||
if err := Set("ingress", "true"); err != nil { | ||
if !strings.Contains(err.Error(), "was already enabled") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this test - why would ingress already be enabled when this test is run? Enabling an enabled addon should not cause an error. We should aim for idempotent API's when possible.
Also, never compare error strings in go: https://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully
Also, please don't compare error strings, they are not an API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to create a mock machine in a directory? I found .minikube/ test data but they only contain profiles.
pkg/minikube/machine/client.go
Outdated
@@ -147,8 +147,8 @@ func (api *LocalClient) Close() error { | |||
} | |||
|
|||
// CommandRunner returns best available command runner for this host | |||
func CommandRunner(h *host.Host) (command.Runner, error) { | |||
if h.DriverName == constants.DriverMock { | |||
func CommandRunner(h *host.Host, minikubeRunning bool) (command.Runner, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API change doesn't feel right to me. The caller should first detect that the cluster is not running, and not ask for a runner in that case. Silently passing a mock back can result in unexpected behavior.
Let's keep fakes and mocks for testing use only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What type of runner should be used?
@@ -604,12 +604,13 @@ func CreateSSHShell(api libmachine.API, args []string) error { | |||
|
|||
// EnsureMinikubeRunningOrExit checks that minikube has a status available and that | |||
// the status is `Running`, otherwise it will exit | |||
func EnsureMinikubeRunningOrExit(api libmachine.API, exitStatus int) { | |||
func IsMinikubeRunning(api libmachine.API) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great cleanup here. =)
@minikube-bot OK to test |
FYI, flaky ssh test failure was #4346 |
8519853
to
007342d
Compare
Travis tests have failedHey @RickyRajinder, 1st Buildmake test
TravisBuddy Request Identifier: 4c399320-ebf4-11e9-b967-0723f107a86b |
007342d
to
a229ef2
Compare
Fixed test Print error message Change minikube running check to after check if exists Updates Set and adds test for disabling Fix action for minikube not running Fix import order
a229ef2
to
96edacc
Compare
Codecov Report
@@ Coverage Diff @@
## master #5565 +/- ##
==========================================
+ Coverage 36.89% 37.08% +0.19%
==========================================
Files 102 102
Lines 7369 7377 +8
==========================================
+ Hits 2719 2736 +17
+ Misses 4297 4287 -10
- Partials 353 354 +1
|
Thank you! |
Fixes #5510
Currently, if you try to enable an addon while minikube is not up, an error is returned saying
This PR attempts to support addon disabling/enabling even when minikube is not running. All feedback and suggestions are welcome.