This repository has been archived by the owner on Mar 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testrunner: implement cluster provisioning support
We break out the provisioning part into its own script so that we can more easily provision multiple hosts simultaneously. We also make sure that SSH is all set up so that users can just directly start SSH'ing between nodes.
- Loading branch information
Showing
9 changed files
with
389 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,8 @@ main() { | |
exit 0 | ||
fi | ||
|
||
export PYTHONUNBUFFERED=1 | ||
|
||
exec $THIS_DIR/spawner.py | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#!/bin/bash | ||
set -Exeuo pipefail | ||
|
||
# This script provisions a node on OpenStack. It may be | ||
# called multiple times in parallel. | ||
|
||
THIS_DIR=$(dirname $0) | ||
|
||
source $THIS_DIR/utils/common.sh | ||
|
||
main() { | ||
|
||
# NB: see the various NBs in the main() of main. | ||
|
||
state=$1; shift | ||
parsedhost=$1; shift | ||
outdir=$1; shift | ||
|
||
[ -d $parsedhost ] | ||
mkdir $outdir | ||
|
||
provision_host | ||
} | ||
|
||
provision_host() { | ||
|
||
# XXX: We hardcode m1.small for now, but these really | ||
# should be specified indirectly from the .redhat-ci | ||
# YAML file through e.g. min-* vars. | ||
env \ | ||
os_image="$(cat $parsedhost/distro)" \ | ||
os_flavor=m1.small \ | ||
os_name_prefix=github-ci-testnode \ | ||
os_user_data="$THIS_DIR/utils/user-data" \ | ||
"$THIS_DIR/utils/os_provision.py" $outdir | ||
|
||
ssh_wait $(cat $outdir/node_addr) $state/node_key | ||
|
||
if [ -f $parsedhost/ostree_revision ]; then | ||
if ! on_atomic_host; then | ||
update_github error "Cannot specify 'ostree' on non-AH." | ||
touch $state/exit # signal testrunner to exit nicely | ||
exit 0 | ||
fi | ||
deploy_ostree | ||
fi | ||
} | ||
|
||
deploy_ostree() { | ||
local remote=$(cat $parsedhost/ostree_remote) | ||
local branch=$(cat $parsedhost/ostree_branch) | ||
local revision=$(cat $parsedhost/ostree_revision) | ||
|
||
local rc=0 | ||
local skip_reboot=0 | ||
if [ -z "$remote" ] && [ -z "$branch" ]; then | ||
|
||
if [ -z "$revision" ]; then | ||
vmssh rpm-ostree upgrade --upgrade-unchanged-exit-77 || rc=$? | ||
else | ||
vmssh rpm-ostree deploy "$revision" || rc=$? | ||
fi | ||
|
||
if [ $rc == 77 ]; then | ||
skip_reboot=1 | ||
elif [ $rc != 0 ]; then | ||
update_github error "Failed to upgrade or deploy." | ||
touch $state/exit # signal testrunner to exit nicely | ||
exit 0 | ||
fi | ||
else | ||
local refspec | ||
|
||
if [ -n "$remote" ]; then | ||
vmssh ostree remote add --no-gpg-verify rhci "$remote" | ||
refspec=rhci: | ||
fi | ||
|
||
if [ -n "$branch" ]; then | ||
refspec="${refspec}$branch" | ||
fi | ||
|
||
if vmssh rpm-ostree rebase "$refspec"; then | ||
update_github error "Failed to rebase onto refspec." | ||
touch $state/exit # signal testrunner to exit nicely | ||
exit 0 | ||
fi | ||
|
||
if [ -n "$revision" ]; then | ||
# we should really be able to do this in a single step | ||
# https://github.com/projectatomic/rpm-ostree/issues/212 | ||
vmreboot | ||
vmssh rpm-ostree deploy "$revision" || rc=$? | ||
|
||
if [ $rc == 77 ]; then | ||
skip_reboot=1 | ||
elif [ $rc != 0 ]; then | ||
update_github error "Failed to upgrade or deploy." | ||
touch $state/exit # signal testrunner to exit nicely | ||
exit 0 | ||
fi | ||
fi | ||
fi | ||
|
||
if [ $skip_reboot != 1 ]; then | ||
vmreboot | ||
fi | ||
} | ||
|
||
update_github() { | ||
local context=$(cat $state/parsed/context) | ||
common_update_github "$context" "$@" | ||
} | ||
|
||
vmssh() { | ||
ssh -q -n -i $state/node_key \ | ||
-o StrictHostKeyChecking=no \ | ||
-o PasswordAuthentication=no \ | ||
-o UserKnownHostsFile=/dev/null \ | ||
root@$(cat $outdir/node_addr) "$@" | ||
} | ||
|
||
vmreboot() { | ||
vmssh systemctl reboot || : | ||
sleep 3 # give time for port to go down | ||
ssh_wait $(cat $outdir/node_addr) $state/node_key | ||
} | ||
|
||
on_atomic_host() { | ||
vmssh test -f /run/ostree-booted | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.