lxc / python3-lxc

Python 3.x binding for liblxc
https://linuxcontainers.org/lxc
GNU Lesser General Public License v2.1
57 stars 38 forks source link

api_test: fix possible infinite loop when trying to get the ip address #32

Closed Cypresslin closed 2 years ago

Cypresslin commented 2 years ago

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 assert(len(ips) > 0) AssertionError

Signed-off-by: Po-Hsu Lin \po-hsu.lin@canonical.com\