Fix kubetest2 panic inheriting env vars

Fixes `panic: runtime error: slice bounds out of range [:-1]` found here: https://prow.k8s.io/view/gs/kubernetes-jenkins/logs/e2e-kops-grid-scenario-aws-cloud-controller-manager/1387534126441041920

Also fixes a logging statement to include the cluster name (empty cluster name is seen in those same logs)
This commit is contained in:
Peter Rifel 2021-04-28 21:44:45 -05:00
parent a42edc4f0d
commit 6afaaa3161
No known key found for this signature in database
GPG Key ID: BC6469E5B16DB2B6
1 changed files with 6 additions and 3 deletions

View File

@ -123,8 +123,11 @@ func (d *deployer) initialize() error {
for _, envvar := range d.env() {
// Set all of the env vars we use for kops in the current process
// so that the tester inherits them when shelling out to kops
i := strings.Index(envvar, "=")
os.Setenv(envvar[0:i], envvar[i+1:])
if i := strings.Index(envvar, "="); i != -1 {
os.Setenv(envvar[0:i], envvar[i+1:])
} else {
os.Setenv(envvar, "")
}
}
}
return nil
@ -137,7 +140,7 @@ func (d *deployer) verifyKopsFlags() error {
if err != nil {
return err
}
klog.Info("Using cluster name ", d.ClusterName)
klog.Infof("Using cluster name: %v", d.ClusterName)
d.ClusterName = name
}