Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python: set_config_item("lxc.cgroup.*") generates duplicate lines in config file #14

Open
amezin opened this issue Apr 3, 2017 · 18 comments
Labels
Bug Confirmed to be a bug

Comments

@amezin
Copy link

amezin commented Apr 3, 2017

With Python bindings:

    container.set_config_item('lxc.cgroup.memory.limit_in_bytes', mem_limit)
    container.set_config_item('lxc.cgroup.memory.memsw.limit_in_bytes', memsw_limit)

generates following lines in container config:

lxc.cgroup.memory.limit_in_bytes = 3G
lxc.cgroup.memory.memsw.limit_in_bytes = 
lxc.cgroup.memory.memsw.limit_in_bytes = 4G

And if there are other set_config_items before 'lxc.cgroup.memory.limit_in_bytes':

lxc.cgroup.memory.limit_in_bytes = 
lxc.cgroup.memory.limit_in_bytes = 3G
lxc.cgroup.memory.memsw.limit_in_bytes = 
lxc.cgroup.memory.memsw.limit_in_bytes = 4G

Happens on current stable-2.0 branch, haven't tested master branch yet

@brauner
Copy link
Member

brauner commented Apr 3, 2017

Afaik, this is expected behavior. Config lines override each other in the order they are specified in.

@brauner
Copy link
Member

brauner commented Apr 21, 2017

Closing as this is expected behavior.

@brauner brauner closed this as completed Apr 21, 2017
@amezin
Copy link
Author

amezin commented Apr 21, 2017

Yes, it works correctly, but why should single set_config_item generate two lines in config file, one of which is useless garbage?

@brauner
Copy link
Member

brauner commented Apr 21, 2017

Oh wait, maybe I misunderstood you. Are you saying that one single call to:

container.set_config_item('lxc.cgroup.memory.memsw.limit_in_bytes', memsw_limit)

will set two lines in the container's config file?

@amezin
Copy link
Author

amezin commented Apr 21, 2017

One single call to

container.set_config_item('lxc.cgroup.memory.memsw.limit_in_bytes', memsw_limit)

(+ container.save_config() of course) will produce this:

...
lxc.cgroup.memory.memsw.limit_in_bytes = 
lxc.cgroup.memory.memsw.limit_in_bytes = 4G
...

even if there were no "lxc.cgroup.memory.memsw.limit_in_bytes" lines in the config file before the call

@brauner
Copy link
Member

brauner commented Apr 21, 2017

Right, sorry I misunderstood. :)

@brauner brauner reopened this Apr 21, 2017
@sobczyk
Copy link

sobczyk commented Jun 23, 2017

This fails starting a container on ubuntu 16.04 (lxc 2.0.8-0ubuntu1~16.04.2)
when I override some settings from python
Failed to parse config: lxc.rootfs.backend =

@brauner
Copy link
Member

brauner commented Jun 23, 2017

Once we release the new config file parser this should be fixed.

@dankegel
Copy link

This just bit me, and it breaks lxc-ls. I'm using 2.0.8-0ubuntu1~16.04.2

When did this sneak in? It's a bit of a dumpster fire, now I can't query any of my 20 containers.

@brauner
Copy link
Member

brauner commented Jul 28, 2017

@dankegel, what exactly?

@dankegel
Copy link

dankegel commented Jul 28, 2017

I'm not quite sure what's going on, but I have about ten ubuntu 16.04 systems
each running several containers (in a configuration roughly unchanged since 2012).

On machines with 2.0.7-0ubuntu1~16.04.2, I see duplicate empty
lxc.hook.pre-mount lines before the real one, but that doesn't seem to bother lxc-ls.

On machines with 2.0.8-0ubuntu1~16.04.2, I also see duplicate empty
lxc.ephemeral lines before the real ones, and lxc-ls complains
lxc-ls: parse.c: lxc_file_for_each_line: 57 Failed to parse config: lxc.ephemeral =
If I remove the empty duplicate, lxc-ls works again.

I have no idea what creates those lines, my script "just" calls lxc-start.

I suppose I can just modify my script to remove the bogus line after creating each new ephemeral container... so it's only a dumpster fire in the "oh, man, not another distraction!" sense.

@stutiredboy
Copy link

Second.

@brauner
Copy link
Member

brauner commented Nov 22, 2017

Is this still a problem with LXC 2.0.9?

@condector
Copy link

Yes, this still a problem with LXC 2.0.11 on Ubuntu 16.04 using python3-lxc lib. For some weird reason, generate two outputs.

@brauner
Copy link
Member

brauner commented Jul 19, 2018

Can you try with master too, please?

@condector
Copy link

I will try and post here an update.

@brauner
Copy link
Member

brauner commented Jul 22, 2018

Thanks!

@condector
Copy link

@brauner I tested with version 2.0.8 that I clone from GitHub directly. The problem was: when I create an object to run an LXC container and save its configuration, the production was 2 line of configurations, one:

lxc.cgroup.memory.limit_in_bytes = 
lxc.cgroup.memory.limit_in_bytes = 256M
lxc.cgroup.cpuset.cpus = 
lxc.cgroup.cpuset.cpus = 1

I start to inspect what's causing it... I know that the second line is the effective one... but the configuration file becomes a little bit full of blank lines.

@stgraber stgraber transferred this issue from lxc/lxc Mar 18, 2020
@stgraber stgraber added the Bug Confirmed to be a bug label Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed to be a bug
Development

No branches or pull requests

7 participants