Skip to content

Commit

Permalink
Avoid using head when getting nodes (#2286)
Browse files Browse the repository at this point in the history
Prevents errors such as:
 06:52:31.692 INFO:    Placing zipkin taint on first worker node
06:52:32.091 ERROR:   🚨 Error (code: 141) occurred at
./hack/lib/tracing.bash:19, with command: zipkin_node=$(oc get node -l
'node-role.kubernetes.io/worker' -oname | head -n 1)
06:52:32.093 ERROR:   Stack trace:
06:52:32.096 ERROR:    1: ./hack/lib/tracing.bash:6
dedicate_node_to_zipkin(...)
06:52:32.099 ERROR:    2: ./hack/tracing.sh:15 install_tracing(...)
make: *** [test-upgrade-with-mesh] Error 141

Co-authored-by: Martin Gencur <[email protected]>
  • Loading branch information
openshift-cherrypick-robot and mgencur authored Oct 18, 2023
1 parent db0039b commit a954ae6
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions hack/lib/tracing.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ function install_tracing {
function dedicate_node_to_zipkin {
logger.info "Placing zipkin taint on first worker node"
local zipkin_node
zipkin_node=$(oc get node -l 'zipkin,node-role.kubernetes.io/worker' -oname | head -1)
if [[ -z "$zipkin_node" ]]; then
zipkin_node=$(oc get node -l 'node-role.kubernetes.io/worker' -oname | head -1)
if [[ -z "$(oc get node -l 'zipkin,node-role.kubernetes.io/worker')" ]]; then
zipkin_node=$(oc get node -l 'node-role.kubernetes.io/worker' -ojsonpath='{.items[0].metadata.name}')
# Add label for placing the Zipkin pod via nodeAffinity
oc label "$zipkin_node" zipkin=
oc label node "$zipkin_node" zipkin=
# Add taint to prevent pods other than Zipkin from scheduling there
oc adm taint --overwrite=true node "$zipkin_node" zipkin:NoSchedule
fi
Expand Down Expand Up @@ -266,9 +265,9 @@ function teardown_tracing {
oc delete service -n "${TRACING_NAMESPACE}" zipkin --ignore-not-found
oc delete deployment -n "${TRACING_NAMESPACE}" zipkin --ignore-not-found

zipkin_node=$(oc get node -l 'zipkin,node-role.kubernetes.io/worker' -oname | head -1)
if [[ -n "$zipkin_node" ]]; then
oc label "$zipkin_node" zipkin-
if [[ -n "$(oc get node -l 'zipkin,node-role.kubernetes.io/worker')" ]]; then
zipkin_node=$(oc get node -l 'zipkin,node-role.kubernetes.io/worker' -ojsonpath='{.items[0].metadata.name}')
oc label node "$zipkin_node" zipkin-
oc adm taint node "$zipkin_node" zipkin:NoSchedule-
fi

Expand Down

0 comments on commit a954ae6

Please sign in to comment.