-
Notifications
You must be signed in to change notification settings - Fork 29
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
destroying containers from code doesn't sync with lxc-ls #38
Comments
Hi Bar Can you share the script you ran that resulted in this mess? :)
|
Sure, To create I use this: def create_container
container_name = SecureRandom.uuid
c = LXC::Container.new(container_name)
begin
c.create('ubuntu')
c.start
SYSLOGGER.info("Pool: Starting container: #{c.name}")
rescue => e
SYSLOGGER.error("Pool: Error starting container #{c.name}: #{e}")
end
return c if c
end To destroy I use this: def destroy_container(c)
container_name = c.name
try = 0
begin
while c.running?
SYSLOGGER.debug("Container: Shutting down container #{c.name}...")
c.shutdown(-1)
sleep 0.1 while c.running?
SYSLOGGER.debug("Container: Stopping container #{c.name}...")
c.stop
c.wait(:stopped, 5)
SYSLOGGER.debug("Container: Destroying container #{c.name}...")
c.destroy
SYSLOGGER.debug("Container: Clearing config for container #{c.name}...")
c.clear_config
end
SYSLOGGER.info("Container: Container #{container_name} closed")
rescue => e
SYSLOGGER.error("Container: Error stopping Container #{container_name}: #{e}")
sleep 2
try += 1
if try < 3
retry
else
@running = true
end
end
end So i basically did something like container_array = []
10.times do
container_array << create_container
end
container_array.each do |c|
destroy_container(c)
end |
@andrenth , did you had time to check this issue ? Can I help somehow ? |
what distro you are using? Can you run the script and print lxcpath as part of it? puts LXC.global_config_item('lxc.lxcpath') fwiw, I tried your script (with unprivileged containers) and it worked fine for me. |
Hi @ranjib , I'm running:
I'm running with Privileged containers. Ruby:
|
I created 10 containers, then, destroyed them all (muahaha).
Looking at lxc-ls and ifconfig I can see that the containers are still "running" but trying to execute lxc-destroy --name *** gives back an error
looking at /var/lib/lxc shows an empty dir.
So it seems I got "phantom" containers ?
The text was updated successfully, but these errors were encountered: