[OmniOS-discuss] FIX IN PLACE NOW - was Re: r151020 zone clone failure

Dan McDonald danmcd at omniti.com
Mon Nov 14 16:56:17 UTC 2016


Looping back around on this.

1.) Some people have had success with my zoneadmd binary.  NOTE - it's not a completely fixed one, as an error path didn't have the fix.

2.) I'm building a replacement system/zones package which will be pushed onto the r151020 IPS repo as I type this. When you update, you will need to reboot.  THIS IS A 'pkg update' TIME!

3.) I will be pushing out release media as well later today.

4.) A detailed explanation of what happened and what I needed to fix is appended.

Thank you all for your help, and for catching this.  I'm sorry I didn't see it pre-020.

Dan


========================

A change from Joyent, which fixed a bug affecting LX zones, was pulled in by my io-lx work:

commit 2d8f41b4e012f1fb3de3a6cb6731708ee5c65bcf
Author: Ryan Zezeski <rpz at joyent.com>
Date:   Sun Sep 25 15:55:02 2016 -0400

    OS-5330 zoneadm mounting an lx or joyent branded zone fails
    Reviewed by: Jerry Jelinek <jerry.jelinek at joyent.com>
    Approved by: Jerry Jelinek <jerry.jelinek at joyent.com>
    (NOTE: Manual port, because of divergence from SmartOS.)

PLEASE NOTE that I had to bring this one in by hand, because we don't have ALL of Joyent's zone changes.  That's the first clue I had.

If one debugs the "zoneadm -z dest clone source" and the /usr/lib/brand/ipkg/clone script (which was what I asked Michael to do with the -x), one sees this subcommand after the ZFS machinations of creating the new zone's filesystem:

	zoneadm -z dest attach -f

This FAILED on lipkg/ipkg zones.  Much gnashing of teeth and deep-diving showed me that for ipkg/lipkg zones, the pre-state script for them actually needs to mount the active dataset.  A change in OS-5330 did NOT have zoneadmd invoking pre-state anymore for anything other than booting.  This is how their LX AND NATIVE zones work, but it is not how ipkg/lipkg work.

To fix this, I had to undo bits of OS-5330, to make them LX-brand specific.  The actual implementation I made is a bit of a band-aid, and I know there's one other potential place that needs scrutiny going forward, but I wanted this fix out sooner rather than later.  The REAL fix will be for this part of zoneadmd to query the brand about what to do.  The Joyent folks confirmed my band-aid fix AND were the ones to tell me the long-term right answer is brand-querying.

I will be pushing this into illumos-omnios:

commit f45647bf9f5f56ad11e447895be7c32a7f3995a4
Author: Dan McDonald <danmcd at omniti.com>
Date:   Mon Nov 14 10:48:39 2016 -0500

    Joyent's OS-5330 accidentally broke ipkg/lipkg clone via breaking
    "zoneadm -z zone mount -f"

diff --git a/usr/src/cmd/zoneadmd/zoneadmd.c b/usr/src/cmd/zoneadmd/zoneadmd.c
index 0a728000..1233fb1 100644
--- a/usr/src/cmd/zoneadmd/zoneadmd.c
+++ b/usr/src/cmd/zoneadmd/zoneadmd.c
@@ -554,9 +554,16 @@ static int
 zone_ready(zlog_t *zlogp, zone_mnt_t mount_cmd, int zstate)
 {
        int err;
+       boolean_t do_prestate;
 
-       if (!ALT_MOUNT(mount_cmd) &&
-           brand_prestatechg(zlogp, zstate, Z_READY) != 0)
+       /*
+        * LX zones don't like prestate/poststate being done on non-booting
+        * mount commands.  Other zones may, so be picky about when/when-not
+        * to invoke pre/post state change.
+        */
+       do_prestate = (strcmp(brand_name, "lx") != 0 || !ALT_MOUNT(mount_cmd));
+
+       if (do_prestate && brand_prestatechg(zlogp, zstate, Z_READY) != 0)
                return (-1);
 
        if ((err = zonecfg_create_snapshot(zone_name)) != Z_OK) {
@@ -580,8 +587,7 @@ zone_ready(zlog_t *zlogp, zone_mnt_t mount_cmd, int zstate)
                goto bad;
        }
 
-       if (!ALT_MOUNT(mount_cmd) &&
-           brand_poststatechg(zlogp, zstate, Z_READY) != 0)
+       if (do_prestate && brand_poststatechg(zlogp, zstate, Z_READY) != 0)
                goto bad;
 
        return (0);
@@ -591,7 +597,7 @@ bad:
         * If something goes wrong, we up the zones's state to the target
         * state, READY, and then invoke the hook as if we're halting.
         */
-       if (!ALT_MOUNT(mount_cmd))
+       if (do_prestate)
                (void) brand_poststatechg(zlogp, ZONE_STATE_READY, Z_HALT);
        return (-1);
 }



More information about the OmniOS-discuss mailing list