Skip to content

Commit 2754bb6

Browse files
authoredMay 18, 2020
Merge pull request #8095 from sharifelgamal/create-node
recreate existing control plane node correctly
2 parents 02cee02 + 4cbeb18 commit 2754bb6

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed
 

‎cmd/minikube/cmd/start.go

+20-1
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,27 @@ func validateRegistryMirror() {
877877
}
878878
}
879879

880-
func createNode(cc config.ClusterConfig, kubeNodeName string) (config.ClusterConfig, config.Node, error) {
880+
func createNode(cc config.ClusterConfig, kubeNodeName string, existing *config.ClusterConfig) (config.ClusterConfig, config.Node, error) {
881881
// Create the initial node, which will necessarily be a control plane
882+
if existing != nil {
883+
cp, err := config.PrimaryControlPlane(existing)
884+
cp.KubernetesVersion = getKubernetesVersion(&cc)
885+
if err != nil {
886+
return cc, config.Node{}, err
887+
}
888+
889+
// Make sure that existing nodes honor if KubernetesVersion gets specified on restart
890+
// KubernetesVersion is the only attribute that the user can override in the Node object
891+
nodes := []config.Node{}
892+
for _, n := range existing.Nodes {
893+
n.KubernetesVersion = getKubernetesVersion(&cc)
894+
nodes = append(nodes, n)
895+
}
896+
cc.Nodes = nodes
897+
898+
return cc, cp, nil
899+
}
900+
882901
cp := config.Node{
883902
Port: cc.KubernetesConfig.NodePort,
884903
KubernetesVersion: getKubernetesVersion(&cc),

‎cmd/minikube/cmd/start_flags.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
348348
if driver.BareMetal(cc.Driver) {
349349
kubeNodeName = "m01"
350350
}
351-
return createNode(cc, kubeNodeName)
351+
return createNode(cc, kubeNodeName, existing)
352352
}
353353

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

‎pkg/minikube/download/preload.go

+13-6
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ func remoteTarballURL(k8sVersion, containerRuntime string) string {
7676
}
7777

7878
// PreloadExists returns true if there is a preloaded tarball that can be used
79-
func PreloadExists(k8sVersion, containerRuntime string) bool {
80-
// TODO: debug why this func is being called two times
81-
glog.Infof("Checking if preload exists for k8s version %s and runtime %s", k8sVersion, containerRuntime)
82-
if !viper.GetBool("preload") {
83-
return false
84-
}
79+
func PreloadExists(k8sVersion, containerRuntime string, forcePreload ...bool) bool {
8580

8681
// and https://github.com/kubernetes/minikube/issues/6934
8782
// to track status of adding crio
@@ -90,6 +85,18 @@ func PreloadExists(k8sVersion, containerRuntime string) bool {
9085
return false
9186
}
9287

88+
// TODO (#8166): Get rid of the need for this and viper at all
89+
force := false
90+
if len(forcePreload) > 0 {
91+
force = forcePreload[0]
92+
}
93+
94+
// TODO: debug why this func is being called two times
95+
glog.Infof("Checking if preload exists for k8s version %s and runtime %s", k8sVersion, containerRuntime)
96+
if !viper.GetBool("preload") && !force {
97+
return false
98+
}
99+
93100
// Omit remote check if tarball exists locally
94101
targetPath := TarballPath(k8sVersion, containerRuntime)
95102
if _, err := os.Stat(targetPath); err == nil {

‎test/integration/aaa_download_only_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ func TestDownloadOnly(t *testing.T) {
5757
t.Run(v, func(t *testing.T) {
5858
defer PostMortemLogs(t, profile)
5959

60-
// Explicitly does not pass StartArgs() to test driver default
6160
// --force to avoid uid check
6261
args := append([]string{"start", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v), fmt.Sprintf("--container-runtime=%s", r)}, StartArgs()...)
6362

@@ -74,7 +73,7 @@ func TestDownloadOnly(t *testing.T) {
7473

7574
// skip for none, as none driver does not have preload feature.
7675
if !NoneDriver() {
77-
if download.PreloadExists(v, r) {
76+
if download.PreloadExists(v, r, true) {
7877
// Just make sure the tarball path exists
7978
if _, err := os.Stat(download.TarballPath(v, r)); err != nil {
8079
t.Errorf("failed to verify preloaded tarball file exists: %v", err)

‎test/integration/helpers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func PostMortemLogs(t *testing.T, profile string) {
203203
t.Logf("-----------------------post-mortem--------------------------------")
204204

205205
if DockerDriver() {
206-
t.Logf("======> post-mortem[%s]: docker inpect <======", t.Name())
206+
t.Logf("======> post-mortem[%s]: docker inspect <======", t.Name())
207207
rr, err := Run(t, exec.Command("docker", "inspect", profile))
208208
if err != nil {
209209
t.Logf("failed to get docker inspect: %v", err)

0 commit comments

Comments
 (0)
Please sign in to comment.