Skip to contentSkip to conversation

liblxc: handle interruption/failure of lxc-debian more gracefully

PATCH In review Matt Helsley 3 participants 9 messages Feb 5, 2009 – Mar 8, 2009 3 messages not in the archive Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 liblxc: handle interruption/failure of lxc-debian more gracefully

If lxc-debian fails or is interrupted during debootstrap then the next invocation of lxc-debian breaks because it only checks for the existence of the directory. This forces the user to remove the cache by hand to retry the create step.

Let's allow the user to re-run lxc-debian to resume/retry. Store the cache in a partial-$ARCH directory until debootstrap succeeds. Then move the valid cache to its final destination.

---
 scripts/lxc-debian.in |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/lxc-debian.in +3 -2
Index: lxc/scripts/lxc-debian.in
===================================================================
@@ -217,19 +217,20 @@ create() {
 		
 		echo "not cached"
 		
-		mkdir -p "$CACHE/rootfs-$ARCH"
+		mkdir -p "$CACHE/partial-$ARCH"
 		
 	        # download a mini debian into a cache
 		echo "Downloading debian minimal ..."
 		debootstrap --verbose --variant=minbase --arch=$ARCH \
 		    --include apache,netbase,net-tools,iproute,openssh-server \
-		    etch $CACHE/rootfs-$ARCH http://ftp.debian.org/debian
+		    etch $CACHE/partial-$ARCH http://ftp.debian.org/debian
 		
 		RESULT=$?
 		if [ "$RESULT" != "0" ]; then
 		    echo "Failed to download the rootfs, aborting."
 		    exit 1
 		fi
+		mv "$CACHE/partial-$ARCH" "$CACHE/rootfs-$ARCH"
 		echo "Download complete."
 	    else
 		echo "Found."
#1 lore raw

PATCH 1/1 liblxc: Update lxc-debian to use the lenny release

With the release of lenny nearing this patch may soon be useful.

---
 scripts/lxc-debian.in |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/lxc-debian.in +2 -2
Index: lxc/scripts/lxc-debian.in
===================================================================
@@ -222,8 +222,8 @@ create() {
 	        # download a mini debian into a cache
 		echo "Downloading debian minimal ..."
 		debootstrap --verbose --variant=minbase --arch=$ARCH \
-		    --include apache,netbase,net-tools,iproute,openssh-server \
-		    etch $CACHE/partial-$ARCH http://ftp.debian.org/debian
+		    --include apache2,netbase,net-tools,iproute,openssh-server \
+		    lenny $CACHE/partial-$ARCH http://ftp.debian.org/debian
 		
 		RESULT=$?
 		if [ "$RESULT" != "0" ]; then
#2 lore raw

Re: [PATCH] liblxc: Update lxc-debian to use the lenny release

Quoted 13 lines · Matt Helsley

With the release of lenny nearing this patch may soon be useful.

---
 scripts/lxc-debian.in |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: lxc/scripts/lxc-debian.in
===================================================================

scripts/lxc-debian.in create() { · line 229

Quoted 10 lines
scripts/lxc-debian.in +2 -2
@@ -222,8 +222,8 @@ create() {
 	        # download a mini debian into a cache
 		echo "Downloading debian minimal ..."
 		debootstrap --verbose --variant=minbase --arch=$ARCH \
-		    --include apache,netbase,net-tools,iproute,openssh-server \
-		    etch $CACHE/partial-$ARCH http://ftp.debian.org/debian
+		    --include apache2,netbase,net-tools,iproute,openssh-server \
+		    lenny $CACHE/partial-$ARCH http://ftp.debian.org/debian
 
 		RESULT=$?
 		if [ "$RESULT" != "0" ]; then

Applied, thanks Matt.

ps : I added the ifupdown missing package because ifup/ifdown are no longer in the initscripts package.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Re: [PATCH] liblxc: Update lxc-debian to use the lenny release

Quoted 21 lines · Daniel Lezcano
Quoted 20 lines · Matt Helsley

With the release of lenny nearing this patch may soon be useful.

---
 scripts/lxc-debian.in |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: lxc/scripts/lxc-debian.in
===================================================================

scripts/lxc-debian.in +2 -2
@@ -222,8 +222,8 @@ create() {
 	        # download a mini debian into a cache
 		echo "Downloading debian minimal ..."
 		debootstrap --verbose --variant=minbase --arch=$ARCH \
-		    --include apache,netbase,net-tools,iproute,openssh-server \
-		    etch $CACHE/partial-$ARCH http://ftp.debian.org/debian
+		    --include apache2,netbase,net-tools,iproute,openssh-server \
+		    lenny $CACHE/partial-$ARCH http://ftp.debian.org/debian
 
Quoted 7 lines

scripts/lxc-debian.in create() { · line 229

Quoted 3 lines
scripts/lxc-debian.in +0 -0
 		RESULT=$?
 		if [ "$RESULT" != "0" ]; then

Applied, thanks Matt.

ps : I added the ifupdown missing package because ifup/ifdown are no longer in the initscripts package.

Hasn't debian switched to Network Manager too? Seems like there should
be a way to interact with it via scripts without forcing the use of ifup/ifdown.

I was somewhat suprised to find debootstrap is incredibly easy to
install by hand on non-debian systems. Even better, there's a package in fedora. So I've been playing with lxc-debian on fedora 9 and 10. However I've had problems "Configuring" the opennssh-server package. Removing that package allows lxc-debian to create the rootfs. I haven't found an underlying reason yet :/ -- have you run into this problem?

Cheers,
-Matt

#5 lore raw

Re: [PATCH] liblxc: Update lxc-debian to use the lenny release

Quoted 30 lines · Matt Helsley
Quoted 28 lines · Daniel Lezcano
Quoted 14 lines · Matt Helsley

With the release of lenny nearing this patch may soon be useful.

---
 scripts/lxc-debian.in |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: lxc/scripts/lxc-debian.in
===================================================================

scripts/lxc-debian.in create() { · line 229

Quoted 10 lines
scripts/lxc-debian.in +2 -2
@@ -222,8 +222,8 @@ create() {
 	        # download a mini debian into a cache
 		echo "Downloading debian minimal ..."
 		debootstrap --verbose --variant=minbase --arch=$ARCH \
-		    --include apache,netbase,net-tools,iproute,openssh-server \
-		    etch $CACHE/partial-$ARCH http://ftp.debian.org/debian
+		    --include apache2,netbase,net-tools,iproute,openssh-server \
+		    lenny $CACHE/partial-$ARCH http://ftp.debian.org/debian
 
 		RESULT=$?
 		if [ "$RESULT" != "0" ]; then

Applied, thanks Matt.

Quoted 8 lines
Quoted 3 lines

ps : I added the ifupdown missing package because ifup/ifdown are no longer in the initscripts package.

Hasn't debian switched to Network Manager too? Seems like there should
be a way to interact with it via scripts without forcing the use of ifup/ifdown.

It looks like the minbase does not have the network manager (I didn't checked if it is available for "lenny").
So I just made a quick fix adding the ifupdown scripts in order to have the debian booting with the network up.
Using the network manager is an interesting solution, but in the short term I think the lxc-debian script should be improved to provide a simple TUI configuration menu so we can make more complex configurations.

Quoted 4 lines

I was somewhat suprised to find debootstrap is incredibly easy to
install by hand on non-debian systems. Even better, there's a package in fedora. So I've been playing with lxc-debian on fedora 9 and 10. However

Yeah, it is a great tool. I am experiencing to do the same with a fedora. It may be possible to use yum like debootstrap for an minbase fedora install.

Quoted 4 lines

I've had problems "Configuring" the opennssh-server package. Removing that package allows lxc-debian to create the rootfs. I haven't found an underlying reason yet :/ -- have you run into this problem?

Mmh, no. I just recreated several times a debian, logged via ssh and I didn't fall in this problem.
What problem did you faced ?

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

Re: [PATCH] liblxc: Update lxc-debian to use the lenny release

DL> It may be possible to use yum like debootstrap for an minbase DL> fedora install.

Yep, something like the following should work:

  root=/path/to/tmproot
  mkdir -p $root/var/lib/rpm
  rpm --root $root --initdb
  rpm --root $root -Uvfh --nodeps http://fedora.osuosl.org/linux/releases/10/Fedora/i386/os/Packages/fedora-release-10-1.noarch.rpm
  yum --installroot=$root -y groupinstall Base
Signature · 3 lines
Dan Smith
IBM Linux Technology Center
email: danms-r/[email protected]

A message that is not in the archive (sent off-list or not yet received): 87d4dr41o0.fsf-FLMGYpZoEPULwtHQx/[email protected]

#9 lore raw

PATCH 1/1 liblxc: add scripts/lxc-fedora.in (WAS: Re: [PATCH] liblxc: Update lxc-debian to use the lenny release)

Quoted 10 lines · Dan Smith

DL> It may be possible to use yum like debootstrap for an minbase DL> fedora install.

Yep, something like the following should work:

  root=/path/to/tmproot
  mkdir -p $root/var/lib/rpm
  rpm --root $root --initdb
  rpm --root $root -Uvfh --nodeps http://fedora.osuosl.org/linux/releases/10/Fedora/i386/os/Packages/fedora-release-10-1.noarch.rpm
  yum --installroot=$root -y groupinstall Base

Looks familiar! ;) I was intrigued by this idea last weekend so I started such a script. However I only tested it as far as creating a semi-correct rootfs. With the exception of network configs most of the configs are still written as for debian. For example I know the selinux policy enforcement settings need to move, the inittab needs to be replaced by the proper upstart configs, etc.

Of course it's based heavily on Daniel's excellent lxc-debian script.

---
 configure.in          |    1 
 scripts/Makefile.am   |    1 
 scripts/lxc-fedora.in |  404 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 406 insertions(+)
configure.in +1 -0
Index: lxc/configure.in
===================================================================
@@ -90,6 +90,7 @@ AC_CONFIG_FILES([
 
 	scripts/Makefile
 	scripts/lxc-debian
+	scripts/lxc-fedora
 	scripts/lxc-sshd
 
         src/Makefile
scripts/Makefile.am +1 -0
Index: lxc/scripts/Makefile.am
===================================================================
@@ -1,3 +1,4 @@
 bin_SCRIPTS = \
 	lxc-debian \
+	lxc-fedora \
 	lxc-sshd
scripts/lxc-fedora.in new file +404 -0

404 lines not on this page · raw message

#10 lore raw

Re: [PATCH] liblxc: add scripts/lxc-fedora.in (WAS: Re: [PATCH] liblxc: Update lxc-debian to use the lenny release)

Quoted 21 lines · Matt Helsley
Quoted 11 lines · Dan Smith

DL> It may be possible to use yum like debootstrap for an minbase DL> fedora install.

Yep, something like the following should work:

  root=/path/to/tmproot
  mkdir -p $root/var/lib/rpm
  rpm --root $root --initdb
  rpm --root $root -Uvfh --nodeps http://fedora.osuosl.org/linux/releases/10/Fedora/i386/os/Packages/fedora-release-10-1.noarch.rpm
  yum --installroot=$root -y groupinstall Base

Looks familiar! ;) I was intrigued by this idea last weekend so I started such a script. However I only tested it as far as creating a semi-correct rootfs. With the exception of network configs most of the configs are still written as for debian. For example I know the selinux policy enforcement settings need to move, the inittab needs to be replaced by the proper upstart configs, etc.

Quoted 4 lines

Of course it's based heavily on Daniel's excellent lxc-debian script.

Applied.

#11 lore raw
In reply to Matt Helsley
Quoted 11 lines · Matt Helsley

If lxc-debian fails or is interrupted during debootstrap then the next invocation of lxc-debian breaks because it only checks for the existence of the directory. This forces the user to remove the cache by hand to retry the create step.

Let's allow the user to re-run lxc-debian to resume/retry. Store the cache in a partial-$ARCH directory until debootstrap succeeds. Then move the valid cache to its final destination.

That is definitively better !
Applied, thanks.

-- Daniel