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

status: Explicitly state that the cluster does not exist #6438

Merged
merged 1 commit into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions cmd/minikube/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ var output string

const (
// Additional states used by kubeconfig
Configured = "Configured" // analogous to state.Saved
Misconfigured = "Misconfigured" // analogous to state.Error
Configured = "Configured" // ~state.Saved
Misconfigured = "Misconfigured" // ~state.Error
// Additional states used for clarity
Nonexistent = "Nonexistent" // ~state.None
)

// Status holds string representations of component states
Expand Down Expand Up @@ -92,6 +94,9 @@ var statusCmd = &cobra.Command{
if err != nil {
glog.Errorf("status error: %v", err)
}
if st.Host == Nonexistent {
glog.Errorf("The %q cluster does not exist!", machineName)
}

switch strings.ToLower(output) {
case "text":
Expand Down Expand Up @@ -125,11 +130,22 @@ func exitCode(st *Status) int {
}

func status(api libmachine.API, name string) (*Status, error) {
st := &Status{}
st := &Status{
Host: Nonexistent,
APIServer: Nonexistent,
Kubelet: Nonexistent,
Kubeconfig: Nonexistent,
}

hs, err := cluster.GetHostStatus(api, name)
if err != nil {
return st, errors.Wrap(err, "host")
}

// Nonexistent it is!
if hs == state.None.String() {
return st, nil
}
st.Host = hs
if st.Host != state.Running.String() {
return st, nil
Expand Down
1 change: 1 addition & 0 deletions cmd/minikube/cmd/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestExitCode(t *testing.T) {
{"ok", 0, &Status{Host: "Running", Kubelet: "Running", APIServer: "Running", Kubeconfig: Configured}},
{"paused", 2, &Status{Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured}},
{"down", 7, &Status{Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured}},
{"missing", 7, &Status{Host: "Nonexistent", Kubelet: "Nonexistent", APIServer: "Nonexistent", Kubeconfig: "Nonexistent"}},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
Expand Down