diff --git a/ci-operator/config/openshift-kni/oran-o2ims/openshift-kni-oran-o2ims-main.yaml b/ci-operator/config/openshift-kni/oran-o2ims/openshift-kni-oran-o2ims-main.yaml index 3fc023b4a8f71..cf6ce7938375a 100644 --- a/ci-operator/config/openshift-kni/oran-o2ims/openshift-kni-oran-o2ims-main.yaml +++ b/ci-operator/config/openshift-kni/oran-o2ims/openshift-kni-oran-o2ims-main.yaml @@ -127,95 +127,7 @@ tests: TLS_13_TLS_ADHERENCE_POLICY: StrictAllComponents test: - ref: optional-operators-operator-sdk - - as: wait-for-server-pods - cli: latest - commands: | - NAMESPACE=oran-o2ims - echo "Waiting for Inventory CR to be auto-created..." - for i in $(seq 1 60); do - if oc get inventory default -n "$NAMESPACE" &>/dev/null; then - echo "Inventory CR 'default' found." - break - fi - echo " attempt $i/60..." - sleep 5 - done - - if ! oc get inventory default -n "$NAMESPACE" &>/dev/null; then - echo "ERROR: Inventory CR 'default' was not created after 5 minutes" - exit 1 - fi - - echo "" - echo "Discovering services with TLS serving certs..." - TLS_SERVICES=$(oc get services -n "$NAMESPACE" \ - -o jsonpath='{range .items[?(@.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name)]}{.metadata.name}{"\n"}{end}') - - echo "TLS services found:" - while read -r svc; do - [ -z "$svc" ] && continue - SECRET=$(oc get service "$svc" -n "$NAMESPACE" \ - -o jsonpath='{.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name}') - echo " $svc -> secret: $SECRET" - done <<< "$TLS_SERVICES" - - echo "" - echo "Waiting for TLS service pods to be ready..." - FAILED=false - while read -r svc; do - [ -z "$svc" ] && continue - SELECTOR=$(oc get service "$svc" -n "$NAMESPACE" \ - -o go-template='{{range $k,$v := .spec.selector}}{{$k}}={{$v}},{{end}}' | sed 's/,$//') - if [ -z "$SELECTOR" ]; then - echo " SKIP: $svc has no selector" - continue - fi - echo " $svc (selector: $SELECTOR)..." - if ! oc wait pods -l "$SELECTOR" -n "$NAMESPACE" \ - --for=condition=Ready --timeout=5m; then - echo " ERROR: pods for $svc did not become ready within 5m" - echo " Pod status:" - oc get pods -l "$SELECTOR" -n "$NAMESPACE" --no-headers | sed 's/^/ /' - echo " Recent events:" - oc get events -n "$NAMESPACE" --field-selector reason!=Pulling,reason!=Pulled \ - --sort-by='.lastTimestamp' 2>/dev/null | grep "$svc" | tail -5 | sed 's/^/ /' \ - || echo " (no events found)" - FAILED=true - fi - done <<< "$TLS_SERVICES" - - if [ "$FAILED" = true ]; then - echo "ERROR: one or more TLS service pods failed readiness checks" - exit 1 - fi - - echo "" - echo "Verifying TLS secrets from service-ca..." - while read -r svc; do - [ -z "$svc" ] && continue - SECRET=$(oc get service "$svc" -n "$NAMESPACE" \ - -o jsonpath='{.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name}') - if oc get secret "$SECRET" -n "$NAMESPACE" &>/dev/null; then - echo " $SECRET exists" - else - echo " ERROR: $SECRET not found" - FAILED=true - fi - done <<< "$TLS_SERVICES" - - if [ "$FAILED" = true ]; then - echo "ERROR: one or more TLS secrets are missing" - exit 1 - fi - - echo "" - echo "Final pod status in $NAMESPACE:" - oc get pods -n "$NAMESPACE" - from: cli - resources: - requests: - cpu: 100m - memory: 200Mi + - ref: oran-o2ims-wait-for-tls-pods - ref: tls-13 - ref: tls-scanner-run workflow: ipi-aws @@ -235,95 +147,7 @@ tests: TLS_13_TLS_ADHERENCE_POLICY: StrictAllComponents test: - ref: optional-operators-operator-sdk - - as: wait-for-server-pods - cli: latest - commands: | - NAMESPACE=oran-o2ims - echo "Waiting for Inventory CR to be auto-created..." - for i in $(seq 1 60); do - if oc get inventory default -n "$NAMESPACE" &>/dev/null; then - echo "Inventory CR 'default' found." - break - fi - echo " attempt $i/60..." - sleep 5 - done - - if ! oc get inventory default -n "$NAMESPACE" &>/dev/null; then - echo "ERROR: Inventory CR 'default' was not created after 5 minutes" - exit 1 - fi - - echo "" - echo "Discovering services with TLS serving certs..." - TLS_SERVICES=$(oc get services -n "$NAMESPACE" \ - -o jsonpath='{range .items[?(@.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name)]}{.metadata.name}{"\n"}{end}') - - echo "TLS services found:" - while read -r svc; do - [ -z "$svc" ] && continue - SECRET=$(oc get service "$svc" -n "$NAMESPACE" \ - -o jsonpath='{.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name}') - echo " $svc -> secret: $SECRET" - done <<< "$TLS_SERVICES" - - echo "" - echo "Waiting for TLS service pods to be ready..." - FAILED=false - while read -r svc; do - [ -z "$svc" ] && continue - SELECTOR=$(oc get service "$svc" -n "$NAMESPACE" \ - -o go-template='{{range $k,$v := .spec.selector}}{{$k}}={{$v}},{{end}}' | sed 's/,$//') - if [ -z "$SELECTOR" ]; then - echo " SKIP: $svc has no selector" - continue - fi - echo " $svc (selector: $SELECTOR)..." - if ! oc wait pods -l "$SELECTOR" -n "$NAMESPACE" \ - --for=condition=Ready --timeout=5m; then - echo " ERROR: pods for $svc did not become ready within 5m" - echo " Pod status:" - oc get pods -l "$SELECTOR" -n "$NAMESPACE" --no-headers | sed 's/^/ /' - echo " Recent events:" - oc get events -n "$NAMESPACE" --field-selector reason!=Pulling,reason!=Pulled \ - --sort-by='.lastTimestamp' 2>/dev/null | grep "$svc" | tail -5 | sed 's/^/ /' \ - || echo " (no events found)" - FAILED=true - fi - done <<< "$TLS_SERVICES" - - if [ "$FAILED" = true ]; then - echo "ERROR: one or more TLS service pods failed readiness checks" - exit 1 - fi - - echo "" - echo "Verifying TLS secrets from service-ca..." - while read -r svc; do - [ -z "$svc" ] && continue - SECRET=$(oc get service "$svc" -n "$NAMESPACE" \ - -o jsonpath='{.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name}') - if oc get secret "$SECRET" -n "$NAMESPACE" &>/dev/null; then - echo " $SECRET exists" - else - echo " ERROR: $SECRET not found" - FAILED=true - fi - done <<< "$TLS_SERVICES" - - if [ "$FAILED" = true ]; then - echo "ERROR: one or more TLS secrets are missing" - exit 1 - fi - - echo "" - echo "Final pod status in $NAMESPACE:" - oc get pods -n "$NAMESPACE" - from: cli - resources: - requests: - cpu: 100m - memory: 200Mi + - ref: oran-o2ims-wait-for-tls-pods - ref: tls-13 - ref: tls-scanner-run workflow: ipi-aws diff --git a/ci-operator/config/openshift-kni/oran-o2ims/openshift-kni-oran-o2ims-release-4.22.yaml b/ci-operator/config/openshift-kni/oran-o2ims/openshift-kni-oran-o2ims-release-4.22.yaml index 5d80fc3fdfcda..8669f3afae7e7 100644 --- a/ci-operator/config/openshift-kni/oran-o2ims/openshift-kni-oran-o2ims-release-4.22.yaml +++ b/ci-operator/config/openshift-kni/oran-o2ims/openshift-kni-oran-o2ims-release-4.22.yaml @@ -127,95 +127,7 @@ tests: TLS_13_TLS_ADHERENCE_POLICY: StrictAllComponents test: - ref: optional-operators-operator-sdk - - as: wait-for-server-pods - cli: latest - commands: | - NAMESPACE=oran-o2ims - echo "Waiting for Inventory CR to be auto-created..." - for i in $(seq 1 60); do - if oc get inventory default -n "$NAMESPACE" &>/dev/null; then - echo "Inventory CR 'default' found." - break - fi - echo " attempt $i/60..." - sleep 5 - done - - if ! oc get inventory default -n "$NAMESPACE" &>/dev/null; then - echo "ERROR: Inventory CR 'default' was not created after 5 minutes" - exit 1 - fi - - echo "" - echo "Discovering services with TLS serving certs..." - TLS_SERVICES=$(oc get services -n "$NAMESPACE" \ - -o jsonpath='{range .items[?(@.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name)]}{.metadata.name}{"\n"}{end}') - - echo "TLS services found:" - while read -r svc; do - [ -z "$svc" ] && continue - SECRET=$(oc get service "$svc" -n "$NAMESPACE" \ - -o jsonpath='{.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name}') - echo " $svc -> secret: $SECRET" - done <<< "$TLS_SERVICES" - - echo "" - echo "Waiting for TLS service pods to be ready..." - FAILED=false - while read -r svc; do - [ -z "$svc" ] && continue - SELECTOR=$(oc get service "$svc" -n "$NAMESPACE" \ - -o go-template='{{range $k,$v := .spec.selector}}{{$k}}={{$v}},{{end}}' | sed 's/,$//') - if [ -z "$SELECTOR" ]; then - echo " SKIP: $svc has no selector" - continue - fi - echo " $svc (selector: $SELECTOR)..." - if ! oc wait pods -l "$SELECTOR" -n "$NAMESPACE" \ - --for=condition=Ready --timeout=5m; then - echo " ERROR: pods for $svc did not become ready within 5m" - echo " Pod status:" - oc get pods -l "$SELECTOR" -n "$NAMESPACE" --no-headers | sed 's/^/ /' - echo " Recent events:" - oc get events -n "$NAMESPACE" --field-selector reason!=Pulling,reason!=Pulled \ - --sort-by='.lastTimestamp' 2>/dev/null | grep "$svc" | tail -5 | sed 's/^/ /' \ - || echo " (no events found)" - FAILED=true - fi - done <<< "$TLS_SERVICES" - - if [ "$FAILED" = true ]; then - echo "ERROR: one or more TLS service pods failed readiness checks" - exit 1 - fi - - echo "" - echo "Verifying TLS secrets from service-ca..." - while read -r svc; do - [ -z "$svc" ] && continue - SECRET=$(oc get service "$svc" -n "$NAMESPACE" \ - -o jsonpath='{.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name}') - if oc get secret "$SECRET" -n "$NAMESPACE" &>/dev/null; then - echo " $SECRET exists" - else - echo " ERROR: $SECRET not found" - FAILED=true - fi - done <<< "$TLS_SERVICES" - - if [ "$FAILED" = true ]; then - echo "ERROR: one or more TLS secrets are missing" - exit 1 - fi - - echo "" - echo "Final pod status in $NAMESPACE:" - oc get pods -n "$NAMESPACE" - from: cli - resources: - requests: - cpu: 100m - memory: 200Mi + - ref: oran-o2ims-wait-for-tls-pods - ref: tls-13 - ref: tls-scanner-run workflow: ipi-aws @@ -235,95 +147,7 @@ tests: TLS_13_TLS_ADHERENCE_POLICY: StrictAllComponents test: - ref: optional-operators-operator-sdk - - as: wait-for-server-pods - cli: latest - commands: | - NAMESPACE=oran-o2ims - echo "Waiting for Inventory CR to be auto-created..." - for i in $(seq 1 60); do - if oc get inventory default -n "$NAMESPACE" &>/dev/null; then - echo "Inventory CR 'default' found." - break - fi - echo " attempt $i/60..." - sleep 5 - done - - if ! oc get inventory default -n "$NAMESPACE" &>/dev/null; then - echo "ERROR: Inventory CR 'default' was not created after 5 minutes" - exit 1 - fi - - echo "" - echo "Discovering services with TLS serving certs..." - TLS_SERVICES=$(oc get services -n "$NAMESPACE" \ - -o jsonpath='{range .items[?(@.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name)]}{.metadata.name}{"\n"}{end}') - - echo "TLS services found:" - while read -r svc; do - [ -z "$svc" ] && continue - SECRET=$(oc get service "$svc" -n "$NAMESPACE" \ - -o jsonpath='{.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name}') - echo " $svc -> secret: $SECRET" - done <<< "$TLS_SERVICES" - - echo "" - echo "Waiting for TLS service pods to be ready..." - FAILED=false - while read -r svc; do - [ -z "$svc" ] && continue - SELECTOR=$(oc get service "$svc" -n "$NAMESPACE" \ - -o go-template='{{range $k,$v := .spec.selector}}{{$k}}={{$v}},{{end}}' | sed 's/,$//') - if [ -z "$SELECTOR" ]; then - echo " SKIP: $svc has no selector" - continue - fi - echo " $svc (selector: $SELECTOR)..." - if ! oc wait pods -l "$SELECTOR" -n "$NAMESPACE" \ - --for=condition=Ready --timeout=5m; then - echo " ERROR: pods for $svc did not become ready within 5m" - echo " Pod status:" - oc get pods -l "$SELECTOR" -n "$NAMESPACE" --no-headers | sed 's/^/ /' - echo " Recent events:" - oc get events -n "$NAMESPACE" --field-selector reason!=Pulling,reason!=Pulled \ - --sort-by='.lastTimestamp' 2>/dev/null | grep "$svc" | tail -5 | sed 's/^/ /' \ - || echo " (no events found)" - FAILED=true - fi - done <<< "$TLS_SERVICES" - - if [ "$FAILED" = true ]; then - echo "ERROR: one or more TLS service pods failed readiness checks" - exit 1 - fi - - echo "" - echo "Verifying TLS secrets from service-ca..." - while read -r svc; do - [ -z "$svc" ] && continue - SECRET=$(oc get service "$svc" -n "$NAMESPACE" \ - -o jsonpath='{.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name}') - if oc get secret "$SECRET" -n "$NAMESPACE" &>/dev/null; then - echo " $SECRET exists" - else - echo " ERROR: $SECRET not found" - FAILED=true - fi - done <<< "$TLS_SERVICES" - - if [ "$FAILED" = true ]; then - echo "ERROR: one or more TLS secrets are missing" - exit 1 - fi - - echo "" - echo "Final pod status in $NAMESPACE:" - oc get pods -n "$NAMESPACE" - from: cli - resources: - requests: - cpu: 100m - memory: 200Mi + - ref: oran-o2ims-wait-for-tls-pods - ref: tls-13 - ref: tls-scanner-run workflow: ipi-aws diff --git a/ci-operator/step-registry/oran-o2ims/OWNERS b/ci-operator/step-registry/oran-o2ims/OWNERS new file mode 100644 index 0000000000000..c565096d6c36f --- /dev/null +++ b/ci-operator/step-registry/oran-o2ims/OWNERS @@ -0,0 +1,8 @@ +approvers: + - alegacy + - donpenney + - rauhersu +reviewers: + - alegacy + - donpenney + - rauhersu diff --git a/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/OWNERS b/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/OWNERS new file mode 120000 index 0000000000000..ec405d65a79df --- /dev/null +++ b/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/OWNERS @@ -0,0 +1 @@ +../OWNERS \ No newline at end of file diff --git a/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/oran-o2ims-wait-for-tls-pods-commands.sh b/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/oran-o2ims-wait-for-tls-pods-commands.sh new file mode 100644 index 0000000000000..35d890ec36b17 --- /dev/null +++ b/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/oran-o2ims-wait-for-tls-pods-commands.sh @@ -0,0 +1,87 @@ +#!/bin/bash +set -o nounset +set -o errexit +set -o pipefail + +NAMESPACE="${WAIT_NAMESPACE:-oran-o2ims}" + +echo "Waiting for Inventory CR to be auto-created..." +for i in $(seq 1 60); do + if oc get inventory default -n "$NAMESPACE" &>/dev/null; then + echo "Inventory CR 'default' found." + break + fi + echo " attempt $i/60..." + sleep 5 +done + +if ! oc get inventory default -n "$NAMESPACE" &>/dev/null; then + echo "ERROR: Inventory CR 'default' was not created after 5 minutes" + exit 1 +fi + +echo "" +echo "Discovering services with TLS serving certs..." +TLS_SERVICES=$(oc get services -n "$NAMESPACE" \ + -o jsonpath='{range .items[?(@.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name)]}{.metadata.name}{"\n"}{end}') + +echo "TLS services found:" +while read -r svc; do + [ -z "$svc" ] && continue + SECRET=$(oc get service "$svc" -n "$NAMESPACE" \ + -o jsonpath='{.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name}') + echo " $svc -> secret: $SECRET" +done <<< "$TLS_SERVICES" + +echo "" +echo "Waiting for TLS service pods to be ready..." +FAILED=false +while read -r svc; do + [ -z "$svc" ] && continue + SELECTOR=$(oc get service "$svc" -n "$NAMESPACE" \ + -o go-template='{{range $k,$v := .spec.selector}}{{$k}}={{$v}},{{end}}' | sed 's/,$//') + if [ -z "$SELECTOR" ]; then + echo " SKIP: $svc has no selector" + continue + fi + echo " $svc (selector: $SELECTOR)..." + if ! oc wait pods -l "$SELECTOR" -n "$NAMESPACE" \ + --for=condition=Ready --timeout=5m; then + echo " ERROR: pods for $svc did not become ready within 5m" + echo " Pod status:" + oc get pods -l "$SELECTOR" -n "$NAMESPACE" --no-headers | sed 's/^/ /' + echo " Recent events:" + oc get events -n "$NAMESPACE" --field-selector reason!=Pulling,reason!=Pulled \ + --sort-by='.lastTimestamp' 2>/dev/null | grep "$svc" | tail -5 | sed 's/^/ /' \ + || echo " (no events found)" + FAILED=true + fi +done <<< "$TLS_SERVICES" + +if [ "$FAILED" = true ]; then + echo "ERROR: one or more TLS service pods failed readiness checks" + exit 1 +fi + +echo "" +echo "Verifying TLS secrets from service-ca..." +while read -r svc; do + [ -z "$svc" ] && continue + SECRET=$(oc get service "$svc" -n "$NAMESPACE" \ + -o jsonpath='{.metadata.annotations.service\.beta\.openshift\.io/serving-cert-secret-name}') + if oc get secret "$SECRET" -n "$NAMESPACE" &>/dev/null; then + echo " $SECRET exists" + else + echo " ERROR: $SECRET not found" + FAILED=true + fi +done <<< "$TLS_SERVICES" + +if [ "$FAILED" = true ]; then + echo "ERROR: one or more TLS secrets are missing" + exit 1 +fi + +echo "" +echo "Final pod status in $NAMESPACE:" +oc get pods -n "$NAMESPACE" diff --git a/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/oran-o2ims-wait-for-tls-pods-ref.metadata.json b/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/oran-o2ims-wait-for-tls-pods-ref.metadata.json new file mode 100644 index 0000000000000..e3c11944ef63d --- /dev/null +++ b/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/oran-o2ims-wait-for-tls-pods-ref.metadata.json @@ -0,0 +1,15 @@ +{ + "path": "oran-o2ims/wait-for-tls-pods/oran-o2ims-wait-for-tls-pods-ref.yaml", + "owners": { + "approvers": [ + "alegacy", + "donpenney", + "rauhersu" + ], + "reviewers": [ + "alegacy", + "donpenney", + "rauhersu" + ] + } +} \ No newline at end of file diff --git a/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/oran-o2ims-wait-for-tls-pods-ref.yaml b/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/oran-o2ims-wait-for-tls-pods-ref.yaml new file mode 100644 index 0000000000000..8cb0c34e2ea71 --- /dev/null +++ b/ci-operator/step-registry/oran-o2ims/wait-for-tls-pods/oran-o2ims-wait-for-tls-pods-ref.yaml @@ -0,0 +1,19 @@ +ref: + as: oran-o2ims-wait-for-tls-pods + from: cli + cli: latest + commands: oran-o2ims-wait-for-tls-pods-commands.sh + env: + - name: WAIT_NAMESPACE + default: oran-o2ims + documentation: "Namespace where the oran-o2ims operator is deployed." + resources: + requests: + cpu: 100m + memory: 200Mi + documentation: |- + Waits for the oran-o2ims Inventory CR to be auto-created, then + discovers all services with TLS serving cert annotations, waits + for their backing pods to be ready, and verifies that the + service-ca TLS secrets exist. Fails the step if any check does + not pass within the timeout.