Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASM-4669 Upgrade Nexus to 3.67.1 to support image signatures #25

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

mtupitsyn
Copy link
Contributor

Summary and Scope

To support multi-platform container image uploads together with Sigstore attachments, we need to upgrade metal nexus to latest version 3.67.1. This also involves upgrade of cray-nexus-setup to 0.11.0.

Issue Type

  • Bugfix Pull Request
  • RFE Pull Request

Prerequisites

  • I have included documentation in my PR (or it is not required)
  • I tested this on internal system (if yes, please include results or a description of the test)
  • I tested this on a vshasta system (if yes, please include results or a description of the test)

Testing

  • Ran a few iterations of install/upgrade/uninstall RPM package on vShasta PIT node. Ensured that upgraded Nexus service starts up properly.
  • Ran /srv/cray/metal-provision/scripts/nexus/setup-nexus.sh script to initialize repositories and pour new content in Nexus
  • Ensured that newly uploaded images have all required components - versions for multiple platforms and sigstore attachments:
    image
    On the screenshot above, more then 1 manifest per tag denotes multi-platform images (aka "manifest lists"), and tag named sha256-*.sig denotes Sigstore attachment.

Idempotency

For better idempotency, fixed couple of bugs related to package upgrade flow:

  • RPM package install does not fail anymore if nexus or cray-nexus-setup images are already loaded into podman
  • Fixed cleanup in RPM package post-install script to remove nexus and cray-nexus-setup images properly

Risks and Mitigations

This introduces some risk since this change also brings in a newer version of Nexus, but otherwise a new functionality required by CSM 1.6 roadmap can not be achieved.

@mtupitsyn mtupitsyn requested a review from a team as a code owner April 16, 2024 20:34
@@ -50,13 +50,14 @@ Provides: pit-nexus
%define sonatype_nexus3_image artifactory.algol60.net/csm-docker/stable/docker.io/sonatype/nexus3:%{sonatype_nexus3_tag}
%define sonatype_nexus3_file sonatype-nexus3-%{sonatype_nexus3_tag}.tar

%define cray_nexus_setup_tag 0.10.1
%define cray_nexus_setup_tag 0.11.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Version 0.11.0 of cray-setup-nexus makes requests to /v1 Nexus API where previous /beta was accessed: Cray-HPE/nexus-setup#29. The /beta is not supported anymore by Nexus 3.67.1.

skopeo --override-arch amd64 --override-os linux copy docker://%{skopeo_image} docker-archive:%{skopeo_file}:%{skopeo_image}:%{skopeo_tag}
skopeo --override-arch amd64 --override-os linux copy --src-creds=%(echo $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN) docker://%{sonatype_nexus3_image} docker-archive:%{sonatype_nexus3_file}:%{sonatype_nexus3_image}
skopeo --override-arch amd64 --override-os linux copy --src-creds=%(echo $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN) docker://%{cray_nexus_setup_image} docker-archive:%{cray_nexus_setup_file}:%{cray_nexus_setup_image}
skopeo --override-arch amd64 --override-os linux copy --src-creds=%(echo $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN) docker://%{skopeo_source_image} docker-archive:%{skopeo_file}:%{skopeo_image}:%{skopeo_tag}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still package skopeo as quay.io/skopeo/stable:latest for backwards compatibility, but use different image artifactory.algol60.net/csm-docker/stable/quay.io/skopeo/stable:v1 as a source. Tag v1 ensures backward compatibility between skopeo versions. Also, we ship our image with special configuration option, which enables copying of Sigstore attachments.

skopeo --override-arch amd64 --override-os linux copy --src-creds=%(echo $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN) docker://%{sonatype_nexus3_image} docker-archive:%{sonatype_nexus3_file}
skopeo --override-arch amd64 --override-os linux copy --src-creds=%(echo $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN) docker://%{cray_nexus_setup_image} docker-archive:%{cray_nexus_setup_file}
skopeo --override-arch amd64 --override-os linux copy docker://%{skopeo_image} docker-archive:%{skopeo_file}:%{skopeo_image}:%{skopeo_tag}
skopeo --override-arch amd64 --override-os linux copy --src-creds=%(echo $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN) docker://%{sonatype_nexus3_image} docker-archive:%{sonatype_nexus3_file}:%{sonatype_nexus3_image}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting image name here allows to avoid searching for image name/tag after podman load. Image already comes properly tagged after podman load.

skopeo --override-arch amd64 --override-os linux copy --src-creds=%(echo $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN) docker://%{cray_nexus_setup_image} docker-archive:%{cray_nexus_setup_file}
skopeo --override-arch amd64 --override-os linux copy docker://%{skopeo_image} docker-archive:%{skopeo_file}:%{skopeo_image}:%{skopeo_tag}
skopeo --override-arch amd64 --override-os linux copy --src-creds=%(echo $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN) docker://%{sonatype_nexus3_image} docker-archive:%{sonatype_nexus3_file}:%{sonatype_nexus3_image}
skopeo --override-arch amd64 --override-os linux copy --src-creds=%(echo $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN) docker://%{cray_nexus_setup_image} docker-archive:%{cray_nexus_setup_file}:%{cray_nexus_setup_image}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting image name here allows to avoid searching for image name/tag after podman load. Image already comes properly tagged after podman load.

@@ -121,8 +122,8 @@ rm -f \
%service_del_postun nexus.service
podman stop nexus || echo 'No nexus container was running, nothing to stop.'
podman rm nexus || echo 'No nexus container was created, nothing to delete.'
podman rmi %{sonatype_nexus3_image}:%{sonatype_nexus3_tag} || echo 'No nexus image was loaded, nothing to remove.'
podman rmi %{cray_nexus_setup_image}:%{cray_nexus_setup_tag} || echo 'No nexus image was loaded, nothing to remove.'
podman rmi %{sonatype_nexus3_image} || echo 'No nexus image was loaded, nothing to remove.'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tag is already part of %{sonatype_nexus3_image} var.

podman rmi %{sonatype_nexus3_image}:%{sonatype_nexus3_tag} || echo 'No nexus image was loaded, nothing to remove.'
podman rmi %{cray_nexus_setup_image}:%{cray_nexus_setup_tag} || echo 'No nexus image was loaded, nothing to remove.'
podman rmi %{sonatype_nexus3_image} || echo 'No nexus image was loaded, nothing to remove.'
podman rmi %{cray_nexus_setup_image} || echo 'No nexus image was loaded, nothing to remove.'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tag is already part of %{scray_nexus_setup_image} var.

podman load -i "$NEXUS_IMAGE_PATH" || exit
# get the tag
NEXUS_IMAGE_ID=$(podman images --noheading --format "{{.Id}}" --filter label="name=Nexus Repository Manager")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may not work properly, if there are more then 1 nexus images in podman. Anyway it's not needed anymore, because image comes already tagged after change in packaging.

podman load -i "$NEXUS_IMAGE_PATH"
# get the tag
NEXUS_IMAGE_ID=$(podman images --noheading --format "{{.Id}}" --filter label="name=Nexus Repository Manager")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may not work properly, if there are more then 1 nexus images in podman. Anyway it's not needed anymore, because image comes already tagged after change in packaging.

podman load -i "$NEXUS_SETUP_IMAGE_PATH" || exit
# get the image id
CRAY_NEXUS_SETUP_ID=$(podman images --noheading --format "{{.Id}}" --filter label="org.label-schema.name=cray-nexus-setup")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may not work properly, if there are more then 1 cray-nexus-setup images in podman. Anyway it's not needed anymore, because image comes already tagged after change in packaging.

@jpdavis-prof jpdavis-prof merged commit 783f97a into main Apr 17, 2024
2 of 3 checks passed
@jpdavis-prof jpdavis-prof deleted the feature/image-signatures branch April 17, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants