Skip to content

Commit

Permalink
Temporary patch for incorrect test user key file ownership
Browse files Browse the repository at this point in the history
When we create test VMs, we include an SSH pubkey for a test user as metadata.
The guest agent sees this and creates a system user (with a
`~/.ssh/authorized_keys` file holding the key we defined) accordingly. On some
DLVM images, the `~/.ssh/authorized_keys` file subsequently gets its ownership
attributes corrupted during startup. This prevents us from being able to SSH
into the VM for the remainder of the test.

This change deploys a workaround that manually patches over the corruption at
VM startup.
  • Loading branch information
jefferbrecht committed Nov 28, 2024
1 parent 1a21b8f commit 2662063
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions integration_test/gce/gce_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,25 @@ func addFrameworkMetadata(imageSpec string, inputMetadata map[string]string) (ma
if _, ok := metadataCopy["startup-script"]; ok {
return nil, errors.New("the 'startup-script' metadata key is reserved for future use. Instead, wait for the instance to be ready and then run things with RunRemotely() or RunScriptRemotely()")
}
// TODO(b/380470389): we actually *can't* do RunRemotely() on DLVM images due to a bug.
// The workaround for the bug is to deploy a fix in-VM via startup scripts.
if strings.Contains(imageSpec, "common-gpu-debian-11-py310") {
metadataCopy["startup-script"] = fmt.Sprintf(`
#!/bin/bash
# Give time for the guest agent and jupyter stuff to finish modifying
# /etc/passwd and test_user home directory
sleep 120
HOMEDIR=/home/%[1]s
SSHFILE=$HOMEDIR/.ssh/authorized_keys
if [ ! -f "$SSHFILE" ]; then
sudo mkdir -p "$HOMEDIR/.ssh"
sudo touch "$SSHFILE"
fi
sudo chown -R %[1]s:%[1]s "$HOMEDIR"
sudo chmod 600 "$SSHFILE"`,
sshUserName,
)
}
}
return metadataCopy, nil
}
Expand Down

0 comments on commit 2662063

Please sign in to comment.