mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-11-03 23:40:03 +00:00 
			
		
		
		
	Support set user with --ssh-user flag when running remote node e2e.
				
					
				
			This commit is contained in:
		@@ -41,9 +41,9 @@ TIMEOUT=${TIMEOUT:-"45m"}
 | 
			
		||||
 | 
			
		||||
mkdir -p ${ARTIFACTS}
 | 
			
		||||
 | 
			
		||||
go run test/e2e_node/runner/remote/run_remote.go  --logtostderr --vmodule=*=4 --ssh-env="gce" \
 | 
			
		||||
  --zone="$GCE_ZONE" --project="$GCE_PROJECT" --hosts="$GCE_HOSTS" \
 | 
			
		||||
  --images="$GCE_IMAGES" --image-project="$GCE_IMAGE_PROJECT" \
 | 
			
		||||
go run test/e2e_node/runner/remote/run_remote.go  --logtostderr --vmodule=*=4 \
 | 
			
		||||
  --ssh-env="gce" --ssh-user="$GCE_USER" --zone="$GCE_ZONE" --project="$GCE_PROJECT" \
 | 
			
		||||
  --hosts="$GCE_HOSTS" --images="$GCE_IMAGES" --image-project="$GCE_IMAGE_PROJECT" \
 | 
			
		||||
  --image-config-file="$GCE_IMAGE_CONFIG_PATH" --cleanup="$CLEANUP" \
 | 
			
		||||
  --results-dir="$ARTIFACTS" --ginkgo-flags="--nodes=$PARALLELISM $GINKGO_FLAGS" \
 | 
			
		||||
  --test-timeout="$TIMEOUT" --test_args="$TEST_ARGS --kubelet-flags=\"$KUBELET_ARGS\"" \
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,6 @@
 | 
			
		||||
# Copy this file to your home directory and modify
 | 
			
		||||
# User used on the gce instances to run the test.
 | 
			
		||||
GCE_USER=
 | 
			
		||||
# Path to a yaml or json file describing images to run or empty
 | 
			
		||||
GCE_IMAGE_CONFIG_PATH=
 | 
			
		||||
# Names of gce hosts to test against (must be resolvable) or empty
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,7 @@ import (
 | 
			
		||||
 | 
			
		||||
var sshOptions = flag.String("ssh-options", "", "Commandline options passed to ssh.")
 | 
			
		||||
var sshEnv = flag.String("ssh-env", "", "Use predefined ssh options for environment.  Options: gce")
 | 
			
		||||
var sshUser = flag.String("ssh-user", "", "Use predefined user for ssh.")
 | 
			
		||||
 | 
			
		||||
var sshOptionsMap map[string]string
 | 
			
		||||
 | 
			
		||||
@@ -53,13 +54,18 @@ func AddHostnameIp(hostname, ip string) {
 | 
			
		||||
	hostnameIpOverrides.m[hostname] = ip
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetHostnameOrIp converts hostname into ip and apply user if necessary.
 | 
			
		||||
func GetHostnameOrIp(hostname string) string {
 | 
			
		||||
	hostnameIpOverrides.RLock()
 | 
			
		||||
	defer hostnameIpOverrides.RUnlock()
 | 
			
		||||
	host := hostname
 | 
			
		||||
	if ip, found := hostnameIpOverrides.m[hostname]; found {
 | 
			
		||||
		return ip
 | 
			
		||||
		host = ip
 | 
			
		||||
	}
 | 
			
		||||
	return hostname
 | 
			
		||||
	if *sshUser != "" {
 | 
			
		||||
		host = fmt.Sprintf("%s@%s", *sshUser, host)
 | 
			
		||||
	}
 | 
			
		||||
	return host
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getSSHCommand handles proper quoting so that multiple commands are executed in the same shell over ssh
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user