Add grenade job
This patch set adds grenade support to Watcher based on legacy-dsvm-base job. Change-Id: I9e23f59f7415aa350b2da644d8801621533b69b0
This commit is contained in:
committed by
Alexander Chadin
parent
90c8525ccb
commit
103e5b5605
@@ -289,6 +289,7 @@ function start_watcher_api {
|
||||
service_protocol="http"
|
||||
fi
|
||||
if [[ "$WATCHER_USE_MOD_WSGI" == "True" ]]; then
|
||||
enable_apache_site watcher-api
|
||||
restart_apache_server
|
||||
else
|
||||
run_process watcher-api "$WATCHER_BIN_DIR/watcher-api --config-file $WATCHER_CONF"
|
||||
@@ -318,7 +319,7 @@ function start_watcher {
|
||||
function stop_watcher {
|
||||
if [[ "$WATCHER_USE_MOD_WSGI" == "True" ]]; then
|
||||
disable_apache_site watcher-api
|
||||
restart_apache_server
|
||||
restart_apache_server
|
||||
else
|
||||
stop_process watcher-api
|
||||
fi
|
||||
|
||||
15
devstack/upgrade/from_rocky/upgrade-watcher
Normal file
15
devstack/upgrade/from_rocky/upgrade-watcher
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ``upgrade-watcher``
|
||||
|
||||
function configure_watcher_upgrade {
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set -o xtrace
|
||||
|
||||
# Copy release-specific files
|
||||
sudo cp $TARGET_RELEASE_DIR/watcher/etc/watcher/watcher.conf $WATCHER_CONF_DIR/watcher.conf
|
||||
sudo cp $TARGET_RELEASE_DIR/watcher/etc/watcher/policy.yaml.sample $WATCHER_CONF_DIR/policy.yaml.sample
|
||||
|
||||
# reset to previous state
|
||||
$XTRACE
|
||||
}
|
||||
126
devstack/upgrade/resources.sh
Executable file
126
devstack/upgrade/resources.sh
Executable file
@@ -0,0 +1,126 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
|
||||
source $GRENADE_DIR/grenaderc
|
||||
source $GRENADE_DIR/functions
|
||||
|
||||
source $TOP_DIR/openrc admin demo
|
||||
|
||||
set -o xtrace
|
||||
|
||||
function _wait_for_status {
|
||||
while :
|
||||
do
|
||||
state=$("${@:2}" -f value -c State)
|
||||
[[ $state == "SUCCEEDED" ]] && break
|
||||
if [ $state == "ERROR" ]; then
|
||||
die $LINENO "ERROR creating audit"
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
}
|
||||
|
||||
function create_audit_template {
|
||||
at_id=$(openstack optimize audittemplate create d1 dummy -s dummy -f value -c UUID)
|
||||
resource_save watcher at_id $at_id
|
||||
}
|
||||
|
||||
function create_audit {
|
||||
audit_id=$(openstack optimize audit create -s dummy -g dummy -f value -c UUID)
|
||||
resource_save watcher audit_id $audit_id
|
||||
}
|
||||
|
||||
function create_audit_with_autotrigger {
|
||||
audit_at_id=$(openstack optimize audit create -s dummy -g dummy -f value -c UUID --auto-trigger)
|
||||
resource_save watcher audit_at_id $audit_at_id
|
||||
}
|
||||
|
||||
function verify_audit_template {
|
||||
local at_id=$(resource_get watcher at_id)
|
||||
openstack optimize audittemplate show $at_id
|
||||
}
|
||||
|
||||
function verify_audit_with_autotrigger {
|
||||
local audit_at_id=$(resource_get watcher audit_at_id)
|
||||
_wait_for_status "SUCCEEDED" openstack optimize audit show $audit_at_id
|
||||
local actionplan_at_id=$(openstack optimize actionplan list --audit $audit_at_id -c UUID -f value)
|
||||
resource_save watcher actionplan_at $actionplan_at_id
|
||||
actionplan_at_state=$(openstack optimize actionplan show $actionplan_at_id -c State -f value)
|
||||
if [ $actionplan_at_state != "SUCCEEDED" ]; then
|
||||
die $LINENO "ERROR executing actionplan"
|
||||
fi
|
||||
}
|
||||
|
||||
function verify_audit {
|
||||
local audit_id=$(resource_get watcher audit_id)
|
||||
_wait_for_status "SUCCEEDED" openstack optimize audit show $audit_id
|
||||
local actionplan_id=$(openstack optimize actionplan list --audit $audit_id -c UUID -f value)
|
||||
resource_save watcher actionplan $actionplan_id
|
||||
actionplan_state=$(openstack optimize actionplan show $actionplan_id -c State -f value)
|
||||
if [ $actionplan_state != "RECOMMENDED" ]; then
|
||||
die $LINENO "ERROR creating actionplan"
|
||||
fi
|
||||
}
|
||||
|
||||
function verify_noapi {
|
||||
# currently no good way
|
||||
:
|
||||
}
|
||||
|
||||
function delete_audit {
|
||||
local audit_id=$(resource_get watcher audit_id)
|
||||
local actionplan_id=$(resource_get watcher actionplan)
|
||||
watcher actionplan delete $actionplan_id
|
||||
openstack optimize audit delete $audit_id
|
||||
}
|
||||
|
||||
function delete_audit_with_autotrigger {
|
||||
local audit_at_id=$(resource_get watcher audit_at_id)
|
||||
local actionplan_id=$(resource_get watcher actionplan_at)
|
||||
watcher actionplan delete $actionplan_id
|
||||
openstack optimize audit delete $audit_at_id
|
||||
}
|
||||
|
||||
function delete_audit_template {
|
||||
local at_id=$(resource_get watcher at_id)
|
||||
openstack optimize audittemplate delete $at_id
|
||||
}
|
||||
|
||||
function create {
|
||||
create_audit_template
|
||||
create_audit
|
||||
create_audit_with_autotrigger
|
||||
}
|
||||
|
||||
function verify {
|
||||
verify_audit_template
|
||||
verify_audit
|
||||
verify_audit_with_autotrigger
|
||||
}
|
||||
|
||||
function destroy {
|
||||
delete_audit_template
|
||||
delete_audit
|
||||
delete_audit_with_autotrigger
|
||||
}
|
||||
|
||||
# Dispatcher
|
||||
case $1 in
|
||||
"create")
|
||||
create
|
||||
;;
|
||||
"verify_noapi")
|
||||
verify_noapi
|
||||
;;
|
||||
"verify")
|
||||
verify
|
||||
;;
|
||||
"destroy")
|
||||
destroy
|
||||
;;
|
||||
"force_destroy")
|
||||
set +o errexit
|
||||
destroy
|
||||
;;
|
||||
esac
|
||||
11
devstack/upgrade/settings
Normal file
11
devstack/upgrade/settings
Normal file
@@ -0,0 +1,11 @@
|
||||
register_project_for_upgrade watcher
|
||||
register_db_to_save watcher
|
||||
|
||||
devstack_localrc base enable_plugin watcher https://git.openstack.org/openstack/watcher stable/rocky
|
||||
devstack_localrc target enable_plugin watcher https://git.openstack.org/openstack/watcher
|
||||
|
||||
devstack_localrc base enable_service watcher-api watcher-decision-engine watcher-applier
|
||||
devstack_localrc target enable_service watcher-api watcher-decision-engine watcher-applier
|
||||
|
||||
BASE_RUN_SMOKE=False
|
||||
TARGET_RUN_SMOKE=False
|
||||
24
devstack/upgrade/shutdown.sh
Executable file
24
devstack/upgrade/shutdown.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
|
||||
source $GRENADE_DIR/grenaderc
|
||||
source $GRENADE_DIR/functions
|
||||
|
||||
# We need base DevStack functions for this
|
||||
source $BASE_DEVSTACK_DIR/functions
|
||||
source $BASE_DEVSTACK_DIR/stackrc # needed for status directory
|
||||
source $BASE_DEVSTACK_DIR/lib/tls
|
||||
source $BASE_DEVSTACK_DIR/lib/apache
|
||||
|
||||
WATCHER_DEVSTACK_DIR=$(dirname $(dirname $0))
|
||||
source $WATCHER_DEVSTACK_DIR/settings
|
||||
source $WATCHER_DEVSTACK_DIR/plugin.sh
|
||||
source $WATCHER_DEVSTACK_DIR/lib/watcher
|
||||
|
||||
set -o xtrace
|
||||
|
||||
stop_watcher
|
||||
|
||||
# sanity check that service is actually down
|
||||
ensure_services_stopped watcher-api watcher-decision-engine watcher-applier
|
||||
70
devstack/upgrade/upgrade.sh
Executable file
70
devstack/upgrade/upgrade.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ``upgrade-watcher``
|
||||
|
||||
echo "*********************************************************************"
|
||||
echo "Begin $0"
|
||||
echo "*********************************************************************"
|
||||
|
||||
# Clean up any resources that may be in use
|
||||
cleanup() {
|
||||
set +o errexit
|
||||
|
||||
echo "********************************************************************"
|
||||
echo "ERROR: Abort $0"
|
||||
echo "********************************************************************"
|
||||
|
||||
# Kill ourselves to signal any calling process
|
||||
trap 2; kill -2 $$
|
||||
}
|
||||
|
||||
trap cleanup SIGHUP SIGINT SIGTERM
|
||||
|
||||
# Keep track of the grenade directory
|
||||
RUN_DIR=$(cd $(dirname "$0") && pwd)
|
||||
|
||||
# Source params
|
||||
source $GRENADE_DIR/grenaderc
|
||||
|
||||
# Import common functions
|
||||
source $GRENADE_DIR/functions
|
||||
|
||||
# This script exits on an error so that errors don't compound and you see
|
||||
# only the first error that occurred.
|
||||
set -o errexit
|
||||
|
||||
# Upgrade watcher
|
||||
# ============
|
||||
|
||||
# Get functions from current DevStack
|
||||
source $TARGET_DEVSTACK_DIR/stackrc
|
||||
source $TARGET_DEVSTACK_DIR/lib/apache
|
||||
source $TARGET_DEVSTACK_DIR/lib/tls
|
||||
source $(dirname $(dirname $BASH_SOURCE))/settings
|
||||
source $(dirname $(dirname $BASH_SOURCE))/plugin.sh
|
||||
|
||||
# Print the commands being run so that we can see the command that triggers
|
||||
# an error. It is also useful for following allowing as the install occurs.
|
||||
set -o xtrace
|
||||
|
||||
# Save current config files for posterity
|
||||
[[ -d $SAVE_DIR/etc.watcher ]] || cp -pr $WATCHER_CONF_DIR $SAVE_DIR/etc.watcher
|
||||
|
||||
# Install the target watcher
|
||||
install_watcher
|
||||
|
||||
# calls upgrade-watcher for specific release
|
||||
upgrade_project watcher $RUN_DIR $BASE_DEVSTACK_BRANCH $TARGET_DEVSTACK_BRANCH
|
||||
|
||||
# Migrate the database
|
||||
watcher-db-manage upgrade || die $LINO "DB migration error"
|
||||
|
||||
start_watcher
|
||||
|
||||
# Don't succeed unless the services come up
|
||||
ensure_services_started watcher-api watcher-decision-engine watcher-applier
|
||||
|
||||
set +o xtrace
|
||||
echo "*********************************************************************"
|
||||
echo "SUCCESS: End $0"
|
||||
echo "*********************************************************************"
|
||||
Reference in New Issue
Block a user