Skip to content

Commit 0019efd

Browse files
committed
Check backwords compatibility with older clusters
1 parent c5f6730 commit 0019efd

File tree

17 files changed

+39
-29
lines changed

17 files changed

+39
-29
lines changed

cmd/minikube/cmd/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func deleteProfile(ctx context.Context, profile *config.Profile) error {
330330
return DeletionError{Err: delErr, Errtype: MissingProfile}
331331
}
332332

333-
if err == nil && (driver.IsNative(cc.Driver) || driver.IsSSH(cc.Driver)) {
333+
if err == nil && (driver.BareMetal(cc.Driver) || driver.IsSSH(cc.Driver)) {
334334
if err := uninstallKubernetes(api, *cc, cc.Nodes[0], viper.GetString(cmdcfg.Bootstrapper)); err != nil {
335335
deletionError, ok := err.(DeletionError)
336336
if ok {

cmd/minikube/cmd/node_add.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var nodeAddCmd = &cobra.Command{
4343
co := mustload.Healthy(ClusterFlagValue())
4444
cc := co.Config
4545

46-
if driver.IsNative(cc.Driver) {
46+
if driver.BareMetal(cc.Driver) {
4747
out.FailureT("native driver does not support multi-node clusters")
4848
}
4949

cmd/minikube/cmd/start.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func startWithDriver(cmd *cobra.Command, starter node.Starter, existing *config.
355355
numNodes = len(existing.Nodes)
356356
}
357357
if numNodes > 1 {
358-
if driver.IsNative(starter.Cfg.Driver) {
358+
if driver.BareMetal(starter.Cfg.Driver) {
359359
exit.Message(reason.DrvUnsupportedMulti, "The native driver is not compatible with multi-node clusters.")
360360
} else {
361361
if existing == nil {
@@ -989,7 +989,7 @@ func validateRequestedMemorySize(req int, drvName string) {
989989
// validateCPUCount validates the cpu count matches the minimum recommended & not exceeding the available cpu count
990990
func validateCPUCount(drvName string) {
991991
var cpuCount int
992-
if driver.IsNative(drvName) {
992+
if driver.BareMetal(drvName) {
993993

994994
// Uses the gopsutil cpu package to count the number of logical cpu cores
995995
ci, err := cpu.Counts(true)
@@ -1106,7 +1106,7 @@ func validateFlags(cmd *cobra.Command, drvName string) {
11061106
}
11071107
}
11081108

1109-
if driver.IsNative(drvName) {
1109+
if driver.BareMetal(drvName) {
11101110
if ClusterFlagValue() != constants.DefaultClusterName {
11111111
exit.Message(reason.DrvUnsupportedProfile, "The '{{.name}} driver does not support multiple profiles: https://minikube.sigs.k8s.io/docs/reference/drivers/none/", out.V{"name": drvName})
11121112
}

cmd/minikube/cmd/start_flags.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
401401
}
402402

403403
var kubeNodeName string
404-
if driver.IsNative(cc.Driver) {
404+
if driver.BareMetal(cc.Driver) {
405405
kubeNodeName = "m01"
406406
}
407407
return createNode(cc, kubeNodeName, existing)
@@ -428,6 +428,14 @@ func upgradeExistingConfig(cc *config.ClusterConfig) {
428428
cc.KicBaseImage = viper.GetString(kicBaseImage)
429429
klog.Infof("config upgrade: KicBaseImage=%s", cc.KicBaseImage)
430430
}
431+
432+
if cc.Driver == driver.AliasNone || cc.VMDriver == driver.AliasNone {
433+
// If a cluster was created before or with minikube v1.17.1 the driver
434+
// name is stored as `none` in the config. We need to change that to
435+
// `native` for future processing.
436+
cc.Driver = driver.Native
437+
cc.VMDriver = driver.Native
438+
}
431439
}
432440

433441
// updateExistingConfigFromFlags will update the existing config from the flags - used on a second start

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
10261026
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
10271027
golang.org/x/mod v0.4.0 h1:8pl+sMODzuvGJkmj2W4kZihvVb5mKm8pB/X44PIQHv8=
10281028
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
1029+
golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY=
10291030
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
10301031
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
10311032
golang.org/x/net v0.0.0-20170915142106-8351a756f30f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -1257,6 +1258,7 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f
12571258
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818 h1:u2ssHESKr0HP2d1wlnjMKH+V/22Vg1lGCVuXmOYU1qA=
12581259
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
12591260
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
1261+
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
12601262
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
12611263
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
12621264
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

pkg/minikube/bootstrapper/kubeadm/kubeadm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func (k *Bootstrapper) init(cfg config.ClusterConfig) error {
208208
klog.Infof("ignoring SystemVerification for kubeadm because of old Kubernetes version %v", version)
209209
skipSystemVerification = true
210210
}
211-
if driver.IsNative(cfg.Driver) && r.Name() == "Docker" {
211+
if driver.BareMetal(cfg.Driver) && r.Name() == "Docker" {
212212
if v, err := r.Version(); err == nil && strings.Contains(v, "azure") {
213213
klog.Infof("ignoring SystemVerification for kubeadm because of unknown docker version %s", v)
214214
skipSystemVerification = true

pkg/minikube/cni/cni.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func chooseDefault(cc config.ClusterConfig) Manager {
125125
return Bridge{cc: cc}
126126
}
127127

128-
if driver.IsNative(cc.Driver) {
128+
if driver.BareMetal(cc.Driver) {
129129
klog.Infof("Driver %s used, CNI unnecessary in this configuration, recommending no CNI", cc.Driver)
130130
return Disabled{cc: cc}
131131
}

pkg/minikube/driver/driver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ func IsMock(name string) bool {
142142

143143
// IsVM checks if the driver is a VM
144144
func IsVM(name string) bool {
145-
if IsKIC(name) || IsNative(name) {
145+
if IsKIC(name) || BareMetal(name) {
146146
return false
147147
}
148148
return true
149149
}
150150

151-
// IsNative returns if this driver is unisolated
152-
func IsNative(name string) bool {
151+
// BareMetal returns if this driver is unisolated
152+
func BareMetal(name string) bool {
153153
return name == Native || name == Mock
154154
}
155155

pkg/minikube/driver/driver_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ func TestSupported(t *testing.T) {
5151
}
5252

5353
func TestBareMetal(t *testing.T) {
54-
if !IsNative(Native) {
54+
if !BareMetal(Native) {
5555
t.Errorf("Supported(%s) is false", Native)
5656
}
57-
if IsNative(VirtualBox) {
57+
if BareMetal(VirtualBox) {
5858
t.Errorf("Supported(%s) is true", VirtualBox)
5959
}
6060
}

pkg/minikube/machine/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func CommandRunner(h *host.Host) (command.Runner, error) {
156156
if h.DriverName == driver.Mock {
157157
return &command.FakeCommandRunner{}, nil
158158
}
159-
if driver.IsNative(h.Driver.DriverName()) {
159+
if driver.BareMetal(h.Driver.DriverName()) {
160160
return command.NewExecRunner(true), nil
161161
}
162162

@@ -220,7 +220,7 @@ func (api *LocalClient) Create(h *host.Host) error {
220220
{
221221
"waiting",
222222
func() error {
223-
if driver.IsNative(h.Driver.DriverName()) {
223+
if driver.BareMetal(h.Driver.DriverName()) {
224224
return nil
225225
}
226226
return mcnutils.WaitFor(drivers.MachineInState(h.Driver, state.Running))
@@ -230,7 +230,7 @@ func (api *LocalClient) Create(h *host.Host) error {
230230
"provisioning",
231231
func() error {
232232
// Skippable because we don't reconfigure Docker?
233-
if driver.IsNative(h.Driver.DriverName()) {
233+
if driver.BareMetal(h.Driver.DriverName()) {
234234
return nil
235235
}
236236
return provisionDockerMachine(h)

0 commit comments

Comments
 (0)