lxc inserts /var/lib/cloud/seed/nocloud-net on every start #1747

Closed
smoser opened this Issue Mar 11, 2016 · 4 comments

Comments

Projects
None yet
2 participants
Contributor

smoser commented Mar 11, 2016

lxc is inserting the template (seed) files for cloud-init every time. It seems like maybe template files should not be inserted on every start.

$ cat go
#!/bin/sh
sdir="/var/lib/cloud/seed/"
lxc delete --force x
echo "== starting =="
lxc launch trusty x
sleep 5

echo "== cleaning =="
lxc exec x -- rm -rf "$sdir"
echo "removed it"
lxc exec x -- sh -c '[ -d "$0" ]' "$sdir" && echo "$sdir is there" || echo "$sdir is gone"
lxc stop x
echo "== container stopped =="

echo "== restarting =="
lxc start x
lxc exec x -- sh -c '[ -d "$0" ]' "$sdir" && echo "$sdir is back" || echo "$sdir is still gone"
lxc exec x -- find "$sdir" -type f

$ sh ./go
== starting ==
Creating x
Starting x
== cleaning ==
removed it
/var/lib/cloud/seed/ is gone
== container stopped ==
== restarting ==
/var/lib/cloud/seed/ is back
/var/lib/cloud/seed/nocloud-net/meta-data
/var/lib/cloud/seed/nocloud-net/vendor-data
/var/lib/cloud/seed/nocloud-net/user-data

Owner

stgraber commented Mar 11, 2016

This is configurable in the image tarball and could be changed to only apply on initial container creation.

However should we do so, there would be no way for someone to correct invalid container metadata short of destroy and recreating the container whereas today they can simply wipe /var/lib/cloud/seed clean, reboot and have cloud-init run again.

Is there a specific problem with always having the file generated at startup time?

Contributor

smoser commented Mar 11, 2016

I think its just less expected. I somewhat expect that lxc will do something to configure my system when i first start it, but then i kind of expect that a stop and start its gone.

I came across this when working on cloud-init networking to take injected network yaml.
I'd do something like:
lxc init xenial x1
lxc-chroot x1 sh -c 'rm -Rf /var/lib/cloud/seed && tar -xf -' < seed.tar
lxc start x1

and then i'd find that lxc overwrote the files i hand set up.

Owner

stgraber commented Mar 11, 2016

Okay, I have another change to get into that metadata so I'll bundle that change together when sending the request to the CPC team.

@stgraber stgraber added this to the lxd-2.0.0.rc4 milestone Mar 11, 2016

@stgraber stgraber added Bug Easy labels Mar 11, 2016

@stgraber stgraber self-assigned this Mar 11, 2016

Owner

stgraber commented Mar 15, 2016

My change has been merged, so this will progressively get fixed as new images roll.

@stgraber stgraber closed this Mar 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment