Skip to content

Commit 42f9ba4

Browse files
committed
get latest version from sail repo
1 parent e848cb7 commit 42f9ba4

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

Diff for: prow/setup/sail-operator-setup.sh

+26-6
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,23 @@ WORKDIR="$2"
6666
IOP_FILE="$2"/iop.yaml
6767
SAIL_IOP_FILE="$(basename "${IOP_FILE%.yaml}")-sail.yaml"
6868

69-
ISTIO_VERSION="${ISTIO_VERSION:-v1.24-latest}"
69+
CONVERTER_BRANCH="${CONVERTER_BRANCH:-main}"
70+
71+
# get istio version from versions.yaml
72+
VERSION_FILE="https://raw.githubusercontent.com/istio-ecosystem/sail-operator/$CONVERTER_BRANCH/pkg/istioversion/versions.yaml"
73+
if [ -z "${ISTIO_VERSION:-}" ]; then
74+
ISTIO_VERSION="$(curl -s "$VERSION_FILE" | grep -E 'name: v[0-9]+\.[0-9]+' | sed -E 's/.*(v[0-9]+\.[0-9]+).*/\1/' | sort -Vr | head -n1)-latest"
75+
fi
76+
7077
NAMESPACE="${NAMESPACE:-istio-system}"
7178
ISTIOCNI_NAMESPACE="${ISTIOCNI_NAMESPACE:-istio-cni}"
7279

7380
ISTIOCNI="${PROW}/config/sail-operator/istio-cni.yaml"
7481
INGRESS_GATEWAY_VALUES="${PROW}/config/sail-operator/ingress-gateway-values.yaml"
7582
EGRESS_GATEWAY_VALUES="${PROW}/config/sail-operator/egress-gateway-values.yaml"
7683

77-
CONVERTER_BRANCH="${CONVERTER_BRANCH:-main}"
7884
CONVERTER_ADDRESS="https://raw.githubusercontent.com/istio-ecosystem/sail-operator/$CONVERTER_BRANCH/tools/configuration-converter.sh"
79-
CONVERTER_SCRIPT=$(basename $CONVERTER_ADDRESS)
85+
CONVERTER_SCRIPT=$(basename "$CONVERTER_ADDRESS")
8086

8187
function download_execute_converter(){
8288
cd "${PROW}"
@@ -109,7 +115,7 @@ function install_istio(){
109115
}
110116

111117
SECRET_NAME="istio-ca-secret"
112-
WEBHOOK_FILE="$PROW/config/validatingwebhook.yaml"
118+
WEBHOOK_FILE="$PROW/config/sail-operator/validatingwebhook.yaml"
113119

114120
function patch_config() {
115121
# adds some control plane values that are mandatory and not available in iop.yaml
@@ -124,7 +130,22 @@ function patch_config() {
124130
fi
125131

126132
# Workaround until https://github.com/istio-ecosystem/sail-operator/issues/749 is fixed
127-
CA_BUNDLE=$(kubectl get secret "$SECRET_NAME" -n "$NAMESPACE" -o yaml | grep "ca-cert" | awk '{print $2}')
133+
CA_BUNDLE=$(kubectl get secret "$SECRET_NAME" -n "$NAMESPACE" -o yaml 2>/dev/null | grep "ca-cert" | awk '{print $2}')
134+
135+
# If not found, sleep for 5 seconds and retry once
136+
if [ -z "$CA_BUNDLE" ]; then
137+
echo "Secret not found. Sleeping for 5 seconds before retrying..."
138+
sleep 5
139+
140+
# Retry once
141+
CA_BUNDLE=$(kubectl get secret "$SECRET_NAME" -n "$NAMESPACE" -o yaml 2>/dev/null | grep "ca-cert" | awk '{print $2}')
142+
143+
if [ -z "$CA_BUNDLE" ]; then
144+
echo "Secret still not found after retry. Exiting."
145+
exit 1
146+
fi
147+
fi
148+
128149
sed -i "s|<base64-encoded-CA-cert>|$CA_BUNDLE|g" "$WEBHOOK_FILE"
129150
kubectl apply -f "$WEBHOOK_FILE"
130151
sed -i "s|$CA_BUNDLE|<base64-encoded-CA-cert>|g" "$WEBHOOK_FILE"
@@ -139,7 +160,6 @@ function install_gateways(){
139160
oc -n "$NAMESPACE" wait --for=condition=Available deployment/istio-ingressgateway --timeout=60s || { echo "Failed to start istio-ingressgateway"; oc get pods -n "$NAMESPACE" -o wide; oc describe pod $(oc get pods -n istio-system --no-headers | awk "$3==\"ErrImagePull\" {print $1}" | head -n 1) -n istio-system; exit 1;}
140161
oc -n "$NAMESPACE" wait --for=condition=Available deployment/istio-egressgateway --timeout=60s || { echo "Failed to start istio-egressgateway"; kubectl get istios; oc get pods -n "$NAMESPACE" -o wide; exit 1;}
141162
echo "Gateways created."
142-
143163
}
144164

145165
function cleanup_istio(){

0 commit comments

Comments
 (0)