Skip to content

Commit 5bd3a7a

Browse files
committed
Add retry on getting ISSUER name
It happens on some infras that the issuer is empty. Probably it does not have enough time to apply changes. This commit adds retry for getting the ISSUER name. Signed-off-by: Daniel Pawlik <dpawlik@redhat.com>
1 parent 3e40e32 commit 5bd3a7a

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

tests/kuttl/common/osp_check_cert_issuer.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ function check_keystone_endpoint {
4040
fi
4141
}
4242

43+
get_issuer_cn() {
44+
local host_port="$1"
45+
local output
46+
47+
output=$(openssl s_client -connect "$host_port" </dev/null 2>/dev/null |
48+
openssl x509 -noout -issuer 2>/dev/null)
49+
50+
echo "$output" | sed -n 's/^.*CN=\([^,]*\).*$/\1/p' | sed 's/ //g'
51+
}
52+
4353
keystone_url=$(openstack endpoint list -c URL -f value | grep 'keystone-public')
4454
keystone_host_port=$(extract_host_port "$keystone_url")
4555

@@ -60,11 +70,14 @@ for url in $(openstack endpoint list -c URL -f value | grep "$endpoint_filter");
6070
host_port=$(extract_host_port "$url")
6171

6272
echo "Checking $host_port ..."
63-
if [[ "$ENDPOINT_TYPE" == "public" ]]; then
64-
ISSUER=$(echo | openssl s_client -connect "$host_port" 2>/dev/null | openssl x509 -noout -issuer | sed -n 's/^.*CN=\([^,]*\).*$/\1/p' | sed 's/ //g')
65-
else
66-
ISSUER=$(openssl s_client -connect $host_port </dev/null 2>/dev/null | openssl x509 -issuer -noout -in /dev/stdin | sed 's/ //g')
67-
fi
73+
for retry in {1..5}; do
74+
echo "Retrying $retry on getting issuer $host_port..."
75+
ISSUER=$(get_issuer_cn "$host_port")
76+
if [[ -n "$ISSUER" ]]; then
77+
break
78+
fi
79+
sleep 20
80+
done
6881

6982
if [[ "$ISSUER" != "$EXPECTED_ISSUER" ]]; then
7083
ISSUER_MISMATCHES+="$host_port issued by $ISSUER, expected $EXPECTED_ISSUER\n"

0 commit comments

Comments
 (0)