Skip to content

Commit 4575d9a

Browse files
Merge pull request #3458 from jrvaldes/enable-debug-olm-install
[hack] generalize debug_logging and use in olm install flow
2 parents 4009b34 + 02e8256 commit 4575d9a

File tree

2 files changed

+39
-36
lines changed

2 files changed

+39
-36
lines changed

hack/common.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ run_WMCO() {
284284
# Run the operator in the given namespace
285285
OSDK_WMCO_management run $OSDK
286286

287+
enable_debug_logging
288+
287289
# Additional guard that ensures that operator was deployed given the SDK flakes in error reporting
288290
if ! oc rollout status deployment windows-machine-config-operator -n $WMCO_DEPLOY_NAMESPACE --timeout=5s; then
289291
return 1
@@ -375,4 +377,41 @@ deleteParallelUpgradeCheckerResources() {
375377
oc delete -f hack/e2e/resources/parallel-upgrade-checker-job.yaml || {
376378
echo "error deleting parallel upgrade checker job"
377379
}
380+
}
381+
382+
383+
enable_debug_logging() {
384+
if [[ $(oc get -n $WMCO_DEPLOY_NAMESPACE pod -l name=windows-machine-config-operator -ojson) == *"--debugLogging"* ]]; then
385+
# debug logging already enabled
386+
return 0
387+
fi
388+
WMCO_SUB=$(oc get sub -n $WMCO_DEPLOY_NAMESPACE --no-headers |awk '{print $1}')
389+
oc patch subscription $WMCO_SUB -n $WMCO_DEPLOY_NAMESPACE --type=merge -p '{"spec":{"config":{"env":[{"name":"ARGS","value":"--debugLogging"}]}}}'
390+
# delete the deployment to ensure the changes are picked up in a timely matter
391+
oc delete deployment -n $WMCO_DEPLOY_NAMESPACE windows-machine-config-operator
392+
retries=0
393+
debug_logging_enabled=0
394+
until [[ $debug_logging_enabled -eq 1 || $retries -gt 30 ]]; do
395+
pod_json=$(oc get -n $WMCO_DEPLOY_NAMESPACE pod -l name=windows-machine-config-operator -ojson)
396+
pod_count=$(echo $pod_json |jq '.items | length')
397+
if [[ $pod_count -ne 1 ]]; then
398+
echo "Found $pod_count WMCO pod(s), waiting for 1"
399+
sleep 10
400+
retries=$((retries+1))
401+
continue
402+
fi
403+
if [[ $pod_json != *"--debugLogging"* ]]; then
404+
echo "Waiting for debugLogging to be set"
405+
sleep 10
406+
retries=$((retries+1))
407+
continue
408+
fi
409+
debug_logging_enabled=1
410+
done
411+
if [[ $debug_logging_enabled -ne 1 ]]; then
412+
echo "Error enabling debug logging"
413+
exit 1
414+
fi
415+
# Final wait to ensure the pod is fully running
416+
oc wait --timeout=10m --for condition=Available -n $WMCO_DEPLOY_NAMESPACE deployment windows-machine-config-operator
378417
}

hack/run-ci-e2e-test.sh

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,6 @@ get_WMCO_logs() {
4141
done
4242
}
4343

44-
enable_debug_logging() {
45-
if [[ $(oc get -n $WMCO_DEPLOY_NAMESPACE pod -l name=windows-machine-config-operator -ojson) == *"--debugLogging"* ]]; then
46-
# debug logging already enabled
47-
return 0
48-
fi
49-
WMCO_SUB=$(oc get sub -n $WMCO_DEPLOY_NAMESPACE --no-headers |awk '{print $1}')
50-
oc patch subscription $WMCO_SUB -n $WMCO_DEPLOY_NAMESPACE --type=merge -p '{"spec":{"config":{"env":[{"name":"ARGS","value":"--debugLogging"}]}}}'
51-
# delete the deployment to ensure the changes are picked up in a timely matter
52-
oc delete deployment -n $WMCO_DEPLOY_NAMESPACE windows-machine-config-operator
53-
retries=0
54-
debug_logging_enabled=0
55-
until [[ $debug_logging_enabled -eq 1 || $retries -gt 30 ]]; do
56-
pod_json=$(oc get -n $WMCO_DEPLOY_NAMESPACE pod -l name=windows-machine-config-operator -ojson)
57-
pod_count=$(echo $pod_json |jq '.items | length')
58-
if [[ $pod_count -ne 1 ]]; then
59-
echo "Found $pod_count WMCO pod(s), waiting for 1"
60-
sleep 10
61-
retries=$((retries+1))
62-
continue
63-
fi
64-
if [[ $pod_json != *"--debugLogging"* ]]; then
65-
echo "Waiting for debugLogging to be set"
66-
sleep 10
67-
retries=$((retries+1))
68-
continue
69-
fi
70-
debug_logging_enabled=1
71-
done
72-
if [[ $debug_logging_enabled -ne 1 ]]; then
73-
echo "Error enabling debug logging"
74-
exit 1
75-
fi
76-
# Final wait to ensure the pod is fully running
77-
oc wait --timeout=10m --for condition=Available -n $WMCO_DEPLOY_NAMESPACE deployment windows-machine-config-operator
78-
}
79-
8044
TEST="basic"
8145
# WINDOWS_SERVER_VERSION will be set in the CI config. If it is not set, default to 2022.
8246
WIN_VER=${WINDOWS_SERVER_VERSION:-"2022"}

0 commit comments

Comments
 (0)