Skip to content

Commit 9bb7c5d

Browse files
committed
Switch to continuous logging during update.
We now have a continuous monitoring running in the background, so we just need to log the current step of the update and it will be logged. Depends-On: openstack-k8s-operators/ci-framework#2841 Resolves: [OSPRH-15060](https://issues.redhat.com/browse/OSPRH-15060)
1 parent faaca9f commit 9bb7c5d

File tree

1 file changed

+19
-42
lines changed

1 file changed

+19
-42
lines changed

scripts/openstack-update.sh

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -43,45 +43,15 @@ else
4343
BASE_DIR="" # current directory
4444
fi
4545

46-
function get_current_compute_state {
47-
local stage="${1:-}"
48-
file_pre="${BASE_DIR}${stage:+${stage}-}"
49-
50-
if [ -e "${CI_INVENTORY}" ]; then
51-
echo "Collecting compute state ${stage:+for $stage }in ${BASE_DIR:-${PWD}}"
52-
53-
# Collect all running containers an all compute nodes in ~/ci-framework-data/tests/update/ by default.
54-
ansible -i "${CI_INVENTORY}" -m shell -a \
55-
"sudo podman ps -q --filter 'status=running' | xargs -I {} sudo podman inspect --format {% raw %} '{{.Name}} {{.Config.Image}} {{.State.StartedAt}}' {% endraw %} {}|sort" computes | \
56-
awk -vfile_pre="${file_pre}" 'BEGIN {tp=strftime("%Y%m%d%H%M%S")} /^compute/ {if (s != "") {close(s)}; s = "containers-" $1 "_" tp ".txt"; next;}; s {print > file_pre s} '
57-
# Collect packages list an all compute nodes in ~/ci-framework-data/tests/update/ by default.
58-
ansible -i "${CI_INVENTORY}" -m shell -a \
59-
"sudo dnf list installed | sort" computes | \
60-
awk -vfile_pre="${file_pre}" 'BEGIN {tp=strftime("%Y%m%d%H%M%S")} /^compute/ {if (s != "") {close(s)}; s = "packages-" $1 "_" tp ".txt"; next;}; s {print > file_pre s} '
46+
# The update_event.sh is created ci-framework update role.
47+
update_event() {
48+
local event="${@:-Unknown Event}"
49+
local event_script="${UPDATE_ARTIFACT_DIR}/update_event.sh"
50+
if [ -e "${event_script}" ]; then
51+
"${event_script}" "${event}"
6152
fi
6253
}
6354

64-
function get_current_pod_state {
65-
local stage="${1:-}"
66-
file_pre="${BASE_DIR}${stage:+${stage}-}"
67-
68-
echo "Collecting pod state ${stage:+for $stage }in ${BASE_DIR:-${PWD}}"
69-
70-
local openstack_state_file="${file_pre}pods_os_state_$(date +%Y%m%d_%H%M%S).tsv"
71-
local os_operator_state_file="${file_pre}pods_os_op_state_$(date +%Y%m%d_%H%M%S).tsv"
72-
oc get pods -n "${OPERATOR_NAMESPACE}" -o json | jq -r '.items[] | select(.status.phase == "Running") | . as $pod | .status.containerStatuses[] | [$pod.metadata.name, $pod.status.startTime, .image, .state.running.startedAt ] | @tsv' > $os_operator_state_file
73-
74-
oc get pods -n "${NAMESPACE}" -o json | jq -r '.items[] | select(.status.phase == "Running") | . as $pod | .status.containerStatuses[] | [$pod.metadata.name, $pod.status.startTime, .image, .state.running.startedAt ] | @tsv' > $openstack_state_file
75-
}
76-
77-
function get_current_state {
78-
local stage="${1:-}"
79-
get_current_compute_state "${stage}"
80-
get_current_pod_state "${stage}"
81-
}
82-
83-
get_current_state "01_before_update"
84-
8555
OPENSTACK_OPERATOR_CSV=$(oc get csv -n $OPERATOR_NAMESPACE -o name | grep openstack-operator)
8656
OPENSTACK_VERSION_CR=$(oc get openstackversion -n $NAMESPACE -o name)
8757

@@ -91,6 +61,8 @@ if [ "${FAKE_UPDATE}" != "false" ]; then
9161
OPENSTACK_DEPLOYED_VERSION=$(oc get -n $NAMESPACE $OPENSTACK_VERSION_CR --template={{.spec.targetVersion}})
9262
sed -i $OUTFILE -e "s|value: $OPENSTACK_DEPLOYED_VERSION|value: $OPENSTACK_VERSION|"
9363

64+
update_event Applying Fake Update CR
65+
9466
oc apply -f $OUTFILE
9567
fi
9668

@@ -107,12 +79,14 @@ cat <<EOF >openstackversionpatch.yaml
10779
}
10880
EOF
10981

82+
update_event Patching the Openstack Version
83+
11084
oc patch $OPENSTACK_VERSION_CR --type=merge --patch-file openstackversionpatch.yaml
11185

11286
# wait for ovn update on control plane
11387
oc wait $OPENSTACK_VERSION_CR --for=condition=MinorUpdateOVNControlplane --timeout=$TIMEOUT
11488

115-
get_current_state "02_after_ovn_controlplane_update"
89+
update_event MinorUpdateOVNControlplane Completed
11690

11791
# start ovn update on data plane
11892
nodes_with_ovn=()
@@ -145,20 +119,22 @@ $OVN_NODE_SETS
145119
- ovn
146120
EOF
147121

122+
update_event Applying the OVN CRD
123+
148124
oc create -f edpm-deployment-ovn-update.yaml
149125

150126
oc get openstackdataplanedeployment ${DATAPLANE_DEPLOYMENT}-ovn-update -o yaml
151127
# wait for ovn dataplane completes
152128
oc wait $OPENSTACK_VERSION_CR --for=condition=MinorUpdateOVNDataplane --timeout=$TIMEOUT
153129
echo "MinorUpdateOVNDataplane completed"
154130

155-
get_current_state "03_after_ovn_dataplane_update"
131+
update_event MinorUpdateOVNDataplane Completed
156132

157133
# wait for control plane update to complete
158134
oc wait $OPENSTACK_VERSION_CR --for=condition=MinorUpdateControlplane --timeout=$TIMEOUT
159-
echo "MinorUpdateControlplane completed"
160135

161-
get_current_state "04_after_controlplane_update"
136+
update_event MinorUpdateControlplane Completed
137+
echo "MinorUpdateControlplane completed"
162138

163139
# start data plane plane update for rest of edpm services
164140
DATAPLANE_NODESETS=$(oc get openstackdataplanenodeset -o name | awk -F'/' '{print " - " $2}')
@@ -175,13 +151,14 @@ $DATAPLANE_NODESETS
175151
- update
176152
EOF
177153

154+
update_event Applying the UPDATE CRD
155+
178156
oc create -f edpm-deployment-update.yaml
179157

180158
# wait for completion of minor update
181159
oc wait $OPENSTACK_VERSION_CR --for=condition=MinorUpdateDataplane --timeout=$TIMEOUT
182160
echo "MinorUpdate completed"
183-
184-
get_current_state "05_after_update"
161+
update_event MinorUpdateDataplane Completed
185162

186163
# check for the status of edpm update
187164
oc get openstackdataplanedeployment ${DATAPLANE_DEPLOYMENT}-update -o yaml

0 commit comments

Comments
 (0)