lxc-start-ephemeral needs tweak to handle centos and fedora hostname setting

Bug #1042431 reported by Dan Kegel
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)
Fix Released
Medium
Serge Hallyn
Precise
Fix Released
Medium
Unassigned

Bug Description

===============================
SRU Justification:
1. Impact: lxc-start-ephemeral does not update hostname for fedora containers
2. Development fix: add the necessary files (/etc/sysconfig/) for fedora hosts to the list of files to be updated.
3. Stable fix: same as development fix.
4. test case: create a fedora container, then start an ephemeral one based on it:
 lxc-create -t fedora -n f14
 lxc-start-ephemeral -o f14
   and check its hostname
5. Regression potential: none - we only attempt updates if the file exists.
===============================
As discussed in the thread "lxc template for RHEL?"
http://sourceforge.net/mailarchive/message.php?msg_id=29730103
lxc-start-ephemeral only knows how to tweak the hostname for ubuntu and debian,
and needs to be taught about where rhel and centos put hostname, something like this:

--- lxc-start-ephemeral.orig 2012-08-27 12:19:03.935513119 -0700
+++ lxc-start-ephemeral 2012-08-27 12:19:54.471514479 -0700
@@ -154,7 +154,19 @@
     LXC_MOUNTED=1

     # Update the ephemeral lxc's configuration to reflect the new
container name.
- sudo sed -i -e "s/$LXC_BASE/$LXC_NAME/" $LXC_DIR/fstab $LXC_DIR/config $LXC_DIR/rootfs/etc/hostname $LXC_DIR/rootfs/etc/hosts
+ # Check all the places known distros keep hostnames.
+ # FIXME: should we sanity check the hostname to make sure it contains no bad chars?
+ for file in $LXC_DIR/fstab $LXC_DIR/config \
+ $LXC_DIR/rootfs/etc/hostname \
+ $LXC_DIR/rootfs/etc/hosts \
+ $LXC_DIR/rootfs/etc/sysconfig/network \
+ $LXC_DIR/rootfs/etc/sysconfig/network-scripts/ifcfg-eth0
+ do
+ if test -f "$file"
+ then
+ sudo sed -i -e "s/$LXC_BASE/$LXC_NAME/" $file
+ fi
+ done

     # Update the fstab to have all bind mounts be ephemeral.
     sudo cp $LXC_DIR/fstab $LXC_DIR/fstab.old

This affects 12.04 and the ppa for lxc, so probably also 12.10 alpha 3.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Thanks, Dan, for the bug report and the patch.

Changed in lxc (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Dan Kegel (dank) wrote :

For completeness, here's a cleaner copy of the patch, along with the centos script I'm using, from that same thread.

I haven't actually deployed yet, but it passes my little unit test.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "0001-Add-Centos-support-to-lxc-create.patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Changed in lxc (Ubuntu):
assignee: nobody → Serge Hallyn (serge-hallyn)
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Dan,

I am pushing the fix to lxc-start-ephemeral for quantal, and we will SRU it to precise. However, the new template for centos would be a new feature and require a feature freeze exception at this point. We can either (1) ask for the FFE, (2)wait until the next cycle opens up (in November), or (3) just push this template through upstream.

I'm happy to do (1). Would you mind opening up a new bug for the centos template to be included?

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lxc - 0.8.0~rc1-4ubuntu32

---------------
lxc (0.8.0~rc1-4ubuntu32) quantal; urgency=low

  * 0204-ubuntu-cloud-userdata-path: Fix broken behavior when a relative
    path is passed into '--userdata' argument. (LP: #1043582)
  * 0205-lxc-ls-manpage-document-two-lines: Document the default two-line
    output format of lxc-ls. (LP: #1043018)
  * lxc-start-ephemeral: support fedora and centos (LP: #1042431)
 -- Serge Hallyn <email address hidden> Thu, 30 Aug 2012 10:05:06 -0500

Changed in lxc (Ubuntu):
status: Triaged → Fix Released
tags: added: needsru
Revision history for this message
Dan Kegel (dank) wrote :

I would be happy with (3), since the chasm between ubuntu and upstream is so wide; I'd rather reduce the gap rather than widen it. Still want a bug?

Revision history for this message
Serge Hallyn (serge-hallyn) wrote : Re: [Bug 1042431] Re: lxc-start-ephemeral needs tweak to handle centos and fedora hostname setting

Quoting Dan Kegel (<email address hidden>):
> I would be happy with (3), since the chasm between ubuntu and upstream
> is so wide;

It only seems that way :) Believe it or not, they *are* going to
converge again.

> I'd rather reduce the gap rather than widen it. Still want
> a bug?

Nope, that's ok :) Please go ahead and email the patch to lxc-devel, and
we'll get it at the next merge.

Thanks!

description: updated
Changed in lxc (Ubuntu Precise):
status: New → In Progress
importance: Undecided → Medium
Revision history for this message
Clint Byrum (clint-fewbar) wrote : Please test proposed package

Hello Dan, or anyone else affected,

Accepted lxc into precise-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/lxc/0.7.5-3ubuntu64 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please change the bug tag from verification-needed to verification-done. If it does not, change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in lxc (Ubuntu Precise):
status: In Progress → Fix Committed
tags: added: verification-needed
tags: added: verification-done
removed: verification-needed
Revision history for this message
Clint Byrum (clint-fewbar) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lxc - 0.7.5-3ubuntu65

---------------
lxc (0.7.5-3ubuntu65) precise-proposed; urgency=low

  * Add proper fix (X001-lxc-ls-onelisting) for lxc-ls showing running
    containers multiple times. (LP: #1043018)

lxc (0.7.5-3ubuntu64) precise-proposed; urgency=low

  [ Serge Hallyn ]
  * lxc.lxc-net.upstart: tell iptables not to masquerate packets between
    containers. (LP: #1045947)
  * 0204-ubuntu-cloud-userdata-path: Fix broken behavior when a relative
    path is passed into '--userdata' argument. (LP: #1043582)
  * 0205-lxc-ls-manpage-document-two-lines: Document the default two-line
    output format of lxc-ls. (LP: #1043018)
  * lxc-start-ephemeral: support fedora and centos (LP: #1042431)
  * 0222-debian-dhcp3-package: fix install of debian testing containers.
    (LP: #1052972)
  * 0100-template-cleanup-cache: clean up template cache if interrupted
    during build. (LP: #1037331)

  [ Scott Moser ]
  * 0225-ubuntu-cloud-numeric-owner: use --numeric-owner when extracting root
    filesystems with tar (LP: #1066084)
 -- Serge Hallyn <email address hidden> Wed, 07 Nov 2012 11:03:36 -0600

Changed in lxc (Ubuntu Precise):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.