Merge pull request #12624 from justinsb/up_show_plan

kubetest2: force printing of the plan on cluster creation
This commit is contained in:
Kubernetes Prow Robot 2021-10-28 07:20:27 -07:00 committed by GitHub
commit f61fc88ec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 41 additions and 5 deletions

View File

@ -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 != "" {
@ -160,6 +172,30 @@ 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,
"--admin",
}
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 {