From c0b4de5feb67f140cc55c7acd0912d6579ad6968 Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 27 Oct 2021 23:36:30 -0400 Subject: [PATCH 1/2] kubetest2: force printing of the plan on cluster creation When we run create with --yes, we skip printing the plan. Instead, we run a "normal" create, and then run an update. We don't touch the terraform case, as there may be issues here and we want to tackle those separately. --- tests/e2e/kubetest2-kops/deployer/up.go | 45 ++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/tests/e2e/kubetest2-kops/deployer/up.go b/tests/e2e/kubetest2-kops/deployer/up.go index 07c0323b26..091825b28c 100644 --- a/tests/e2e/kubetest2-kops/deployer/up.go +++ b/tests/e2e/kubetest2-kops/deployer/up.go @@ -79,9 +79,19 @@ func (d *deployer) Up() error { return err } } else { - err := d.createCluster(zones, adminAccess) - if err != nil { - return err + if d.terraform != nil { + if err := d.createCluster(zones, adminAccess, true); err != nil { + return err + } + } else { + // For the non-terraform case, we want to see the preview output. + // So run a create (which logs the output), then do an update + if err := d.createCluster(zones, adminAccess, false); err != nil { + return err + } + if err := d.updateCluster(true); err != nil { + return err + } } } isUp, err := d.IsUp() @@ -95,7 +105,7 @@ func (d *deployer) Up() error { return nil } -func (d *deployer) createCluster(zones []string, adminAccess string) error { +func (d *deployer) createCluster(zones []string, adminAccess string, yes bool) error { args := []string{ d.KopsBinaryPath, "create", "cluster", @@ -104,7 +114,9 @@ func (d *deployer) createCluster(zones []string, adminAccess string) error { "--kubernetes-version", d.KubernetesVersion, "--ssh-public-key", d.SSHPublicKeyPath, "--override", "cluster.spec.nodePortAccess=0.0.0.0/0", - "--yes", + } + if yes { + args = append(args, "--yes") } if d.CreateArgs != "" { @@ -161,6 +173,29 @@ func (d *deployer) createCluster(zones []string, adminAccess string) error { return nil } +func (d *deployer) updateCluster(yes bool) error { + + args := []string{ + d.KopsBinaryPath, "update", "cluster", + "--name", d.ClusterName, + } + if yes { + args = append(args, "--yes") + } + + klog.Info(strings.Join(args, " ")) + cmd := exec.Command(args[0], args[1:]...) + cmd.SetEnv(d.env()...) + + exec.InheritOutput(cmd) + err := cmd.Run() + if err != nil { + return err + } + + return nil +} + func (d *deployer) IsUp() (bool, error) { wait := d.ValidationWait if wait == 0 { From 6c14d0f6ef431dd64f6e0b0027de465252bf9af8 Mon Sep 17 00:00:00 2001 From: justinsb Date: Thu, 28 Oct 2021 08:36:05 -0400 Subject: [PATCH 2/2] kubetest2: Add --admin flag to update --- tests/e2e/kubetest2-kops/deployer/up.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/kubetest2-kops/deployer/up.go b/tests/e2e/kubetest2-kops/deployer/up.go index 091825b28c..7411379dd3 100644 --- a/tests/e2e/kubetest2-kops/deployer/up.go +++ b/tests/e2e/kubetest2-kops/deployer/up.go @@ -178,6 +178,7 @@ func (d *deployer) updateCluster(yes bool) error { args := []string{ d.KopsBinaryPath, "update", "cluster", "--name", d.ClusterName, + "--admin", } if yes { args = append(args, "--yes")