Skip to content
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
7 changes: 4 additions & 3 deletions cmd/minikube/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ type Status struct {
APIServer string
Kubeconfig string
Worker bool
TimeToStop string
TimeToStop string `json:",omitempty"`
DockerEnv string `json:",omitempty"`
PodManEnv string `json:",omitempty"`
}
Expand All @@ -146,7 +146,7 @@ type ClusterState struct {
BaseState

BinaryVersion string
TimeToStop string
TimeToStop string `json:",omitempty"`
Components map[string]BaseState
Nodes []NodeState
}
Expand Down Expand Up @@ -185,7 +185,9 @@ host: {{.Host}}
kubelet: {{.Kubelet}}
apiserver: {{.APIServer}}
kubeconfig: {{.Kubeconfig}}
{{- if .TimeToStop }}
timeToStop: {{.TimeToStop}}
{{- end }}
{{- if .DockerEnv }}
docker-env: {{.DockerEnv}}
{{- end }}
Expand Down Expand Up @@ -319,7 +321,6 @@ func nodeStatus(api libmachine.API, cc config.ClusterConfig, n config.Node) (*St
Kubelet: Nonexistent,
Kubeconfig: Nonexistent,
Worker: !controlPlane,
TimeToStop: Nonexistent,
}

hs, err := machine.Status(api, name)
Expand Down
12 changes: 6 additions & 6 deletions cmd/minikube/cmd/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ func TestStatusText(t *testing.T) {
},
{
name: "paused",
state: &Status{Name: "minikube", Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured, TimeToStop: Nonexistent},
want: "minikube\ntype: Control Plane\nhost: Running\nkubelet: Stopped\napiserver: Paused\nkubeconfig: Configured\ntimeToStop: Nonexistent\n\n",
state: &Status{Name: "minikube", Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured},
want: "minikube\ntype: Control Plane\nhost: Running\nkubelet: Stopped\napiserver: Paused\nkubeconfig: Configured\n\n",
},
{
name: "down",
state: &Status{Name: "minikube", Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured, TimeToStop: Nonexistent},
want: "minikube\ntype: Control Plane\nhost: Stopped\nkubelet: Stopped\napiserver: Stopped\nkubeconfig: Misconfigured\ntimeToStop: Nonexistent\n\n\nWARNING: Your kubectl is pointing to stale minikube-vm.\nTo fix the kubectl context, run `minikube update-context`\n",
state: &Status{Name: "minikube", Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured},
want: "minikube\ntype: Control Plane\nhost: Stopped\nkubelet: Stopped\napiserver: Stopped\nkubeconfig: Misconfigured\n\n\nWARNING: Your kubectl is pointing to stale minikube-vm.\nTo fix the kubectl context, run `minikube update-context`\n",
},
}
for _, tc := range tests {
Expand All @@ -87,8 +87,8 @@ func TestStatusJSON(t *testing.T) {
state *Status
}{
{"ok", &Status{Host: "Running", Kubelet: "Running", APIServer: "Running", Kubeconfig: Configured, TimeToStop: "10m"}},
{"paused", &Status{Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured, TimeToStop: Nonexistent}},
{"down", &Status{Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured, TimeToStop: Nonexistent}},
{"paused", &Status{Host: "Running", Kubelet: "Stopped", APIServer: "Paused", Kubeconfig: Configured}},
{"down", &Status{Host: "Stopped", Kubelet: "Stopped", APIServer: "Stopped", Kubeconfig: Misconfigured}},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/commands/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ minikube status [flags]

```
-f, --format string Go template format string for the status output. The format for Go templates can be found here: https://golang.org/pkg/text/template/
For the list accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status (default "{{.Name}}\ntype: Control Plane\nhost: {{.Host}}\nkubelet: {{.Kubelet}}\napiserver: {{.APIServer}}\nkubeconfig: {{.Kubeconfig}}\ntimeToStop: {{.TimeToStop}}\n{{- if .DockerEnv }}\ndocker-env: {{.DockerEnv}}\n{{- end }}\n{{- if .PodManEnv }}\npodman-env: {{.PodManEnv}}\n{{- end }}\n\n")
For the list accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status (default "{{.Name}}\ntype: Control Plane\nhost: {{.Host}}\nkubelet: {{.Kubelet}}\napiserver: {{.APIServer}}\nkubeconfig: {{.Kubeconfig}}\n{{- if .TimeToStop }}\ntimeToStop: {{.TimeToStop}}\n{{- end }}\n{{- if .DockerEnv }}\ndocker-env: {{.DockerEnv}}\n{{- end }}\n{{- if .PodManEnv }}\npodman-env: {{.PodManEnv}}\n{{- end }}\n\n")
-l, --layout string output layout (EXPERIMENTAL, JSON only): 'nodes' or 'cluster' (default "nodes")
-n, --node string The node to check status for. Defaults to control plane. Leave blank with default format for status on all nodes.
-o, --output string minikube status --output OUTPUT. json, text (default "text")
Expand Down
19 changes: 15 additions & 4 deletions test/integration/scheduled_stop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ func TestScheduledStopWindows(t *testing.T) {

// sleep for 5 seconds
time.Sleep(5 * time.Second)
// make sure minikube timetoStop is not present
ensureTimeToStopNotPresent(ctx, t, profile)
// make sure minikube status is "Stopped"
ensureMinikubeStatus(ctx, t, profile, "Host", state.Stopped.String())
// make sure minikube timtostop is "Nonexistent"
ensureMinikubeStatus(ctx, t, profile, "TimeToStop", "Nonexistent")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@medyagh, what I am thinking is instead of removing this check from the test. Can we check for TimeToStop status value to be ""?

Copy link
Contributor

Choose a reason for hiding this comment

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

This should check that the timeToStop line is omitted entirely.

}

func TestScheduledStopUnix(t *testing.T) {
Expand Down Expand Up @@ -113,10 +113,10 @@ func TestScheduledStopUnix(t *testing.T) {
t.Fatalf("process %v running but should have been killed on reschedule of stop", pid)
}

// make sure minikube timetoStop is not present
ensureTimeToStopNotPresent(ctx, t, profile)
// make sure minikube status is "Stopped"
ensureMinikubeStatus(ctx, t, profile, "Host", state.Stopped.String())
// make sure minikube timtostop is "Nonexistent"
ensureMinikubeStatus(ctx, t, profile, "TimeToStop", "Nonexistent")
}

func startMinikube(ctx context.Context, t *testing.T, profile string) {
Expand Down Expand Up @@ -195,3 +195,14 @@ func ensureMinikubeScheduledTime(ctx context.Context, t *testing.T, profile stri
t.Fatalf("error %v", err)
}
}

func ensureTimeToStopNotPresent(ctx context.Context, t *testing.T, profile string) {
args := []string{"status", "-p", profile}
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
t.Fatalf("minikube status: %v\n%s", err, rr.Output())
}
if strings.Contains(rr.Output(), "TimeToStop") {
t.Fatalf("expected status output to not include `TimeToStop` but got *%s*", rr.Output())
}
}