From b18b4e80a09a9741c3a6ab3adeec77927535b024 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Sat, 28 Aug 2021 15:58:39 +0200 Subject: [PATCH] distro/{rhel86,rhel90}: specify a remote for deployments When deploying an ostree commit, specify a remote, currently hard- coded to `rhel-edge`, so that updates work automatically, if they are served from the same location as the initial commit is pulled from. NB: now that the remote is specified in the raw image, remove the corresponding bits form the tests. Signed-off-by: Antonio Murdaca --- internal/distro/rhel86/pipelines.go | 19 ++++++++++++++++++- internal/distro/rhel90/pipelines.go | 19 ++++++++++++++++++- test/cases/ostree-raw-image.sh | 5 ----- test/cases/ostree-simplified-installer.sh | 5 ----- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/internal/distro/rhel86/pipelines.go b/internal/distro/rhel86/pipelines.go index 0d83fd1ba..4e1d87908 100644 --- a/internal/distro/rhel86/pipelines.go +++ b/internal/distro/rhel86/pipelines.go @@ -790,10 +790,11 @@ func ostreeDeployPipeline( p.Name = "image-tree" p.Build = "name:build" osname := "redhat" + remote := "rhel-edge" p.AddStage(osbuild.OSTreeInitFsStage()) p.AddStage(osbuild.NewOSTreePullStage( - &osbuild.OSTreePullStageOptions{Repo: repoPath}, + &osbuild.OSTreePullStageOptions{Repo: repoPath, Remote: remote}, ostreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref), )) p.AddStage(osbuild.NewOSTreeOsInitStage( @@ -807,6 +808,7 @@ func ostreeDeployPipeline( &osbuild.OSTreeDeployStageOptions{ OsName: osname, Ref: options.OSTree.Ref, + Remote: remote, Mounts: []string{"/boot", "/boot/efi"}, Rootfs: osbuild.Rootfs{ Label: "root", @@ -817,6 +819,21 @@ func ostreeDeployPipeline( }, }, )) + + if options.OSTree.URL != "" { + p.AddStage(osbuild.NewOSTreeRemotesStage( + &osbuild.OSTreeRemotesStageOptions{ + Repo: "/ostree/repo", + Remotes: []osbuild.OSTreeRemote{ + { + Name: remote, + URL: options.OSTree.URL, + }, + }, + }, + )) + } + p.AddStage(osbuild.NewOSTreeFillvarStage( &osbuild.OSTreeFillvarStageOptions{ Deployment: osbuild.OSTreeDeployment{ diff --git a/internal/distro/rhel90/pipelines.go b/internal/distro/rhel90/pipelines.go index ec73c957c..e9dddb138 100644 --- a/internal/distro/rhel90/pipelines.go +++ b/internal/distro/rhel90/pipelines.go @@ -786,10 +786,11 @@ func ostreeDeployPipeline( p.Name = "image-tree" p.Build = "name:build" osname := "redhat" + remote := "rhel-edge" p.AddStage(osbuild.OSTreeInitFsStage()) p.AddStage(osbuild.NewOSTreePullStage( - &osbuild.OSTreePullStageOptions{Repo: repoPath}, + &osbuild.OSTreePullStageOptions{Repo: repoPath, Remote: remote}, ostreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref), )) p.AddStage(osbuild.NewOSTreeOsInitStage( @@ -803,6 +804,7 @@ func ostreeDeployPipeline( &osbuild.OSTreeDeployStageOptions{ OsName: osname, Ref: options.OSTree.Ref, + Remote: remote, Mounts: []string{"/boot", "/boot/efi"}, Rootfs: osbuild.Rootfs{ Label: "root", @@ -813,6 +815,21 @@ func ostreeDeployPipeline( }, }, )) + + if options.OSTree.URL != "" { + p.AddStage(osbuild.NewOSTreeRemotesStage( + &osbuild.OSTreeRemotesStageOptions{ + Repo: "/ostree/repo", + Remotes: []osbuild.OSTreeRemote{ + { + Name: remote, + URL: options.OSTree.URL, + }, + }, + }, + )) + } + p.AddStage(osbuild.NewOSTreeFillvarStage( &osbuild.OSTreeFillvarStageOptions{ Deployment: osbuild.OSTreeDeployment{ diff --git a/test/cases/ostree-raw-image.sh b/test/cases/ostree-raw-image.sh index f49471fb2..b502a1f32 100755 --- a/test/cases/ostree-raw-image.sh +++ b/test/cases/ostree-raw-image.sh @@ -604,11 +604,6 @@ until [ "$(sudo podman inspect -f '{{.State.Running}}' rhel-edge)" == "true" ]; sleep 1; done; -# Workaround to https://github.com/osbuild/osbuild-composer/issues/1693 -greenprint "🗳 Add external prod edge repo" -sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" admin@${UEFI_GUEST_ADDRESS} "echo ${EDGE_USER_PASSWORD} |sudo -S ostree remote add --no-gpg-verify --no-sign-verify rhel-edge ${PROD_REPO_URL}" -sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" admin@${UEFI_GUEST_ADDRESS} "echo ${EDGE_USER_PASSWORD} |sudo -S ostree admin switch rhel-edge:${OSTREE_REF}" - # Pull upgrade to prod mirror greenprint "⛓ Pull upgrade to prod mirror" sudo ostree --repo="$PROD_REPO" pull --mirror edge-stage "$OSTREE_REF" diff --git a/test/cases/ostree-simplified-installer.sh b/test/cases/ostree-simplified-installer.sh index 4afd927d8..bac2270e4 100755 --- a/test/cases/ostree-simplified-installer.sh +++ b/test/cases/ostree-simplified-installer.sh @@ -662,11 +662,6 @@ until [ "$(sudo podman inspect -f '{{.State.Running}}' rhel-edge)" == "true" ]; sleep 1; done; -# Workaround to https://github.com/osbuild/osbuild-composer/issues/1693 -greenprint "🗳 Add external prod edge repo" -sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" admin@${UEFI_GUEST_ADDRESS} "echo ${EDGE_USER_PASSWORD} |sudo -S ostree remote add --no-gpg-verify --no-sign-verify rhel-edge ${PROD_REPO_URL}" -sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" admin@${UEFI_GUEST_ADDRESS} "echo ${EDGE_USER_PASSWORD} |sudo -S ostree admin switch rhel-edge:${OSTREE_REF}" - # Pull upgrade to prod mirror greenprint "⛓ Pull upgrade to prod mirror" sudo ostree --repo="$PROD_REPO" pull --mirror edge-stage "$OSTREE_REF"