Closed ach5948 closed 3 years ago
Hello, could me and my classmates work on this issue please?
Was originally planning to work on issue https://github.com/lxc/python3-lxc/issues/15 but it turns out someone already opened a PR for it.
Hey @stgraber, just wanted to check in again if it would be okay for me to work on this issue? Thanks!
Absolutely!
Assigned it to you now!
Thanks for assigning it @stgraber!
I've been a little lost trying to think of the solution.
The create and destroy functions in the lxc.c file in this python repo are eventually making a call to functions in lxc/lxccontainer.h
I'm guessing that the fix is actually in the lxc/lxc
repo in lxccontainer.c
.
Moreover, I'm having a hard time trying to set up things to run. I had a file structure as follows:
lxc -- lxc -- python3-lxc
However, when I go to python3-lxc and run python3 setup.py build
, I get an error saying that lxc.c:27:10: fatal error: 'lxc/lxccontainer.h' file not found
Could you please give me some direction here? Or do you think this issue is more involved than we think it is and would require a lot of context?
Ok, so the issue here is that create()
creates a rootfs for a container while destroy()
deletes the container itself including its path. It's that step which is preventing it be re-created as the object still has its old config, causing it to prevent a new create()
run.
To fix this in python3-lxc, I think we need to changes:
create()
needs to call save_config()
if the container isn't defined (self.defined
)destroy()
needs to call clear_config()
on success, this needs a new python3 wrapper for destroy to handle thatAs this is not going to be touching the C part of this, you can just install python3-lxc
on an Ubuntu system and then use this in a python3 shell to reproduce the issue:
import lxc
test = lxc.Container("test")
test.destroy()
test.create("busybox")
test.destroy()
test.create("busybox")
This should output True
every time when this issue is fixed.
You can directly mess with the python3 binding live by editing /usr/lib/python3/dist-packages/lxc/__init__.py
on such a system.
Thanks a lot for the explanation, that makes sense. I was able to set things up on an Ubuntu system and edit the binding as you suggested for testing it.
I'm a little confused by one thing though. Even before I made any changes, all my create()
calls are returning False
. Do you know what might be the issue here?
Going off of the Steps to Reproduce in the issue description, this is what I'm getting:
test = lxc.Container("test") ->
test.create(template="debian") False
test.destroy() False
test.create(template="debian") False
I did, however, open a PR #23 that does the changes you suggested.
Yeah, test with busybox not debian, we don't ship the debian template by default.
Required information
lxc-start --version
: 2.0.7uname -a
: Linux 4.9.0-3-amd64 lxc/lxc#1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64 GNU/LinuxIssue description
After instantiating, creating, and destroying a linux container, calling create without re-instantiating returns false rather than recreating the container
Steps to reproduce
the second call simply returns false