Update vm scripts to handle existing kbuilder user.

PiperOrigin-RevId: 311751972
This commit is contained in:
Adin Scannell
2020-05-15 10:09:54 -07:00
committed by gVisor bot
parent 1847165a8c
commit c5a939d76c
3 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -71,7 +71,7 @@ declare internal=""
declare -r start=$(date +%s)
declare -r end=$((${start}+${timeout}))
while [[ "$(date +%s)" -lt "${end}" ]] && [[ "${success}" -lt 3 ]]; do
echo -n "."
echo -n "." >&2
if gcloud compute ssh --zone "${ZONE}" "${USERNAME}"@"${INSTANCE_NAME}" -- true 2>/dev/null; then
success=$((${success}+1))
elif gcloud compute ssh --internal-ip --zone "${ZONE}" "${USERNAME}"@"${INSTANCE_NAME}" -- true 2>/dev/null; then
+1 -1
View File
@@ -60,7 +60,7 @@ def _vm_image_impl(ctx):
# Run the builder to generate our output.
echo = ctx.actions.declare_file(ctx.label.name)
resolved_inputs, argv, runfiles_manifests = ctx.resolve_command(
command = "echo -ne \"#!/bin/bash\\necho $(%s)\\n\" > %s && chmod 0755 %s" % (
command = "echo -ne \"#!/bin/bash\\nset -e\\nimage=$(%s)\\necho ${image}\\n\" > %s && chmod 0755 %s" % (
ctx.files.builder[0].path,
echo.path,
echo.path,
+8 -8
View File
@@ -43,14 +43,14 @@ done
# junitparser is used to merge junit xml files.
pip install junitparser
# We need a kbuilder user.
if useradd -c "kbuilder user" -m -s /bin/bash kbuilder; then
# User was added successfully; we add the relevant SSH keys here.
mkdir -p ~kbuilder/.ssh
(IFS=$'\n'; echo "${ssh_public_keys[*]}") > ~kbuilder/.ssh/authorized_keys
chmod 0600 ~kbuilder/.ssh/authorized_keys
chown -R kbuilder ~kbuilder/.ssh
fi
# We need a kbuilder user, which may already exist.
useradd -c "kbuilder user" -m -s /bin/bash kbuilder || true
# We need to provision appropriate keys.
mkdir -p ~kbuilder/.ssh
(IFS=$'\n'; echo "${ssh_public_keys[*]}") > ~kbuilder/.ssh/authorized_keys
chmod 0600 ~kbuilder/.ssh/authorized_keys
chown -R kbuilder ~kbuilder/.ssh
# Give passwordless sudo access.
cat > /etc/sudoers.d/kokoro <<EOF