Skip to content

Commit f6b9a30

Browse files
committed
[ISV-2398] Implement process to check image signature before release.
This splits up the IIB process of adding bundle images to index and copying the images to the published repo into two separate steps, so that images will not be published before they're signed.
1 parent 15bbdfb commit f6b9a30

File tree

7 files changed

+183
-184
lines changed

7 files changed

+183
-184
lines changed

ansible/roles/operator-pipeline/templates/openshift/pipelines/operator-release-pipeline.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ spec:
438438
- name: connect_registry
439439
value: "$(tasks.set-env.results.connect_registry)"
440440

441-
# call IIB to publish the bundle
442-
- name: publish-bundle
441+
# call IIB to add the bundle to index
442+
- name: add-bundle-to-index
443443
runAfter:
444444
- publish-resources
445445
- get-supported-versions
@@ -449,16 +449,14 @@ spec:
449449
values:
450450
- undistributed
451451
taskRef:
452-
name: publish-bundle
452+
name: add-bundle-to-index
453453
params:
454454
- name: pipeline_image
455455
value: "$(params.pipeline_image)"
456456
- name: index_images
457457
value: "$(tasks.get-supported-versions.results.indices)"
458458
- name: bundle_pullspec
459459
value: "$(tasks.publish-to-ocp-registry.results.image_pullspec)"
460-
- name: operator_distribution_method
461-
value: *operatorDistribution
462460
- name: iib_url
463461
value: "$(tasks.set-env.results.iib_url)"
464462
- name: environment
@@ -471,20 +469,17 @@ spec:
471469
# use manifest list digests from IIB output and get the manifest digests from registry
472470
- name: get-manifest-digests
473471
runAfter:
474-
- publish-bundle
472+
- add-bundle-to-index
475473
when: *whenNotUndistributed
476474
taskRef:
477475
name: get-manifest-digests
478476
params:
479477
- name: pipeline_image
480478
value: "$(params.pipeline_image)"
481-
- name: manifest_list_digests
482-
value: "$(tasks.publish-bundle.results.manifest_list_digests)"
479+
- name: index_image_paths
480+
value: "$(tasks.add-bundle-to-index.results.index_image_paths)"
483481
- name: environment
484482
value: "$(params.env)"
485-
workspaces:
486-
- name: registry-credentials
487-
workspace: registry-pull-credentials
488483

489484
# send UMB message for RADAS to sign the container image
490485
- name: request-signature
@@ -551,6 +546,22 @@ spec:
551546
workspace: repository
552547
subPath: signing
553548

549+
- name: publish-to-index
550+
runAfter:
551+
- upload-signature
552+
when: *whenNotUndistributed
553+
taskRef:
554+
name: publish-to-index
555+
params:
556+
- name: pipeline_image
557+
value: "$(params.pipeline_image)"
558+
- name: index_image_paths
559+
value: "$(tasks.add-bundle-to-index.results.index_image_paths)"
560+
- name: environment
561+
value: "$(params.env)"
562+
- name: operator_distribution_method
563+
value: *operatorDistribution
564+
554565

555566
finally:
556567

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
apiVersion: tekton.dev/v1beta1
3+
kind: Task
4+
metadata:
5+
name: add-bundle-to-index
6+
spec:
7+
params:
8+
- name: pipeline_image
9+
- name: bundle_pullspec
10+
description: Bundle pullspec
11+
- name: index_images
12+
description: All known supported index image pull specs (space separated)
13+
- name: iib_url
14+
description: IIB API url
15+
default: https://iib.engineering.redhat.com
16+
- name: kerberos_keytab_secret_name
17+
description: >-
18+
The name of the Kubernetes Secret that contains the kerberos keytab for submitting IIB builds.
19+
- name: kerberos_keytab_secret_key
20+
description: >-
21+
The key within the Kubernetes Secret that contains the kerberos keytab for submitting IIB builds.
22+
- name: environment
23+
description: |
24+
Which environment the pipeline is running in. Can be one of [dev, qa, stage, prod]
25+
results:
26+
- name: index_image_paths
27+
description: Comma-separated list of index reference + temporary location of the unpublished images generated by IIB builds
28+
- name: status
29+
description: Indicates a status of adding a bundle to an index
30+
volumes:
31+
- name: kerberos-volume
32+
secret:
33+
secretName: "$(params.kerberos_keytab_secret_name)"
34+
steps:
35+
- name: add-bundle-to-index
36+
image: "$(params.pipeline_image)"
37+
env:
38+
- name: KRB_KEYTAB_FILE
39+
value: "/etc/kerberos/$(params.kerberos_keytab_secret_key)"
40+
volumeMounts:
41+
- name: kerberos-volume
42+
readOnly: true
43+
mountPath: "/etc/kerberos"
44+
script: |
45+
#! /usr/bin/env bash
46+
set -xe
47+
48+
ENV=$(params.environment)
49+
INDEX_IMAGES="$(params.index_images)"
50+
if [[ $ENV == "dev" || $ENV == "qa" ]]; then
51+
echo "Adding bundle to an index is a NOOP for dev and qa environments at this time."
52+
echo -n "success" | tee "$(results.status.path)"
53+
# output dummy/test values for following tasks
54+
echo -n "$(params.bundle_pullspec)" | tee "$(results.index_image_paths.path)"
55+
exit 0
56+
fi
57+
58+
if [[ $ENV != "prod" ]]; then
59+
# Replace registry urls with stage urls when in preprod
60+
INDEX_IMAGES=${INDEX_IMAGES//registry.redhat.io/registry.stage.redhat.io}
61+
fi
62+
63+
# DO NOT use `--verbose` to avoid auth headers appearing in logs
64+
index \
65+
--iib-url "$(params.iib_url)" \
66+
--indices $INDEX_IMAGES \
67+
--bundle-pullspec "$(params.bundle_pullspec)" \
68+
--image-output index-image-paths.txt
69+
70+
71+
echo -n "success" | tee "$(results.status.path)"
72+
cat index-image-paths.txt | tee "$(results.index_image_paths.path)"

ansible/roles/operator-pipeline/templates/openshift/tasks/get-manifest-digests.yml

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ metadata:
55
name: get-manifest-digests
66
spec:
77
params:
8-
- name: manifest_list_digests
8+
- name: index_image_paths
99
description: |
10-
Comma-separated list of manifest list digests generated by the IIB builds, in the
11-
format of registry.redhat.io/redhat/test-index@sha256:123
10+
Comma-separated list of index reference + manifest list digests generated by IIB
11+
builds, in the format of <from_index>+<temp_index_image>, example:
12+
registry.redhat.io/redhat/test-index:v4.6+registry-proxy.engineering.redhat.com/rh-osbs/iib@sha256:123
1213
- name: environment
1314
description: |
1415
Which environment the pipeline is running in. Can be one of [dev, qa, stage, prod]
@@ -18,9 +19,6 @@ spec:
1819
description: Comma-separated list of indices
1920
- name: manifest_digests
2021
description: Comma-separated list of manifest digests retrieved from registry
21-
workspaces:
22-
- name: registry-credentials
23-
description: Docker config for retrieving the bundle image
2422
steps:
2523
- name: podman-manifest-inspect
2624
image: "$(params.pipeline_image)"
@@ -33,35 +31,20 @@ spec:
3331
# output dummy/test values for signing purposes
3432
if [[ $ENV == "dev" || $ENV == "qa" ]]; then
3533
echo -n "registry.redhat.io/redhat/test-operator-index:v4.9" | tee "$(results.docker_references.path)"
36-
echo "$(params.manifest_list_digests)" | awk -F '@' '{print $2}' | tee "$(results.manifest_list_digests.path)"
34+
echo "$(params.index_image_paths)" | awk -F '+' '{print $2}' | tee "$(results.manifest_digests.path)"
3735
echo "Getting manifest digests is a NOOP for dev and qa environments at this time."
3836
exit 0
3937
fi
4038
41-
DIGEST_LIST=$(echo $(params.manifest_list_digests) | tr "," " ")
42-
43-
if [[ $ENV != "prod" ]]; then
44-
export HTTP_PROXY="http://squid.corp.redhat.com:3128"
45-
export HTTPS_PROXY="http://squid.corp.redhat.com:3128"
46-
47-
# TODO find a better way to set registry based on env
48-
# Replace registry urls with stage urls when in preprod
49-
DIGEST_LIST=${DIGEST_LIST//registry.redhat.io/registry.stage.redhat.io}
50-
fi
51-
52-
# podman manifest inspect doesn't support any of the authfile options, this is the only way
53-
cp $(workspaces.registry-credentials.path)/.dockerconfigjson $HOME/.docker/config.json
39+
DIGEST_LIST=$(echo $(params.index_image_paths) | tr "," " ")
5440
5541
DOCKER_REFERENCES=""
5642
MANIFEST_DIGESTS=""
5743
for i in $DIGEST_LIST
5844
do
59-
REFERENCE=$(echo $i | awk -F '@' '{print $1}')
60-
61-
# remove version from reference before combining with sha
62-
DIGEST=$(echo $REFERENCE | awk -F ':' '{print $1}')
63-
DIGEST+=@$(echo $i | awk -F '@' '{print $2}')
45+
REFERENCE=$(echo $i | awk -F '+' '{print $1}')
6446
47+
DIGEST=$(echo $i | awk -F '+' '{print $2}')
6548
6649
MANIFEST_LIST=$(podman manifest inspect $DIGEST)
6750
MANIFEST_LIST=$(echo $MANIFEST_LIST | jq -r '.manifests[].digest')

ansible/roles/operator-pipeline/templates/openshift/tasks/publish-bundle.yml renamed to ansible/roles/operator-pipeline/templates/openshift/tasks/publish-to-index.yml

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,23 @@
22
apiVersion: tekton.dev/v1beta1
33
kind: Task
44
metadata:
5-
name: publish-bundle
5+
name: publish-to-index
66
spec:
77
params:
88
- name: pipeline_image
9-
- name: bundle_pullspec
10-
description: Bundle pullspec
11-
- name: index_images
12-
description: All known supported index image pull specs (space separated)
13-
- name: iib_url
14-
description: IIB API url
15-
default: https://iib.engineering.redhat.com
16-
- name: kerberos_keytab_secret_name
17-
description: >-
18-
The name of the Kubernetes Secret that contains the kerberos keytab for submitting IIB builds.
19-
- name: kerberos_keytab_secret_key
20-
description: >-
21-
The key within the Kubernetes Secret that contains the kerberos keytab for submitting IIB builds.
22-
- name: operator_distribution_method
23-
description: Operator distribution method. Can be one of [connect, marketplace]
9+
- name: index_image_paths
10+
description: |
11+
Comma-separated list of index reference + manifest list digests generated by IIB
12+
builds, in the format of <from_index>+<temp_index_image>, example:
13+
registry.redhat.io/redhat/test-index:v4.6+registry-proxy.engineering.redhat.com/rh-osbs/iib@sha256:123
2414
- name: environment
2515
description: |
2616
Which environment the pipeline is running in. Can be one of [dev, qa, stage, prod]
27-
results:
28-
- name: manifest_list_digests
29-
description: Comma-separated list of image name + manifest list digests generated by the IIB builds
30-
- name: status
31-
description: Indicates a status of publishing a bundle to an index
32-
volumes:
33-
- name: kerberos-volume
34-
secret:
35-
secretName: "$(params.kerberos_keytab_secret_name)"
17+
- name: operator_distribution_method
18+
description: Operator distribution method. Can be one of [connect, marketplace]
3619
steps:
37-
- name: publish-bundle
20+
- name: skopeo-copy
21+
# Pipeline image is needed for Red Hat internal SSL cert
3822
image: "$(params.pipeline_image)"
3923
env:
4024
- name: QUAY_USER
@@ -47,20 +31,14 @@ spec:
4731
secretKeyRef:
4832
name: iib-quay-credentials
4933
key: password
50-
- name: KRB_KEYTAB_FILE
51-
value: "/etc/kerberos/$(params.kerberos_keytab_secret_key)"
5234
- name: DIST_METHOD
5335
value: "$(params.operator_distribution_method)"
54-
volumeMounts:
55-
- name: kerberos-volume
56-
readOnly: true
57-
mountPath: "/etc/kerberos"
5836
script: |
5937
#! /usr/bin/env bash
60-
set -xe
38+
# DO NOT USE `set -x`, to avoid revealing the quay token in logs!
39+
set -e
6140
6241
# select the correct index
63-
6442
case "$(params.environment)" in
6543
prod)
6644
case $DIST_METHOD in
@@ -93,20 +71,28 @@ spec:
9371
*)
9472
echo "Publishing bundle to an index is a NOOP for dev and qa environments at this time."
9573
echo -n "success" | tee "$(results.status.path)"
96-
# output dummy/test values for signing purposes
97-
echo -n "$(params.bundle_pullspec)" | tee "$(results.manifest_list_digests.path)"
9874
exit 0
9975
;;
10076
esac
10177
102-
# DO NOT use `--verbose` to avoid auth headers appearing in logs
103-
index \
104-
--iib-url "$(params.iib_url)" \
105-
--from-index $FROM_INDEX \
106-
--indices $(params.index_images) \
107-
--bundle-pullspec "$(params.bundle_pullspec)" \
108-
--output manifest-list-digests.txt
78+
echo "FROM_INDEX: $FROM_INDEX"
79+
echo "Copying index images to published repos..."
80+
81+
TEMP_IMAGES=$(echo $(params.index_image_paths) | tr "," " ")
10982
83+
for i in $TEMP_IMAGES
84+
do
85+
SRC_IMAGE=$(echo $i | awk -F '+' '{print $2}')
86+
echo "Source image: $SRC_IMAGE"
87+
VERSION=$(echo $i | awk -F '+' '{print $1}' | awk -F ':' '{print $2}')
88+
DEST_IMAGE="${FROM_INDEX}:${VERSION}"
89+
echo "Dest image: $DEST_IMAGE"
11090
111-
echo -n "success" | tee "$(results.status.path)"
112-
cat manifest-list-digests.txt | tee "$(results.manifest_list_digests.path)"
91+
skopeo \
92+
--command-timeout 300s copy \
93+
--format v2s2 --all \
94+
--src-no-creds \
95+
--dest-creds $QUAY_USER:$QUAY_TOKEN \
96+
docker://$SRC_IMAGE \
97+
docker://$DEST_IMAGE
98+
done

operator-pipeline-images/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ RUN dnf update -y && \
3838
pinentry \
3939
pip \
4040
podman \
41-
python3-devel && \
41+
python3-devel \
42+
skopeo && \
4243
dnf clean all
4344

4445
COPY operator-pipeline-images/config/krb5.conf /etc/krb5.conf

0 commit comments

Comments
 (0)