Skip to content

Commit a719f44

Browse files
authored
Adding RedHat OpenShift container preflight testing (#803)
1 parent ca3618e commit a719f44

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,6 @@ preflight: ## Run the OpenShift preflight tests against the Operator Image in a
12421242
--env KUBECONFIG=/kubeconfig/config \
12431243
--env PFLT_DOCKERCONFIG=/dockerconfig/$(PREFLIGHT_REGISTRY_AUTH_JSON) \
12441244
--env PFLT_LOGLEVEL=trace \
1245-
--env PFLT_CHANNEL=beta \
12461245
--env PFLT_LOGFILE=/artifacts/preflight.log \
12471246
-v $(BUILD_PREFLIGHT):/artifacts \
12481247
-v $(HOME)/.kube/:/kubeconfig:ro \

hack/openshift/operator-cert.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,21 @@ LATEST_RELEASE=""
168168
if [ "${USE_LATEST_OPERATOR_RELEASE}" = "true" ]; then
169169
# delete the old local repo to force a new one to be cloned
170170
rm -rf "${BUILD_DIR}/certified-operators"
171-
# Use a proper name for git branch
172-
GIT_CERT_BRANCH="release-${OPERATOR_VERSION}"
173171
# Find the latest release of the Coherence Operator on GitHub
174172
LATEST_RELEASE=$(gh release list --repo oracle/coherence-operator --json name,isLatest --jq '.[] | select(.isLatest)|.name')
175173
# Strip the v from the front of the release to give the Operator version
176174
OPERATOR_VERSION=${LATEST_RELEASE#"v"}
177175
echo "Latest Operator version is ${OPERATOR_VERSION}"
176+
# Check the latest release image exists on OCR
177+
COHERENCE_OPERATOR_IMAGE="container-registry.oracle.com/middleware/coherence-operator:${OPERATOR_VERSION}"
178+
echo "Checking Oracle Container Registry for image ${OCR_COHERENCE_IMAGE}"
179+
podman manifest inspect "${OCR_COHERENCE_IMAGE}" > /dev/null
180+
if [ $? -ne 0 ]; then
181+
echo "ERROR: Image ${OCR_COHERENCE_IMAGE} does not exist on OCR."
182+
exit 1
183+
fi
184+
# Use a proper name for the git branch
185+
GIT_CERT_BRANCH="release-${OPERATOR_VERSION}"
178186
# Set the upstream repo for the pull request to be the official RedHat repo
179187
UPSTREAM_REPO_NAME=redhat-openshift-ecosystem/certified-operators
180188
# make sure the certified-operators repo in Coherence Community is sync'ed with the RedHat repo
@@ -184,6 +192,7 @@ else
184192
OPERATOR_VERSION=$(cat "${BUILD_DIR}/_output/version.txt")
185193
# We will not be submitting results
186194
SUBMIT_RESULTS=false
195+
COHERENCE_OPERATOR_IMAGE="${REGISTRY_HOST}/${REGISTRY_NAMESPACE}/coherence-operator:${OPERATOR_VERSION}"
187196
fi
188197
189198
if [ -z "${OPERATOR_VERSION:-}" ]; then

hack/openshift/run-preflight.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2020, 2025, Oracle and/or its affiliates.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at
5+
# http://oss.oracle.com/licenses/upl.
6+
#
7+
8+
ROOT_DIR=$(pwd)
9+
BUILD_DIR="${ROOT_DIR}/build"
10+
OUTPUT_DIR="${BUILD_DIR}/_output"
11+
12+
mkdir -p "${OUTPUT_DIR}" || true
13+
14+
if [ -z "${SUBMIT_RESULTS:-}" ]; then
15+
SUBMIT_RESULTS=false
16+
fi
17+
18+
if [ "${SUBMIT_RESULTS}" = "true" ]; then
19+
if [ -z "${OPENSHIFT_API_KEY:-}" ]; then
20+
echo "Error: SUBMIT_RESULTS is set to 'true' but OPENSHIFT_API_KEY is not set"
21+
exit 1
22+
fi
23+
if [ -z "${OPENSHIFT_IMAGE_COMPONENT_ID:-}" ]; then
24+
OPENSHIFT_IMAGE_COMPONENT_ID="67bdf00eb9f79dcdb25aa8e2"
25+
fi
26+
EXTRA_ARGS="--pyxis-api-token=${OPENSHIFT_API_KEY} --certification-component-id=${OPENSHIFT_IMAGE_COMPONENT_ID}"
27+
else
28+
EXTRA_ARGS=""
29+
fi
30+
31+
if [ "${USE_LATEST_OPERATOR_RELEASE}" = "true" ]; then
32+
echo "Run preflight on latest release"
33+
# Find the latest release of the Coherence Operator on GitHub
34+
LATEST_RELEASE=$(gh release list --repo oracle/coherence-operator --json name,isLatest --jq '.[] | select(.isLatest)|.name')
35+
# Strip the v from the front of the release to give the Operator version
36+
OPERATOR_VERSION=${LATEST_RELEASE#"v"}
37+
echo "Latest Operator version is ${OPERATOR_VERSION}"
38+
# Check the latest release image exists on OCR
39+
COHERENCE_OPERATOR_IMAGE="container-registry.oracle.com/middleware/coherence-operator:${OPERATOR_VERSION}"
40+
echo "Checking Oracle Container Registry for image ${COHERENCE_OPERATOR_IMAGE}"
41+
docker manifest inspect "${COHERENCE_OPERATOR_IMAGE}" > /dev/null
42+
if [ $? -ne 0 ]; then
43+
echo "ERROR: Image ${COHERENCE_OPERATOR_IMAGE} does not exist on OCR."
44+
exit 1
45+
fi
46+
else
47+
echo "Run preflight on latest build"
48+
# We are just testing a local build, so use the current version
49+
OPERATOR_VERSION=$(cat "${BUILD_DIR}/_output/version.txt")
50+
# We will not be submitting results
51+
SUBMIT_RESULTS=false
52+
COHERENCE_OPERATOR_IMAGE="${REGISTRY_HOST}/${REGISTRY_NAMESPACE}/coherence-operator:${OPERATOR_VERSION}"
53+
fi
54+
55+
echo "Running preflight on ${COHERENCE_OPERATOR_IMAGE}"
56+
57+
PREFLIGHT_LOG="${OUTPUT_DIR}/preflight.log"
58+
preflight check container --submit="${SUBMIT_RESULTS}" --logfile="${PREFLIGHT_LOG}" ${EXTRA_ARGS} ${COHERENCE_OPERATOR_IMAGE}

0 commit comments

Comments
 (0)