-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
450 additions
and
31 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 |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Upgrade Workload | ||
|
||
The upgrade workload playbook is `workloads/upgrade.yml` and will upgrade a cluster with or without tooling. | ||
|
||
Note that upgrades can reboot nodes and thus any node that is rebooted hosting a pbench agent pod that is actively collecting data will be interrupted. As with cloud native workloads, pods are supposed to be ephemeral anyway. | ||
|
||
Running from CLI: | ||
|
||
```sh | ||
$ cp workloads/inventory.example inventory | ||
$ # Add orchestration host to inventory | ||
$ # Edit vars in workloads/vars/scale.yml or define Environment vars (See below) | ||
$ time ansible-playbook -vv -i inventory workloads/upgrade.yml | ||
``` | ||
|
||
## Environment variables | ||
|
||
### PUBLIC_KEY | ||
Default: `~/.ssh/id_rsa.pub` | ||
Public ssh key file for Ansible. | ||
|
||
### PRIVATE_KEY | ||
Default: `~/.ssh/id_rsa` | ||
Private ssh key file for Ansible. | ||
|
||
### ORCHESTRATION_USER | ||
Default: `root` | ||
User for Ansible to log in as. Must authenticate with PUBLIC_KEY/PRIVATE_KEY. | ||
|
||
### WORKLOAD_IMAGE | ||
Default: `quay.io/openshift-scale/scale-ci-workload` | ||
Container image that runs the workload script. | ||
|
||
### WORKLOAD_JOB_NODE_SELECTOR | ||
Default: `true` | ||
Enables/disables the node selector that places the workload job on the `workload` node. | ||
|
||
### WORKLOAD_JOB_TAINT | ||
Default: `true` | ||
Enables/disables the toleration on the workload job to permit the `workload` taint. | ||
|
||
### WORKLOAD_JOB_PRIVILEGED | ||
Default: `false` | ||
Enables/disables running the workload Pod as privileged. | ||
|
||
### KUBECONFIG_FILE | ||
Default: `~/.kube/config` | ||
Location of kubeconfig on orchestration host. | ||
|
||
### PBENCH_INSTRUMENTATION | ||
Default: `false` | ||
Enables/disables running the workload wrapped by pbench-user-benchmark. When enabled, pbench agents can then be enabled (`ENABLE_PBENCH_AGENTS`) for further instrumentation data and pbench-copy-results can be enabled (`ENABLE_PBENCH_COPY`) to export captured data for further analysis. | ||
|
||
### ENABLE_PBENCH_AGENTS | ||
Default: `false` | ||
Enables/disables the collection of pbench data on the pbench agent Pods. These Pods are deployed by the tooling playbook. | ||
|
||
### ENABLE_PBENCH_COPY | ||
Default: `false` | ||
Enables/disables the copying of pbench data to a remote results server for further analysis. | ||
|
||
### PBENCH_SSH_PRIVATE_KEY_FILE | ||
Default: `~/.ssh/id_rsa` | ||
Location of ssh private key to authenticate to the pbench results server. | ||
|
||
### PBENCH_SSH_PUBLIC_KEY_FILE | ||
Default: `~/.ssh/id_rsa.pub` | ||
Location of the ssh public key to authenticate to the pbench results server. | ||
|
||
### PBENCH_SERVER | ||
Default: There is no public default. | ||
DNS address of the pbench results server. | ||
|
||
### SCALE_CI_RESULTS_TOKEN | ||
Default: There is no public default. | ||
Future use for pbench and prometheus scraper to place results into git repo that holds results data. | ||
|
||
### JOB_COMPLETION_POLL_ATTEMPTS | ||
Default: `360` | ||
Number of retries for Ansible to poll if the workload job has completed. Poll attempts delay 10s between polls with some additional time taken for each polling action depending on the orchestration host setup. | ||
|
||
### UPGRADE_TEST_PREFIX | ||
Default: `upgrade` | ||
Test to prefix the pbench results. | ||
|
||
### UPGRADE_NEW_VERSION_URL | ||
Default: No default. | ||
The url portion of a new version to upgrade to. An example would be `quay.io/openshift-release-dev/ocp-release` or `registry.svc.ci.openshift.org/ocp/release`. | ||
|
||
### UPGRADE_NEW_VERSION | ||
Default: No default. | ||
The new version to upgrade to. Check [https://openshift-release.svc.ci.openshift.org/](https://openshift-release.svc.ci.openshift.org/) for versions and upgrade paths based on the installed cluster. | ||
|
||
### FORCE_UPGRADE | ||
Default: `false` | ||
Determines the `--force` flag value for the `oc adm upgrade` command to initiate an upgrade. | ||
|
||
### UPGRADE_POLL_ATTEMPTS | ||
Default: `1800` | ||
Number of times to poll to determine if the cluster has been upgraded. Each poll attempted corresponds to approximately a 2s wait plus poll time. | ||
|
||
### EXPECTED_UPGRADE_DURATION | ||
Default: `1800` | ||
Pass/fail criteria. Value to determine if upgrade workload executed in duration expected. | ||
|
||
## Smoke test variables | ||
|
||
``` | ||
UPGRADE_TEST_PREFIX=upgrade_smoke | ||
UPGRADE_NEW_VERSION_URL=registry.svc.ci.openshift.org/ocp/release | ||
UPGRADE_NEW_VERSION=4.2.0-0.nightly-2019-08-13-183722 | ||
FORCE_UPGRADE=true | ||
UPGRADE_POLL_ATTEMPTS=7200 | ||
``` |
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,123 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: scale-ci-workload-script | ||
data: | ||
run.sh: | | ||
#!/bin/sh | ||
set -eo pipefail | ||
workload_log() { echo "$(date -u) $@" >&2; } | ||
export -f workload_log | ||
workload_log "Configuring pbench for running upgrade workload" | ||
mkdir -p /var/lib/pbench-agent/tools-default/ | ||
echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd | ||
if [ "${ENABLE_PBENCH_AGENTS}" = true ]; then | ||
echo "" > /var/lib/pbench-agent/tools-default/disk | ||
echo "" > /var/lib/pbench-agent/tools-default/iostat | ||
echo "workload" > /var/lib/pbench-agent/tools-default/label | ||
echo "" > /var/lib/pbench-agent/tools-default/mpstat | ||
echo "" > /var/lib/pbench-agent/tools-default/oc | ||
echo "" > /var/lib/pbench-agent/tools-default/perf | ||
echo "" > /var/lib/pbench-agent/tools-default/pidstat | ||
echo "" > /var/lib/pbench-agent/tools-default/sar | ||
master_nodes=`oc get nodes -l pbench_agent=true,node-role.kubernetes.io/master= --no-headers | awk '{print $1}'` | ||
for node in $master_nodes; do | ||
echo "master" > /var/lib/pbench-agent/tools-default/remote@$node | ||
done | ||
infra_nodes=`oc get nodes -l pbench_agent=true,node-role.kubernetes.io/infra= --no-headers | awk '{print $1}'` | ||
for node in $infra_nodes; do | ||
echo "infra" > /var/lib/pbench-agent/tools-default/remote@$node | ||
done | ||
worker_nodes=`oc get nodes -l pbench_agent=true,node-role.kubernetes.io/worker= --no-headers | awk '{print $1}'` | ||
for node in $worker_nodes; do | ||
echo "worker" > /var/lib/pbench-agent/tools-default/remote@$node | ||
done | ||
fi | ||
source /opt/pbench-agent/profile | ||
workload_log "Done configuring pbench for upgrade workload run" | ||
workload_log "Running upgrade workload" | ||
if [ "${PBENCH_INSTRUMENTATION}" = "true" ]; then | ||
pbench-user-benchmark -- sh /root/workload/workload.sh | ||
result_dir="/var/lib/pbench-agent/$(ls -t /var/lib/pbench-agent/ | grep "pbench-user" | head -2 | tail -1)"/1/sample1 | ||
if [ "${ENABLE_PBENCH_COPY}" = "true" ]; then | ||
pbench-copy-results --prefix ${UPGRADE_TEST_PREFIX} | ||
fi | ||
else | ||
sh /root/workload/workload.sh | ||
result_dir=/tmp | ||
fi | ||
workload_log "Completed upgrade workload run" | ||
workload_log "Checking Test Results" | ||
workload_log "Checking Test Exit Code" | ||
if [ $(jq '.exit_code==0' ${result_dir}/exit.json) == "false" ]; then | ||
workload_log "Test Failure" | ||
workload_log "Test Analysis: Failed" | ||
exit 1 | ||
fi | ||
workload_log "Comparing upgrade duration to expected duration" | ||
workload_log "Scaling Duration: $(jq '.duration' ${result_dir}/exit.json)" | ||
if [ $(jq '.duration>'${EXPECTED_UPGRADE_DURATION}'' ${result_dir}/exit.json) == "true" ]; then | ||
workload_log "EXPECTED_UPGRADE_DURATION (${EXPECTED_UPGRADE_DURATION}) exceeded ($(jq '.duration' ${result_dir}/exit.json))" | ||
workload_log "Test Analysis: Failed" | ||
exit 1 | ||
fi | ||
# TODO: Check pbench-agent collected metrics for Pass/Fail | ||
# TODO: Check prometheus collected metrics for Pass/Fail | ||
workload_log "Test Analysis: Passed" | ||
workload.sh: | | ||
#!/bin/sh | ||
result_dir=/tmp | ||
if [ "${PBENCH_INSTRUMENTATION}" = "true" ]; then | ||
result_dir=${benchmark_results_dir} | ||
fi | ||
start_time=$(date +%s) | ||
workload_log "Before Upgrade Data" | ||
oc get clusterversion/version | ||
oc get clusteroperators | ||
oc adm upgrade --force=${FORCE_UPGRADE} --to-image=${UPGRADE_NEW_VERSION_URL}:${UPGRADE_NEW_VERSION} | ||
# Poll to see upgrade started | ||
retries=0 | ||
while [ ${retries} -le 120 ] ; do | ||
clusterversion_output=`oc get clusterversion/version` | ||
if [[ "${clusterversion_output}" == *"Working towards "* ]]; then | ||
workload_log "Cluster upgrade started" | ||
break | ||
else | ||
workload_log "Cluster upgrade has not started, Poll attempts: ${retries}/120" | ||
sleep 1 | ||
fi | ||
retries=$[${retries} + 1] | ||
done | ||
# Poll to see if upgrade has completed | ||
retries=0 | ||
while [ ${retries} -le ${UPGRADE_POLL_ATTEMPTS} ] ; do | ||
clusterversion_output=`oc get clusterversion/version` | ||
if [[ "${clusterversion_output}" == *"Cluster version is "* ]]; then | ||
workload_log "Cluster upgrade complete" | ||
break | ||
else | ||
workload_log "Cluster still upgrading, Poll attempts: ${retries}/${UPGRADE_POLL_ATTEMPTS}" | ||
sleep 2 | ||
fi | ||
retries=$[${retries} + 1] | ||
done | ||
end_time=$(date +%s) | ||
duration=$((end_time-start_time)) | ||
exit_code=0 | ||
workload_log "Post Upgrade Data" | ||
oc get clusterversion/version | ||
oc get clusteroperators | ||
if [[ "${clusterversion_output}" != *"Cluster version is "* ]]; then | ||
workload_log "Cluster failed to scale to ${UPGRADE_NEW_VERSION} in (${UPGRADE_POLL_ATTEMPTS} * 2s)" | ||
exit_code=1 | ||
fi | ||
workload_log "Writing Exit Code and Duration" | ||
jq -n '. | ."exit_code"='${exit_code}' | ."duration"='${duration}'' > "${result_dir}/exit.json" |
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.