Skip to content

Commit d453535

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 d9d6655 commit d453535

5 files changed

+31
-25
lines changed

src/build-legacy-oscontainer.sh

Lines changed: 7 additions & 0 deletions
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

Lines changed: 15 additions & 10 deletions
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/cosalib/buildah.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
def buildah_base_args(containers_storage=None):
88
buildah_base_argv = ['buildah']
9-
if containers_storage is not None:
10-
buildah_base_argv.append(f"--root={containers_storage}")
119
if os.environ.get('container') is not None:
1210
print("Using nested container mode due to container environment variable")
13-
buildah_base_argv.extend(NESTED_BUILD_ARGS)
11+
if containers_storage is not None:
12+
buildah_base_argv.append(f"--root={containers_storage}")
13+
buildah_base_argv.extend(NESTED_BUILD_ARGS)
1414
else:
1515
print("Skipping nested container mode")
1616
return buildah_base_argv

src/oscontainer-deprecated-legacy-format.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,8 @@ def oscontainer_build(containers_storage, tmpdir, src, ref, image_name_and_tag,
207207
subprocess.call(buildah_base_argv + ['rm', bid], stdout=subprocess.DEVNULL)
208208

209209
if push:
210-
print("Pushing container")
210+
print("Pushing container to oci-archive")
211211
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))
223212

224213
if digestfile is not None:
225214
podCmd.append(f'--digestfile={digestfile}')
@@ -229,6 +218,8 @@ def oscontainer_build(containers_storage, tmpdir, src, ref, image_name_and_tag,
229218

230219
podCmd.append(image_name_and_tag)
231220

221+
podCmd.append(f'oci-archive:{builddir}/{image_name_and_tag}')
222+
232223
cmdlib.runcmd(podCmd)
233224
elif digestfile is not None:
234225
inspect = run_get_json(buildah_base_argv + ['inspect', image_name_and_tag])[0]

src/vmdeps.txt

Lines changed: 3 additions & 0 deletions
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)