Step: operator-pipelines-preflight-common-check

This step will execute the Preflight utility against a target certification test asset. Preflight STDOUT is suppressed, and log file always pushed to the SHARED_DIR as a tarball called preflight.tar.gz. This is to encourage the secure transmission of those assets in a follow up step for this task. Optionally, setting PUBLISH_ARTIFACTS=true when calling this task will immediately push preflight artifacts and logfiles to the ARTIFACT_DIR which is searchable on prow.ci.openshift.org.

Container image used for this step: ci/openshift-preflight:latest

ci/openshift-preflight:latest resolves to an image imported from the specified imagestream tag on the build farm (documentation).

Environment

In addition to the default environment, the step exposes the following:

Variable Name Type Variable Content
TEST_ASSET Parameter[?] The asset under test by the preflight utility.
ASSET_TYPE Parameter[?] The type of asset under test. One of "container" or "operator".
PFLT_INDEXIMAGE Parameter[?] The index image containing an operator bundle under test. Used for the "operator" asset type.
PFLT_LOGLEVEL Parameter[?] The log verbosity. One of "info", "error", "debug", "trace". (default: trace)
PFLT_ARTIFACTS Parameter[?] Where Preflight will write artifacts locally.
PUBLISH_ARTIFACTS Parameter[?] Whether preflight will publish its artifacts, preflight.log, and results.json to ARTIFACT_DIR. (default: false)

Source Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash

# This step will execute preflight against the provided asset.
# https://github.com/redhat-openshift-ecosystem/openshift-preflight
#
# Expects env vars:
#    ASSET_TYPE:            The asset type, which correlates with the 
#                           preflight policy that is to be executed.
#                           Options: container, operator
#    TEST_ASSET:            The asset to test with the preflight utility.
#                           Must include the registry and the tag/digest.
#                           Ex. quay.io/example/some-container:0.0.1
#    PFLT_INDEXIMAGE:       The index image containing the bundle under test
#                           if testing an operator.
#    PFLT_LOGLEVEL          The log verbosity. One of "info", "error", "debug",
#                           "trace".
#    PFLT_ARTIFACTS         Where Preflight will write artifacts.
#    PUBLISH_ARTIFACTS      Whether to publish preflight's plaintext artifacts/*, results.json, 
#                           and preflight.log to this job's log on prow.ci.openshift.org.
#                           Options: true, false

# Check for the expected asset types, or otherwise fail.
rc=$([ "${ASSET_TYPE}" == "container" ] || [ "${ASSET_TYPE}" == "operator" ]; echo $?)
[ "$rc" -ne 0 ] && { echo "ERR An incorrect asset type was provided. Expecting 'container' or 'operator'."; exit 1 ;}

# Go to a temporary directory to write
WORKDIR=$(mktemp -d)
cd "${WORKDIR}" || exit 2

preflight_targz_file="${SHARED_DIR}/preflight.tar.gz"
preflight_stdout_file="${WORKDIR}/preflight.stdout"
preflight_stderr_file="${WORKDIR}/preflight.stderr"

export PFLT_ARTIFACTS
export PFLT_INDEXIMAGE
export PFLT_LOGLEVEL

if [ -f "${SHARED_DIR}/decrypted_config.json" ]; then
    export PFLT_DOCKERCONFIG="${SHARED_DIR}/decrypted_config.json"
fi

echo "Running Preflight."
preflight check "${ASSET_TYPE}" "${TEST_ASSET}" > "${preflight_stdout_file}" 2> "${preflight_stderr_file}"

if [ "${PUBLISH_ARTIFACTS}" == "true" ]; then 
    echo "PUBLIC_ARTIFACTS is set to true. Publishing all artifacts."
    cp -a "${PFLT_ARTIFACTS}" "${ARTIFACT_DIR}"/
    cp -a preflight.log "${ARTIFACT_DIR}"/    
    cp -a "${preflight_stdout_file}" "${ARTIFACT_DIR}"/
    cp -a "${preflight_stderr_file}" "${ARTIFACT_DIR}"/
fi

echo "Placing assets into ${preflight_targz_file} for any future CI tasks."
# assumes we're in WORKDIR and strips full paths where appropriate.
tar czvf "${preflight_targz_file}" "$PFLT_ARTIFACTS" preflight.log "$(basename "${preflight_stdout_file}")"  "$(basename "${preflight_stderr_file}")"

echo "Preflight execution completed."
exit 0

Properties

Property Value Description
Resource requests (cpu) 1000m Used in .resources.requests of the pod running this step.
Resource requests (memory) 400Mi Used in .resources.requests of the pod running this step.

GitHub Link:

https://github.com/openshift/release/blob/master/ci-operator/step-registry/operator-pipelines/preflight-common/check/operator-pipelines-preflight-common-check-ref.yaml

Owners:

Approvers:

Source code for this page located on GitHub