Skip to content

Commit bf241cd

Browse files
committed
oscontainer-deprecated-legacy-format: use runvm not nested containers
This also changes the push to create a oci-archive that will then be pushed with `cosa push-container-manifest` by the pipeline.
1 parent 730618d commit bf241cd

4 files changed

+29
-26
lines changed

src/build-legacy-oscontainer.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
# shellcheck disable=SC1091
3+
set -euo pipefail
4+
# Start VM and call buildah
5+
. /usr/lib/coreos-assembler/cmdlib.sh; prepare_build
6+
. /usr/lib/coreos-assembler/cmdlib.sh
7+
runvm -- /usr/lib/coreos-assembler/oscontainer-deprecated-legacy-format.py "$@"

src/cmd-upload-oscontainer-deprecated-legacy-format

+15-10
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,24 @@ if args.arch_tag:
101101
# every time we want to poll.
102102
# TODO: Remove --from
103103
digestfile = "tmp/oscontainer-digest"
104-
# We need to pass the auth file from the unpriv user to the root process
105-
cosa_argv = ['sudo', '--preserve-env=container,DISABLE_TLS_VERIFICATION,SSL_CERT_DIR,SSL_CERT_FILE,REGISTRY_AUTH_FILE,OSCONTAINER_CERT_DIR']
106-
authfile = os.environ.get("REGISTRY_AUTH_FILE", os.path.expanduser('~/.docker/config.json'))
107-
if not os.path.isfile(authfile):
108-
raise SystemExit(f"Missing {authfile}")
109-
os.environ['REGISTRY_AUTH_FILE'] = authfile
110-
cosa_argv.extend(['/usr/lib/coreos-assembler/oscontainer.py', '--workdir=./tmp', 'build', f"--from={args.from_image}"])
104+
print("Entering vm to build oscontainer for build: {}".format(latest_build))
105+
arguments = ''
111106
for d in args.add_directory:
112-
cosa_argv.append(f"--add-directory={d}")
113-
cosa_argv.append(f"--display-name={display_name}")
107+
arguments = arguments + (f' --add-directory="{d}"')
108+
arguments = arguments + (f' --display-name="{display_name}"')
114109
if 'labeled-packages' in configyaml:
115110
pkgs = ' '.join(configyaml['labeled-packages'])
116-
cosa_argv.append(f"--labeled-packages={pkgs}")
111+
arguments = arguments + (f' --labeled-packages="{pkgs}"')
112+
if args.format is not None:
113+
arguments = arguments + (f' --format="{args.format}"')
114+
115+
cosa_argv = (['/usr/lib/coreos-assembler/build-legacy-oscontainer.sh', '--workdir=./tmp', 'build', f'--from={args.from_image}'])
116+
for d in args.add_directory:
117+
cosa_argv.append(f'--add-directory="{d}"')
118+
cosa_argv.append(f'--display-name="{display_name}"')
119+
if 'labeled-packages' in configyaml:
120+
pkgs = ' '.join(configyaml['labeled-packages'])
121+
cosa_argv.append(f'--labeled-packages="{pkgs}"')
117122
if args.format is not None:
118123
cosa_argv.append(f'--format={args.format}')
119124
subprocess.check_call(cosa_argv +

src/oscontainer-deprecated-legacy-format.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
import shutil
2121
import subprocess
2222
from cosalib import cmdlib
23-
from cosalib.buildah import (
24-
buildah_base_args
25-
)
2623

2724
OSCONTAINER_COMMIT_LABEL = 'com.coreos.ostree-commit'
2825

@@ -108,7 +105,7 @@ def oscontainer_build(containers_storage, tmpdir, src, ref, image_name_and_tag,
108105
else:
109106
ostree_version = None
110107

111-
buildah_base_argv = buildah_base_args(containers_storage)
108+
buildah_base_argv = ['buildah']
112109

113110
# In general, we just stick with the default tmpdir set up. But if a
114111
# workdir is provided, then we want to be sure that all the heavy I/O work
@@ -207,19 +204,8 @@ def oscontainer_build(containers_storage, tmpdir, src, ref, image_name_and_tag,
207204
subprocess.call(buildah_base_argv + ['rm', bid], stdout=subprocess.DEVNULL)
208205

209206
if push:
210-
print("Pushing container")
207+
print("Pushing container to oci-archive")
211208
podCmd = buildah_base_argv + ['push']
212-
if not tls_verify:
213-
tls_arg = '--tls-verify=false'
214-
else:
215-
tls_arg = '--tls-verify'
216-
podCmd.append(tls_arg)
217-
218-
if authfile != "":
219-
podCmd.append("--authfile={}".format(authfile))
220-
221-
if cert_dir != "":
222-
podCmd.append("--cert-dir={}".format(cert_dir))
223209

224210
if digestfile is not None:
225211
podCmd.append(f'--digestfile={digestfile}')
@@ -229,6 +215,8 @@ def oscontainer_build(containers_storage, tmpdir, src, ref, image_name_and_tag,
229215

230216
podCmd.append(image_name_and_tag)
231217

218+
podCmd.append(f'oci-archive:{builddir}/{image_name_and_tag}')
219+
232220
cmdlib.runcmd(podCmd)
233221
elif digestfile is not None:
234222
inspect = run_get_json(buildah_base_argv + ['inspect', image_name_and_tag])[0]

src/vmdeps.txt

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ selinux-policy selinux-policy-targeted policycoreutils
2020
# coreos-assembler
2121
python3 python3-gobject-base buildah podman skopeo iptables iptables-libs
2222

23+
# legacy-oscontainer
24+
python3-pyyaml python3-botocore python3-flufl-lock python3-tenacity
25+
2326
# luks
2427
cryptsetup
2528
# filesystems/storage

0 commit comments

Comments
 (0)