Skip to content

Commit b8b9af5

Browse files
Merge pull request openstack-k8s-operators#1462 from danpawlik/retry-getting-issuer
Add retry on getting ISSUER name
2 parents 3e40e32 + 07f0dd6 commit b8b9af5

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

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[[:space:]]*=[[:space:]]*\([^,]*\).*$/\1/p'
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"

tests/kuttl/tests/ctlplane-tls-custom-issuers/02-assert-service-certs-issuers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ commands:
88
99
- script: |
1010
echo "Checking issuer of internal certificates..."
11-
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "issuer=CN=rootca-internal-custom" "internal"
11+
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "rootca-internal-custom" "internal"
1212
1313
- script: |
1414
echo "Checking issuer of ingress certificates..."

tests/kuttl/tests/ctlplane-tls-custom-issuers/04-assert-service-certs-default-issuers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ commands:
1212
1313
- script: |
1414
echo "Checking issuer of internal certificates..."
15-
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "issuer=CN=rootca-internal" "internal"
15+
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "rootca-internal" "internal"
1616
1717
- script: |
1818
echo "Checking issuer of ingress certificates..."

tests/kuttl/tests/ctlplane-tls-custom-issuers/07-assert-service-certs-default-issuers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ commands:
88
99
- script: |
1010
echo "Checking issuer of internal certificates..."
11-
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "issuer=CN=rootca-internal" "internal"
11+
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "rootca-internal" "internal"
1212
1313
- script: |
1414
echo "Checking issuer of ingress certificates..."

tests/kuttl/tests/ctlplane-tls-custom-issuers/10-assert-service-certs-issuers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ commands:
1212
1313
- script: |
1414
echo "Checking issuer of internal certificates..."
15-
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "issuer=CN=rootca-internal-custom" "internal"
15+
oc exec -i openstackclient -n $NAMESPACE -- bash -s < ../../common/osp_check_cert_issuer.sh "rootca-internal-custom" "internal"
1616
1717
- script: |
1818
echo "Checking issuer of ingress certificates..."

0 commit comments

Comments
 (0)