Skip to content

Commit 8f8ad81

Browse files
committed
T7557: Use systemd quadlet for containers
1 parent 821a804 commit 8f8ad81

5 files changed

Lines changed: 150 additions & 170 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Autogenerated by container.py ###
2+
[Unit]
3+
Description=VyOS Network {{ name }}
4+
5+
[Network]
6+
{% for opt in opts %}
7+
{{ opt }}
8+
{% endfor %}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### Autogenerated by container.py ###
2+
[Unit]
3+
Description=VyOS Container {{ name }}
4+
5+
[Container]
6+
{% for opt in opts %}
7+
{{ opt }}
8+
{% endfor %}
9+
10+
[Service]
11+
Restart={{ restart }}

data/templates/container/systemd-unit.j2

Lines changed: 0 additions & 17 deletions
This file was deleted.

smoketest/scripts/cli/test_container.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
base_path = ['container']
3030
PROCESS_NAME = 'conmon'
31-
PROCESS_PIDFILE = '/run/vyos-container-{0}.service.pid'
3231

3332
busybox_image = 'busybox:stable'
3433
busybox_image_path = '/usr/share/vyos/busybox-stable.tar'
@@ -68,9 +67,13 @@ def tearDown(self):
6867
self.assertIsNone(process_named_running(PROCESS_NAME))
6968

7069
# Ensure systemd units are removed
71-
units = glob.glob('/run/systemd/system/vyos-container-*')
70+
units = glob.glob('/run/containers/systemd/vyos*')
7271
self.assertEqual(units, [])
7372

73+
def is_running(self, name):
74+
command = f'systemctl show vyos-{name} --property=ActiveState --value'
75+
return cmd(command).strip() == 'active'
76+
7477
def test_basic(self):
7578
cont_name = 'c1'
7679

@@ -99,12 +102,7 @@ def test_basic(self):
99102
# commit changes
100103
self.cli_commit()
101104

102-
pid = 0
103-
with open(PROCESS_PIDFILE.format(cont_name), 'r') as f:
104-
pid = int(f.read())
105-
106-
# Check for running process
107-
self.assertEqual(process_named_running(PROCESS_NAME), pid)
105+
self.assertTrue(self.is_running(cont_name))
108106

109107
# verify
110108
tmp = cmd(f'sudo podman exec -it {cont_name} sysctl kernel.msgmax')
@@ -143,6 +141,8 @@ def test_name_server(self):
143141
self.cli_set(base_path + ['network', net_name, 'no-name-server'])
144142
self.cli_commit()
145143

144+
self.assertTrue(self.is_running(cont_name))
145+
146146
n = cmd_to_json(f'sudo podman inspect {cont_name}')
147147
self.assertEqual(n['HostConfig']['Dns'][0], name_server)
148148

@@ -158,12 +158,7 @@ def test_cpu_limit(self):
158158

159159
self.cli_commit()
160160

161-
pid = 0
162-
with open(PROCESS_PIDFILE.format(cont_name), 'r') as f:
163-
pid = int(f.read())
164-
165-
# Check for running process
166-
self.assertEqual(process_named_running(PROCESS_NAME), pid)
161+
self.assertTrue(self.is_running(cont_name))
167162

168163
def test_ipv4_network(self):
169164
prefix = '192.0.2.0/24'

0 commit comments

Comments
 (0)