Skip to content

Commit 47435d9

Browse files
authored
Merge pull request #8868 from tstromberg/minimal-transition-state
status: Add experimental cluster JSON status with state transition support
2 parents 245e37d + c6e6013 commit 47435d9

File tree

17 files changed

+533
-87
lines changed

17 files changed

+533
-87
lines changed

cmd/minikube/cmd/delete.go

+11
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
"k8s.io/minikube/pkg/minikube/localpath"
4545
"k8s.io/minikube/pkg/minikube/machine"
4646
"k8s.io/minikube/pkg/minikube/out"
47+
"k8s.io/minikube/pkg/minikube/out/register"
4748
)
4849

4950
var deleteAll bool
@@ -125,6 +126,8 @@ func runDelete(cmd *cobra.Command, args []string) {
125126
if len(args) > 0 {
126127
exit.UsageT("Usage: minikube delete")
127128
}
129+
register.SetEventLogPath(localpath.EventLog(ClusterFlagValue()))
130+
register.Reg.SetStep(register.Deleting)
128131

129132
validProfiles, invalidProfiles, err := config.ListProfiles()
130133
if err != nil {
@@ -146,6 +149,8 @@ func runDelete(cmd *cobra.Command, args []string) {
146149
deleteContainersAndVolumes(oci.Podman)
147150

148151
errs := DeleteProfiles(profilesToDelete)
152+
register.Reg.SetStep(register.Done)
153+
149154
if len(errs) > 0 {
150155
HandleDeletionErrors(errs)
151156
} else {
@@ -166,6 +171,8 @@ func runDelete(cmd *cobra.Command, args []string) {
166171
}
167172

168173
errs := DeleteProfiles([]*config.Profile{profile})
174+
register.Reg.SetStep(register.Done)
175+
169176
if len(errs) > 0 {
170177
HandleDeletionErrors(errs)
171178
}
@@ -264,6 +271,8 @@ func deletePossibleKicLeftOver(cname string, driverName string) {
264271

265272
func deleteProfile(profile *config.Profile) error {
266273
glog.Infof("Deleting %s", profile.Name)
274+
register.Reg.SetStep(register.Deleting)
275+
267276
viper.Set(config.ProfileName, profile.Name)
268277
if profile.Config != nil {
269278
glog.Infof("%s configuration: %+v", profile.Name, profile.Config)
@@ -326,6 +335,8 @@ func deleteProfile(profile *config.Profile) error {
326335
}
327336

328337
func deleteHosts(api libmachine.API, cc *config.ClusterConfig) {
338+
register.Reg.SetStep(register.Deleting)
339+
329340
if cc != nil {
330341
for _, n := range cc.Nodes {
331342
machineName := driver.MachineName(*cc, n)

cmd/minikube/cmd/pause.go

+29-13
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ import (
2828
"k8s.io/minikube/pkg/minikube/cruntime"
2929
"k8s.io/minikube/pkg/minikube/driver"
3030
"k8s.io/minikube/pkg/minikube/exit"
31+
"k8s.io/minikube/pkg/minikube/localpath"
3132
"k8s.io/minikube/pkg/minikube/machine"
3233
"k8s.io/minikube/pkg/minikube/mustload"
3334
"k8s.io/minikube/pkg/minikube/out"
35+
"k8s.io/minikube/pkg/minikube/out/register"
3436
)
3537

3638
var (
@@ -47,8 +49,27 @@ var pauseCmd = &cobra.Command{
4749

4850
func runPause(cmd *cobra.Command, args []string) {
4951
co := mustload.Running(ClusterFlagValue())
52+
register.SetEventLogPath(localpath.EventLog(ClusterFlagValue()))
53+
register.Reg.SetStep(register.Pausing)
54+
55+
glog.Infof("namespaces: %v keys: %v", namespaces, viper.AllSettings())
56+
if allNamespaces {
57+
namespaces = nil //all
58+
} else if len(namespaces) == 0 {
59+
exit.WithCodeT(exit.BadUsage, "Use -A to specify all namespaces")
60+
}
61+
62+
ids := []string{}
5063

5164
for _, n := range co.Config.Nodes {
65+
// Use node-name if available, falling back to cluster name
66+
name := n.Name
67+
if n.Name == "" {
68+
name = co.Config.Name
69+
}
70+
71+
out.T(out.Pause, "Pausing node {{.name}} ... ", out.V{"name": name})
72+
5273
host, err := machine.LoadHost(co.API, driver.MachineName(*co.Config, n))
5374
if err != nil {
5475
exit.WithError("Error getting host", err)
@@ -64,23 +85,18 @@ func runPause(cmd *cobra.Command, args []string) {
6485
exit.WithError("Failed runtime", err)
6586
}
6687

67-
glog.Infof("namespaces: %v keys: %v", namespaces, viper.AllSettings())
68-
if allNamespaces {
69-
namespaces = nil //all
70-
} else if len(namespaces) == 0 {
71-
exit.WithCodeT(exit.BadUsage, "Use -A to specify all namespaces")
72-
}
73-
74-
ids, err := cluster.Pause(cr, r, namespaces)
88+
uids, err := cluster.Pause(cr, r, namespaces)
7589
if err != nil {
7690
exit.WithError("Pause", err)
7791
}
92+
ids = append(ids, uids...)
93+
}
7894

79-
if namespaces == nil {
80-
out.T(out.Unpause, "Paused kubelet and {{.count}} containers", out.V{"count": len(ids)})
81-
} else {
82-
out.T(out.Unpause, "Paused kubelet and {{.count}} containers in: {{.namespaces}}", out.V{"count": len(ids), "namespaces": strings.Join(namespaces, ", ")})
83-
}
95+
register.Reg.SetStep(register.Done)
96+
if namespaces == nil {
97+
out.T(out.Unpause, "Paused {{.count}} containers", out.V{"count": len(ids)})
98+
} else {
99+
out.T(out.Unpause, "Paused {{.count}} containers in: {{.namespaces}}", out.V{"count": len(ids), "namespaces": strings.Join(namespaces, ", ")})
84100
}
85101
}
86102

cmd/minikube/cmd/start.go

+2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ func platform() string {
124124

125125
// runStart handles the executes the flow of "minikube start"
126126
func runStart(cmd *cobra.Command, args []string) {
127+
register.SetEventLogPath(localpath.EventLog(ClusterFlagValue()))
128+
127129
out.SetJSON(viper.GetString(startOutput) == "json")
128130
displayVersion(version.GetVersion())
129131

0 commit comments

Comments
 (0)