Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recreate existing control plane node correctly #8095

Merged
merged 14 commits into from
May 18, 2020
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
21 changes: 20 additions & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,27 @@ func validateRegistryMirror() {
}
}

func createNode(cc config.ClusterConfig, kubeNodeName string) (config.ClusterConfig, config.Node, error) {
func createNode(cc config.ClusterConfig, kubeNodeName string, existing *config.ClusterConfig) (config.ClusterConfig, config.Node, error) {
// Create the initial node, which will necessarily be a control plane
if existing != nil {
cp, err := config.PrimaryControlPlane(existing)
cp.KubernetesVersion = getKubernetesVersion(&cc)
if err != nil {
return cc, config.Node{}, err
}

// Make sure that existing nodes honor if KubernetesVersion gets specified on restart
// KubernetesVersion is the only attribute that the user can override in the Node object
nodes := []config.Node{}
for _, n := range existing.Nodes {
n.KubernetesVersion = getKubernetesVersion(&cc)
nodes = append(nodes, n)
}
cc.Nodes = nodes

return cc, cp, nil
}

cp := config.Node{
Port: cc.KubernetesConfig.NodePort,
KubernetesVersion: getKubernetesVersion(&cc),
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
if driver.BareMetal(cc.Driver) {
kubeNodeName = "m01"
}
return createNode(cc, kubeNodeName)
return createNode(cc, kubeNodeName, existing)
}

// updateExistingConfigFromFlags will update the existing config from the flags - used on a second start
Expand Down
19 changes: 13 additions & 6 deletions pkg/minikube/download/preload.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,7 @@ func remoteTarballURL(k8sVersion, containerRuntime string) string {
}

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

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

// TODO (#8166): Get rid of the need for this and viper at all
force := false
if len(forcePreload) > 0 {
force = forcePreload[0]
}

// TODO: debug why this func is being called two times
glog.Infof("Checking if preload exists for k8s version %s and runtime %s", k8sVersion, containerRuntime)
if !viper.GetBool("preload") && !force {
return false
}

// Omit remote check if tarball exists locally
targetPath := TarballPath(k8sVersion, containerRuntime)
if _, err := os.Stat(targetPath); err == nil {
Expand Down
3 changes: 1 addition & 2 deletions test/integration/aaa_download_only_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func TestDownloadOnly(t *testing.T) {
t.Run(v, func(t *testing.T) {
defer PostMortemLogs(t, profile)

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

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

// skip for none, as none driver does not have preload feature.
if !NoneDriver() {
if download.PreloadExists(v, r) {
if download.PreloadExists(v, r, true) {
// Just make sure the tarball path exists
if _, err := os.Stat(download.TarballPath(v, r)); err != nil {
t.Errorf("failed to verify preloaded tarball file exists: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func PostMortemLogs(t *testing.T, profile string) {
t.Logf("-----------------------post-mortem--------------------------------")

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