Skip to content
This repository was archived by the owner on Oct 10, 2020. It is now read-only.

Commit e78ecdd

Browse files
giusepperh-atomic-bot
authored andcommitted
install: add new option --runtime=PATH to choose the OCI runtime
it is supported by system and user containers. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1125 Approved by: TomSweeneyRedHat
1 parent d465ea5 commit e78ecdd

5 files changed

Lines changed: 28 additions & 4 deletions

File tree

Atomic/install.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def cli(subparser):
6767
help=_('install a system container'))
6868
installp.add_argument("--system-package", dest="system_package", default="auto",
6969
help=_('control how to install the package. It accepts `auto`, `yes`, `no`, `build`'))
70+
installp.add_argument("--runtime", dest="runtime", default=None,
71+
help=_('specify the OCI runtime to use for system and user containers'))
7072
installp.add_argument("--rootfs", dest="remote",
7173
help=_("choose an existing exploded container/image to use "
7274
"its rootfs as a remote, read-only rootfs for the "

Atomic/syscontainers.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def __init__(self):
8383
self.args = None
8484
self.setvalues = None
8585
self.display = False
86-
self._runtime = None
86+
self.runtime = None
87+
self._runtime_from_info_file = None
8788

8889
def get_atomic_config_item(self, config_item):
8990
"""
@@ -148,6 +149,11 @@ def set_args(self, args):
148149
except (NameError, AttributeError):
149150
pass
150151

152+
try:
153+
self.runtime = self.args.runtime
154+
except (NameError, AttributeError):
155+
pass
156+
151157
@staticmethod
152158
def _split_set_args(setvalues):
153159
values = {}
@@ -468,8 +474,11 @@ def _generate_default_oci_configuration(self, destination):
468474
conf.write(json.dumps(configuration, indent=4))
469475

470476
def _get_oci_runtime(self):
471-
if self._runtime:
472-
return self._runtime
477+
if self.runtime:
478+
return self.runtime
479+
480+
if self._runtime_from_info_file:
481+
return self._runtime_from_info_file
473482

474483
if self.user:
475484
return util.BWRAP_OCI_PATH
@@ -1094,7 +1103,7 @@ def update_container(self, name, setvalues=None, rebase=None):
10941103
return
10951104

10961105
if runtime is not None:
1097-
self._runtime = runtime
1106+
self._runtime_from_info_file = runtime
10981107
if system_package is None:
10991108
system_package = 'yes' if rpm_installed else 'no'
11001109
self._checkout(repo, name, image, next_deployment, True, values, remote=self.args.remote, installed_files=installed_files, system_package=system_package)

bash/atomic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ _atomic_install() {
721721
--help
722722
--display
723723
--rootfs
724+
--runtime
724725
--storage
725726
--system
726727
--system-package

docs/atomic-install.1.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ root filesystem. The existing rootfs will be used as the new
7070
system container's rootfs (read only), and thus the new container
7171
will only contain config and info files.
7272

73+
**--runtime=PATH**
74+
Change the OCI runtime used by the systemd service file for running
75+
system containers and user containers. The default **/bin/runc** is
76+
used for system containers. Conversely, for user containers the
77+
default value is **/bin/bwrap-oci**.
78+
7379
**--set=NAME=VALUE**
7480
Set a value that is going to be used by a system container for its
7581
configuration and can be specified multiple times. It is used only

tests/integration/test_system_containers_runtime.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ IFS=$'\n\t'
1515
# 8. Repeated updates/rollbacks
1616
# 9. Update --rebase
1717
# 10. Updating/rolling back a container with a remote rootfs
18+
# 11. Verify --runtime is honored
1819

1920
setup () {
2021
${ATOMIC} pull --storage ostree docker:atomic-test-system:latest
@@ -229,3 +230,8 @@ assert_matches "new-receiver" ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}-new/config.
229230

230231
${ATOMIC} containers rollback ${NAME}-new
231232
assert_matches ${SECRET} ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}-new/config.json
233+
234+
# 11. Test --runtime
235+
${ATOMIC} uninstall ${NAME}-new
236+
${ATOMIC} install --name=${NAME}-new --runtime=/bin/ls --set=RECEIVER=${SECRET} --system atomic-test-system
237+
assert_matches /bin/ls /etc/systemd/system/${NAME}-new.service

0 commit comments

Comments
 (0)