Skip to content

Commit 1955ed6

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#39074 from Random-Liu/node-e2e-set-user
Automatic merge from submit-queue Node E2E: Set user with `--ssh-user` flag when running remote node e2e. This PR unblocks kubernetes/test-infra#1348. In our test environment, we must login test instance as user `jenkins` because of the service account. Node e2e is always using the default user on the host, which works fine till now, because it is always run as `jenkins` in our test environment. However, now we moved the test runner into a docker container, inside the container user is `root` by default, which will cause error: ``` Permission denied (publickey) ``` This PR added a flag `--ssh-user` to explicitly specify the user used to ssh into test instance. The dockerized test runner can set user to `jenkins` with this flag. @krzyzacy @ixdy
2 parents 744876d + 10f72be commit 1955ed6

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Diff for: test/e2e_node/jenkins/e2e-node-jenkins.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ TIMEOUT=${TIMEOUT:-"45m"}
4141

4242
mkdir -p ${ARTIFACTS}
4343

44-
go run test/e2e_node/runner/remote/run_remote.go --logtostderr --vmodule=*=4 --ssh-env="gce" \
45-
--zone="$GCE_ZONE" --project="$GCE_PROJECT" --hosts="$GCE_HOSTS" \
46-
--images="$GCE_IMAGES" --image-project="$GCE_IMAGE_PROJECT" \
44+
go run test/e2e_node/runner/remote/run_remote.go --logtostderr --vmodule=*=4 \
45+
--ssh-env="gce" --ssh-user="$GCE_USER" --zone="$GCE_ZONE" --project="$GCE_PROJECT" \
46+
--hosts="$GCE_HOSTS" --images="$GCE_IMAGES" --image-project="$GCE_IMAGE_PROJECT" \
4747
--image-config-file="$GCE_IMAGE_CONFIG_PATH" --cleanup="$CLEANUP" \
4848
--results-dir="$ARTIFACTS" --ginkgo-flags="--nodes=$PARALLELISM $GINKGO_FLAGS" \
4949
--test-timeout="$TIMEOUT" --test_args="$TEST_ARGS --kubelet-flags=\"$KUBELET_ARGS\"" \

Diff for: test/e2e_node/jenkins/template.properties

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Copy this file to your home directory and modify
2+
# User used on the gce instances to run the test.
3+
GCE_USER=
24
# Path to a yaml or json file describing images to run or empty
35
GCE_IMAGE_CONFIG_PATH=
46
# Names of gce hosts to test against (must be resolvable) or empty

Diff for: test/e2e_node/remote/ssh.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929

3030
var sshOptions = flag.String("ssh-options", "", "Commandline options passed to ssh.")
3131
var sshEnv = flag.String("ssh-env", "", "Use predefined ssh options for environment. Options: gce")
32+
var sshUser = flag.String("ssh-user", "", "Use predefined user for ssh.")
3233

3334
var sshOptionsMap map[string]string
3435

@@ -53,13 +54,18 @@ func AddHostnameIp(hostname, ip string) {
5354
hostnameIpOverrides.m[hostname] = ip
5455
}
5556

57+
// GetHostnameOrIp converts hostname into ip and apply user if necessary.
5658
func GetHostnameOrIp(hostname string) string {
5759
hostnameIpOverrides.RLock()
5860
defer hostnameIpOverrides.RUnlock()
61+
host := hostname
5962
if ip, found := hostnameIpOverrides.m[hostname]; found {
60-
return ip
63+
host = ip
6164
}
62-
return hostname
65+
if *sshUser != "" {
66+
host = fmt.Sprintf("%s@%s", *sshUser, host)
67+
}
68+
return host
6369
}
6470

6571
// getSSHCommand handles proper quoting so that multiple commands are executed in the same shell over ssh

0 commit comments

Comments
 (0)