Skip to content
Merged
3 changes: 1 addition & 2 deletions ci/get-ocp-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ cosa_workdir=
ocp_manifest=
output_dir=
rc=0
options=$(getopt --options h --longoptions help,cosa-workdir:,ocp-layer:,output-dir:,cleanup,create-gpg-keys -- "$@") || rc=$?
options=$(getopt --options h --longoptions help,cosa-workdir:,ocp-layer:,output-dir:,cleanup -- "$@") || rc=$?
[ $rc -eq 0 ] || print_usage_and_exit
eval set -- "$options"
while [ $# -ne 0 ]; do
Expand All @@ -83,7 +83,6 @@ while [ $# -ne 0 ]; do
--ocp-layer) ocp_manifest=$2; shift;;
--output-dir) output_dir=$2; shift;;
--cleanup) cleanup_repos; exit 0;;
--create-gpg-keys) create_gpg_keys; exit 0;;
--) break;;
*) echo "$0: invalid argument: $1" >&2; exit 1;;
esac
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, do we still need the else block at all further down ,if we are only building with OPENSHIFT_CI=1 ? i.e when we are building with cosa? If we do, then the conditional below,

 osname=$(source /usr/lib/os-release; if [ $ID == centos ]; then echo scos; fi)

also needs to accommodate the fact that ID can be scos.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, can you expand? Which else block exactly?

If we do, then the conditional below,

 osname=$(source /usr/lib/os-release; if [ $ID == centos ]; then echo scos; fi)

also needs to accommodate the fact that ID can be scos.

Hmm, not sure I follow. In what scenario will the ID be scos? Currently that's only in the okd-c9s variant, which pretty much I think we should just nuke at this point.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok i think i understand now - i was talking about the block here, but i believe we need it for the tests? Now that the OKD images are layered and we don't need okd-c9s anymore, should this be changed to c9s as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that block is still being used in the cosa path to build the base RHCOS images.

Now that the OKD images are layered and we don't need okd-c9s anymore, should this be changed to c9s as well?

I think it'll need to be reworked a bit yeah. Probably the cleanest actually is to just pass /usr/share/rpm-ostree/treefile.json since we're running from the node image which will inherit that from the base. And for the extensions manifest, probably we could auto-select between e.g. extensions-ocp.yaml and extensions-okd.yaml based on the node image we're building FROM?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes sense. I can take a look at this and try to do this.

Expand Down
18 changes: 9 additions & 9 deletions ci/prow-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ cosa_build() {
cosa fetch
# Only build the ostree image by default
cosa build ostree
# Build extensions container
}

cosa_build_extensions() {
cosa buildextend-extensions-container
}

# Build QEMU image and run all kola tests
kola_test_qemu() {
cosa buildextend-qemu
cosa kola run --parallel 2 --output-dir ${ARTIFACT_DIR:-/tmp}/kola --rerun --allow-rerun-success tags=needs-internet
cosa kola run --parallel 2 --output-dir ${ARTIFACT_DIR:-/tmp}/kola --rerun --allow-rerun-success tags=needs-internet "$@"
}

# Build metal, metal4k & live images and run kola tests
Expand Down Expand Up @@ -270,21 +272,19 @@ main() {
cosa_init "$2"
prepare_repos
;;
"build" | "init-and-build-default") # TODO: change prow job to use init-and-build-default
cosa_init "ocp-rhel-9.6"
cosa_build
;;
# this is called by cosa's CI
"rhcos-cosa-prow-pr-ci")
setup_user
cosa_init "ocp-rhel-9.6"
cosa_build
cosa_build_extensions
kola_test_qemu
;;
"rhcos-9-build-test-qemu")
setup_user
cosa_init "ocp-rhel-9.6"
cosa_build
cosa_build_extensions
kola_test_qemu
;;
"rhcos-9-build-test-metal")
Expand All @@ -301,13 +301,13 @@ main() {
;;
"scos-9-build-test-qemu")
setup_user
cosa_init "okd-c9s"
cosa_init "c9s"
cosa_build
kola_test_qemu
kola_test_qemu --tag '!openshift'
;;
"scos-9-build-test-metal")
setup_user
cosa_init "okd-c9s"
cosa_init "c9s"
cosa_build
kola_test_metal
;;
Expand Down
20 changes: 11 additions & 9 deletions extensions/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ FROM registry.ci.openshift.org/rhcos-devel/rhel-coreos:latest as os
RUN mkdir /os
WORKDIR /os
ADD . .
ARG COSA
ARG VARIANT
RUN if [[ -z "$COSA" ]] ; then ci/get-ocp-repo.sh --ocp-layer packages-openshift.yaml; else ci/get-ocp-repo.sh --create-gpg-keys; fi
RUN if [[ -n "${VARIANT}" ]]; then MANIFEST="manifest-${VARIANT}.yaml"; EXTENSIONS="extensions-${VARIANT}.yaml"; else MANIFEST="manifest.yaml"; EXTENSIONS="extensions.yaml"; fi && rpm-ostree compose extensions --rootfs=/ --output-dir=/usr/share/rpm-ostree/extensions/ ./"${MANIFEST}" ./"${EXTENSIONS}"
ARG OPENSHIFT_CI=0
ARG VARIANT=""
RUN if [ "${OPENSHIFT_CI}" != 0 ]; then ci/get-ocp-repo.sh --ocp-layer packages-openshift.yaml; fi
RUN --mount=type=secret,id=yumrepos,target=/os/secret.repo if [[ -n "${VARIANT}" ]]; then MANIFEST="manifest-${VARIANT}.yaml"; EXTENSIONS="extensions-${VARIANT}.yaml"; else MANIFEST="manifest.yaml"; EXTENSIONS="extensions.yaml"; fi && rpm-ostree compose extensions --rootfs=/ --output-dir=/usr/share/rpm-ostree/extensions/ ./"${MANIFEST}" ./"${EXTENSIONS}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make the secret always required?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's a no-op if the secret wasn't provided.


## Creates the repo metadata for the extensions.
## This uses Fedora as a lowest-common-denominator because it will work on
Expand All @@ -21,16 +21,18 @@ RUN rm -f /etc/yum.repos.d/*.repo \
RUN dnf install -y createrepo_c
RUN createrepo_c /usr/share/rpm-ostree/extensions/

# Generate extensions.json for meta.json, written to a bind-mounted path during the build.
# Generate extensions.json for meta.json.
# Use dnf repoquery to print 'name: version,' for each RPM
# sed to remove the comma from the last RPM
RUN sh -c 'echo "{" > /tmp/extensions.json && \
dnf repoquery --repofrompath=extensions,/usr/share/rpm-ostree/extensions/ \
RUN (echo "{" && \
(dnf repoquery --repofrompath=extensions,/usr/share/rpm-ostree/extensions/ \
--quiet --disablerepo=* --enablerepo=extensions \
--queryformat "\"%{name}\": \"%{evr}.%{arch}\"," | \
sed "$ s/,$//" >> /tmp/extensions.json && \
echo "}" >> /tmp/extensions.json'
sed "$ s/,$//") && echo "}") >> /usr/share/rpm-ostree/extensions.json

## Final container that has the extensions repo dir
FROM registry.access.redhat.com/ubi9/ubi:latest
COPY --from=builder /usr/share/rpm-ostree/extensions/ /usr/share/rpm-ostree/extensions/
# Make this the last layer, this is similar to the metalayer trick in the node
# image, but this one is specific to rpm-ostree extensions.
COPY --from=builder /usr/share/rpm-ostree/extensions.json /usr/share/rpm-ostree/extensions.json
4 changes: 4 additions & 0 deletions scripts/generate-metadata
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def get_rpmdb_pkglist():
rpmdb = []
for line in out.splitlines():
n, e, v, r, a = line.split()
if n == 'gpg-pubkey':
# those aren't real packages, it's just how rpm represents imported
# GPG keys
continue
# canonicalize none to 0 to match rpm-ostree semantics
if e == '(none)':
e = '0'
Expand Down