diff --git a/kubetest2-gce/deployer/common.go b/kubetest2-gce/deployer/common.go index 63f9fc56..f09bf5e4 100644 --- a/kubetest2-gce/deployer/common.go +++ b/kubetest2-gce/deployer/common.go @@ -107,12 +107,11 @@ func (d *deployer) buildEnv() []string { // which is by default disabled on GCE VMs if USER is root. In order // for the deployer to work without fuss when run as root (like it // does by default in Prow) we can simply change USER to be something - // non-root. USER is not always set in a given environment, so the UID - // is checked instead for guaranteed correct information. - if uid := os.Getuid(); uid == 0 { - env = append(env, fmt.Sprintf("USER=%s", "kubetest2")) + // non-root. + if user, ok := os.LookupEnv("USER"); ok && user != "root" { + env = append(env, fmt.Sprintf("USER=%s", user)) } else { - env = append(env, fmt.Sprintf("USER=%s", os.Getenv("USER"))) + env = append(env, fmt.Sprintf("USER=%s", "kubetest2")) } // kube-up.sh, kube-down.sh etc. use PROJECT as a parameter