This example script is guaranteed to fail on modern Ubuntu releases due to outdated configuration. These changes allow the script to pass:
- Fixes container.create arguments to request Noble image instead of Xenial, as Xenial images are no longer available
- Changes cgroups key strings to use cgroups v2 nomenclature ('max' instead of 'limit_in_bytes', 'peak' instead of 'max_usage_in_bytes')
Signed-off-by: Austin Rhodes <austin.rhodes@canonical.com>
When using python3-lxc with liblxc from lxc 6.0.x, we could observe
random systemd startup failures on containers.
systemd will report this on startup when the corruption hit:
"Warning! Reported kernel version 2.6.74-300.fc42.x86_64 is older than systemd's required baseline kernel version 4.15. Your mileage may vary."
Some systemd services fail to start properly, including systemd-journald.
The root problem is that other lxc library code unexpectedly calls into
lxc_config_parse_arch() from python3-lxc instead of the function from liblxc.
The function signature of lxc_config_parse_arch() changed throughout the years
and the second "persona" pointer argument was added. The older python3-lxc copy
of the function would not initialize the provided memory location of "persona".
It will therefore contain a random value.
Additionally the symbol visibility of liblxc's lxc_config_parse_arch()
changed with this commit in lxc 6.0:
******************************************
commit 42eeffcb05c468fd7b3a90eeda4a3abe9f26844b
AuthorDate: Sun Feb 18 15:43:20 2024 +0100
confile: unhide lxc_config_parse_arch() helper
Looks safe enough to be available for liblxc users.
******************************************
This results in two symbols with the same name and
the python3-lxc symbol takes precedence.
Fix the issue by making the function static in python3-lxc,
so python3-lxc stays compatible with lxc 5.x and 6.x.
A future python3-lxc version might remove the local function
and use lxc_config_parse_arch() from liblxc 6.0 and later.
Side quest: Even though lxc 5.0 already has the "persona" function argument in
lxc_config_parse_arch() since 7c43fa56e70c65607f63dec8ff5a9682a3091ab2 (from 2021),
it is not affected since the symbol visibility is still hidden.
Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Container_attach_and_possibly_wait() fails in Python 3.13 with
"PyMutex_Unlock: unlocking mutex that is not locked" if PyOS_AfterFork()
is used.
Signed-off-by: Andreas Vögele <andreas@andreasvoegele.com>
If the the ips can not be correctly obtained with container.get_ips()
this while loop will never ends.
Fix this by using:
while not ips and count != 30
So that even if the ips is empty, the loop will get terminated after
30 attempts (30 seconds later). This retry limit was bumped from 10
to 30 to give it a chance to get the ip address.
If the ip address cannot be obtained, this test will failed with:
Traceback (most recent call last):
File "/usr/share/doc/python3-lxc/examples/api_test.py", line 131, in <module>
assert(len(ips) > 0)
AssertionError
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
When the host has kernel module sit or ipip inserted, additional network
interfaces sit0 and/or tunl0 would appear inside the container by
default as well, which fails the api_test.
This change append sit0/tunl0 to expected interfaces when applicable.
Closes: #2
Signed-off-by: You-Sheng Yang <vicamo@gmail.com>