From 6ba8b69e3ec0526c814b4265fa2353f2a58e0401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Mon, 28 Nov 2022 15:07:27 +0100 Subject: [PATCH] koji_builder: fix the script for updating osbuildapi The awk helper responsible for extracting IP addresses from the resolvectl call could handle only 2 of them. It turns out that api.openshift.com now has 4 A records, therefore this method became flakey: It added only 2 addresses to the IP set, so if the osbuild plugin used one of the 2 ignored addresses, the call failed. This commit solves it by introducing a different method of parsing the resolvectl output: We now use an ugly but working sed command that erases everything from the line except for the IPv4 address. Therefore, I had to quote the echo before the new sed command so it can get a proper multiline input. Also, I limited resolvectl to just use IPv4 because the new script cannot handle IPv6 properly. This doesn't cause any harm because api.openshift.com isn't actually accessible by IPv6. Sigh... --- roles/koji_builder/templates/osbuildapi-update.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/roles/koji_builder/templates/osbuildapi-update.sh b/roles/koji_builder/templates/osbuildapi-update.sh index bfebde5189..45a854e754 100644 --- a/roles/koji_builder/templates/osbuildapi-update.sh +++ b/roles/koji_builder/templates/osbuildapi-update.sh @@ -5,13 +5,13 @@ # in staging we need to allow api.stage and in prod api. {% if env == 'staging' %} -RESOLVEQUERY=`resolvectl --cache=no --legend=no query api.stage.openshift.com 2> /dev/null` +RESOLVEQUERY=`resolvectl -4 --cache=no --legend=no query api.stage.openshift.com 2> /dev/null` {% else %} -RESOLVEQUERY=`resolvectl --cache=no --legend=no query api.openshift.com 2> /dev/null` +RESOLVEQUERY=`resolvectl -4 --cache=no --legend=no query api.openshift.com 2> /dev/null` {% endif %} test $? -eq 0 || exit $? -NEWIPS=`echo $RESOLVEQUERY | grep link | awk '{print $2 " " $6}' | sort -n` +NEWIPS=`echo "$RESOLVEQUERY" | grep link | sed -E 's/.* ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/g' | sort -n` /usr/sbin/ipset flush osbuildapi for j in $NEWIPS @@ -22,10 +22,10 @@ done {% if env == 'staging' %} # in stg we need to add identity.api because we are using api.stage above. # in prod this is already the same as api.openshift.com, so skip it. -RESOLVEQUERY=`resolvectl --cache=no --legend=no query identity.api.openshift.com 2> /dev/null` +RESOLVEQUERY=`resolvectl -4 --cache=no --legend=no query identity.api.openshift.com 2> /dev/null` test $? -eq 0 || exit $? -NEWIDENTITYIPS=`echo $RESOLVEQUERY | grep link | awk '{print $2 " " $6}' | sort -n` +NEWIDENTITYIPS=`echo "$RESOLVEQUERY" | grep link | sed -E 's/.* ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/g' | sort -n` for j in $NEWIDENTITYIPS do