diff --git a/mantle/kola/tests/upgrade/basic.go b/mantle/kola/tests/upgrade/basic.go index 3f506f99d0..2737df3f7d 100644 --- a/mantle/kola/tests/upgrade/basic.go +++ b/mantle/kola/tests/upgrade/basic.go @@ -209,13 +209,11 @@ func fcosUpgradeBasic(c cluster.TestCluster) { c.Run("upgrade-from-current", func(c cluster.TestCluster) { newVersion := kola.CosaBuild.Meta.OstreeVersion + ".kola" + ostreeCommit := kola.CosaBuild.Meta.OstreeCommit if usingContainer { - // until https://github.com/bootc-dev/bootc/pull/1421 propagates, we can't rely on kola.CosaBuild.Meta.OstreeCommit being the same - ostreeCommit := c.MustSSHf(m, "sudo rpm-ostree status --json | jq -r '.deployments[0].checksum'") newCommit := c.MustSSHf(m, "sudo ostree commit -b testupdate --tree=ref=%s --add-metadata-string version=%s", ostreeCommit, newVersion) rpmostreeRebase(c, m, string(newCommit), newVersion) } else { - ostreeCommit := kola.CosaBuild.Meta.OstreeCommit ostree_command := "ostree commit --repo %s -b %s --tree ref=%s --add-metadata-string version=%s " + "--keep-metadata='fedora-coreos.stream' --keep-metadata='coreos-assembler.basearch' --parent=%s" newCommit := c.MustSSHf(m, diff --git a/src/cosalib/cmdlib.py b/src/cosalib/cmdlib.py index 31e7e11db5..a85361e6b7 100644 --- a/src/cosalib/cmdlib.py +++ b/src/cosalib/cmdlib.py @@ -367,6 +367,7 @@ def import_oci_archive(parent_tmpd, ociarchive, ref): Imports layered/non-encapsulated OCI archive into the tmp/repo. Returns the OSTree commit that was imported. ''' + with tempfile.TemporaryDirectory(dir=parent_tmpd) as tmpd: subprocess.check_call(['ostree', 'init', '--repo', tmpd, '--mode=bare-user']) @@ -381,17 +382,15 @@ def import_oci_archive(parent_tmpd, ociarchive, ref): if len(blob_refs) > 0: subprocess.check_call(['ostree', 'pull-local', '--repo', tmpd, 'tmp/repo'] + blob_refs) - subprocess.check_call(['ostree', 'container', 'image', 'pull', tmpd, - f'ostree-unverified-image:oci-archive:{ociarchive}']) - - # awkwardly work around the fact that there is no --write-ref equivalent - # XXX: we can make this better once we can rely on --ostree-digestfile - # https://github.com/bootc-dev/bootc/pull/1421 - refs = subprocess.check_output(['ostree', 'refs', '--repo', tmpd, - '--list', 'ostree/container/image'], - encoding='utf-8').splitlines() - assert len(refs) == 1 - subprocess.check_call(['ostree', 'refs', '--repo', tmpd, refs[0], '--create', ref]) + subprocess.check_call(['ostree', 'container', 'image', 'pull', + '--ostree-digestfile', f'{tmpd}/digestfile', + tmpd, f'ostree-unverified-image:oci-archive:{ociarchive}']) + + # Read the digestfile and get the ref + with open(f'{tmpd}/digestfile', 'r') as f: + ostree_commit = f.read() + + subprocess.check_call(['ostree', 'refs', '--repo', tmpd, ostree_commit, '--create', ref]) subprocess.check_call(['ostree', 'refs', '--repo', 'tmp/repo', ref, '--delete']) subprocess.check_call(['ostree', 'pull-local', '--repo', 'tmp/repo', tmpd, ref]) @@ -401,7 +400,6 @@ def import_oci_archive(parent_tmpd, ociarchive, ref): encoding='utf-8').splitlines() subprocess.check_call(['ostree', 'pull-local', '--repo', 'tmp/repo', tmpd] + blob_refs) - ostree_commit = subprocess.check_output(['ostree', 'rev-parse', '--repo', 'tmp/repo', ref], encoding='utf-8').strip() return ostree_commit