Skip to content

Commit

Permalink
Merge pull request #6438 from tstromberg/nonexistent-status
Browse files Browse the repository at this point in the history
status: Explicitly state that the cluster does not exist
  • Loading branch information
tstromberg authored Jan 31, 2020
2 parents 723b074 + 6bd48a8 commit 02902f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
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

0 comments on commit 02902f7

Please sign in to comment.