Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions mantle/kola/tests/upgrade/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 11 additions & 12 deletions src/cosalib/cmdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ 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.
'''

ostree_commit = ''
with tempfile.TemporaryDirectory(dir=parent_tmpd) as tmpd:
subprocess.check_call(['ostree', 'init', '--repo', tmpd, '--mode=bare-user'])

Expand All @@ -381,17 +383,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'{parent_tmpd}/digestfile',
tmpd, f'ostree-unverified-image:oci-archive:{ociarchive}'])

# Read the digestfile and get the ref
with open(f'{parent_tmpd}/digestfile', 'r') as f:
ostree_commit = f.read().splitlines()[0]

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])

Expand All @@ -401,7 +401,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


Expand Down
Loading