@@ -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}
0 commit comments