Skip to content

Commit

Permalink
oscontainer: use extensions artifact, drop download-extensions
Browse files Browse the repository at this point in the history
Use the tarball produced by `buildextend-extensions` as the source of
truth for extensions and drop `download-extensions` now that we no
longer need it.
  • Loading branch information
jlebon authored and openshift-merge-robot committed Feb 23, 2021
1 parent 744e091 commit 4cddfae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 79 deletions.
19 changes: 8 additions & 11 deletions src/cmd-upload-oscontainer
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ metapath = f"{latest_build_path}/meta.json"
with open(metapath) as f:
meta = json.load(f)

# for backcompat, we auto-build extensions if they're missing
if os.path.exists('src/config/extensions.yaml'):
if 'extensions' not in meta:
cmdlib.run_verbose(['coreos-assembler', 'buildextend-extensions'])
with open(metapath) as f:
meta = json.load(f)
assert 'extensions' in meta

configdir = os.path.abspath('src/config')
oscconfigpath = f'{configdir}/oscontainer.yaml'
# XXX: fold oscontainer.yaml handling into oscontainer.py
Expand All @@ -51,15 +59,6 @@ if os.path.exists(oscconfigpath):
if 'base' in configyaml:
args.from_image = configyaml['base']

extensions_src = 'src/config/extensions.yaml'
extensions_destdir = None
if os.path.exists(extensions_src):
extensions_destdir = 'tmp/extensions'
if os.path.exists(extensions_destdir):
shutil.rmtree(extensions_destdir)
os.mkdir(extensions_destdir)
cmdlib.run_verbose(['/usr/lib/coreos-assembler/download-extensions', extensions_destdir])

print("Preparing to upload oscontainer for build: {}".format(latest_build))
ostree_commit = meta['ostree-commit']

Expand Down Expand Up @@ -108,8 +107,6 @@ os.environ['REGISTRY_AUTH_FILE'] = authfile
cosa_argv.extend(['/usr/lib/coreos-assembler/oscontainer.py', '--workdir=./tmp', 'build', f"--from={args.from_image}"])
for d in args.add_directory:
cosa_argv.append(f"--add-directory={d}")
if extensions_destdir is not None:
cosa_argv.append(f"--add-directory={extensions_destdir}")
cosa_argv.append(f"--display-name={display_name}")
subprocess.check_call(cosa_argv +
[f'--digestfile={digestfile}',
Expand Down
67 changes: 0 additions & 67 deletions src/download-extensions

This file was deleted.

11 changes: 10 additions & 1 deletion src/oscontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,15 @@ def oscontainer_build(containers_storage, tmpdir, src, ref, image_name_and_tag,
f.write(nevra)
f.write('\n')

meta = {}
builddir = None
if os.path.isfile('builds/builds.json'):
with open('builds/builds.json') as fb:
builds = json.load(fb)['builds']
latest_build = builds[0]['id']
arch = cmdlib.get_basearch()
metapath = f"builds/{latest_build}/{arch}/meta.json"
builddir = f"builds/{latest_build}/{arch}"
metapath = f"{builddir}/meta.json"
with open(metapath) as f:
meta = json.load(f)
rhcos_commit = meta['coreos-assembler.container-config-git']['commit']
Expand All @@ -184,6 +187,12 @@ def oscontainer_build(containers_storage, tmpdir, src, ref, image_name_and_tag,
config += ['-l', f"com.coreos.coreos-assembler-commit={cosa_commit}"]
config += ['-l', f"com.coreos.redhat-coreos-commit={rhcos_commit}"]

if 'extensions' in meta:
tarball = os.path.abspath(os.path.join(builddir, meta['extensions']['path']))
dest_dir = os.path.join(mnt, 'extensions')
os.makedirs(dest_dir, exist_ok=True)
run_verbose(["tar", "-xf", tarball], cwd=dest_dir)

if display_name is not None:
config += ['-l', 'io.openshift.build.version-display-names=machine-os=' + display_name,
'-l', 'io.openshift.build.versions=machine-os=' + ostree_version]
Expand Down

0 comments on commit 4cddfae

Please sign in to comment.