Project

General

Profile

Bug #1204

zoneadm cannot create clone of zone from snapshot

Added by Alexander Eremin over 8 years ago. Updated about 4 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
PKG (Image Packaging System)
Target version:
-
Start date:
2011-07-12
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
clone

Description

Bug from https://defect.opensolaris.org/bz/show_bug.cgi?id=5940 still exist, i.e.:

~# zoneadm -z test2 clone -s rpool/zones/test/ROOT/zbe-1@test_snap
/usr/lib/brand/ipkg/clone: -s: unknown option

brand-specific usage: clone {sourcezone}
usage: clone [-m method] [-s <ZFS snapshot>] [brand-specific args] zonename
Clone the installation of another zone. The -m option can be used to
specify 'copy' which forces a copy of the source zone. The -s option
can be used to specify the name of a ZFS snapshot that was taken from
a previous clone command. The snapshot will be used as the source
instead of creating a new ZFS snapshot. All other arguments are passed
to the brand clone function; see brands(5) for more information.


Files

ips-clone.patch (1.81 KB) ips-clone.patch Jim Klimov, 2013-11-13 01:40 AM
ips-clone.patch (3.75 KB) ips-clone.patch Jim Klimov, 2013-11-14 11:03 PM
ips-clone.patch (4.27 KB) ips-clone.patch Jim Klimov, 2013-11-15 02:35 AM
sol10-clone.patch (3.6 KB) sol10-clone.patch Jim Klimov, 2013-11-20 11:37 PM

History

#1

Updated by Alexander Eremin over 8 years ago

while pkg doesn't provide these options in brand "clone" script, we must do not use brand hook or remove this call from zoneadm..

#2

Updated by Rich Lowe over 8 years ago

  • Project changed from illumos gate to OpenIndiana Distribution

Most of the ipkg brand (including this bit) is in the pkg-gate, not illumos.

#3

Updated by Chris Jordan over 8 years ago

  • Category set to PKG (Image Packaging System)
  • Assignee set to OI PKG
  • Tags changed from needs-triage to clone
#4

Updated by Jim Klimov over 6 years ago

This patch was made and tested in OI 151a8, works for both specified full snapshot names (dataset part loudly ignored) or just snapshot name.

Patch markup is mangled by the tracker, so uploading as file.

#5

Updated by Jim Klimov over 6 years ago

Awaiting comments on mailing list...

#6

Updated by Jim Klimov over 6 years ago

Test results:

  1. Make origin, prepare zone configs beforehand
  1. zfs snapshot -r pond/zones/_ips/DUMMY/DUMMY-fullroot@20131109-02
  1. Clone by snapshot name
  1. zoneadm -z ns-master clone -s 20131109-02 DUMMY-fullroot
  1. Clone by dataset@snap (dataset ignored, because active dataset is found automatically)
  1. zoneadm -z mysql3 clone -s rpool@20131109-02 DUMMY-fullroot
    WARNING: Ignoring dataset, using only snapshot name
  1. zfs list o origin,name -r pond/zones/_ips/dbms/mysql3
    ORIGIN NAME
    pond/zones/_ips/dbms/mysql3
    - pond/zones/_ips/dbms/mysql3/ROOT
    pond/zones/_ips/DUMMY/DUMMY-fullroot/ROOT/zbe@20131109-02 pond/zones/_ips/dbms/mysql3/ROOT/zbe

It may be argued that the dataset part should not be ignored, and not the "active" zone root should be cloned but literally the provided dataset (should then be "$ZONENAME/ROOT/zbe-*"). This is not currently implemented, but can be done with little effort if deemed desirable.

#7

Updated by Jim Klimov over 6 years ago

Updated the patch. Now it supports cloning from a different zone boot environment of the same zone by accepting the following values for "-s" (snapshot):
1) @* - such strings are interpreted as dataset@snapname, including an empty dataset part (only "@snapname" is then accepted for currently active source ZBE)
2) */
- such strings specify the dataset, of which a snapshot will be made and used automatically
3) * - any other strings specify the snapshot name, which should exist of the currently active source zone root

Sanity checks are done that the specified source dataset (if specified) conforms to the naming and attributes of ZBE's, and is a ZBE of the specified source zone, and that a snapshot (if specified) exists in the selected source dataset.

Also added is a "-X" 'brand-specific argument' which allows to disable "sys-unconfig" in the newly cloned zone. Sometimes admins and their carefully prepared template zones know better ;)

I did not find the relevant manpages where these bits of information could be added; otherwise the task is tested and complete as far as I am concerned.

#8

Updated by Jim Klimov over 6 years ago

After addressing some review by Cedric Blancher (mostly to add comments, ultimately) and applying a few minor fixes such as ensuring that the new zone stays mounted even if it was not sys-unconfig'ed, I made this new patch.

#9

Updated by Jim Klimov over 6 years ago

On a related note, here is a similar patch for "solaris10" branded zones (/usr/lib/brand/solaris10/clone which should be part of illumos-gate). Unfortunately, I can't create and test a solaris10 zone at the moment, so this patch is "theoretical" and untested. It supports the same logic for source snapshot naming and for optional avoidance of sys-unconfig (-X).

#10

Updated by Jon Tibble about 6 years ago

  • Status changed from Feedback to Resolved
  • % Done changed from 90 to 100

Fixed in a9.

Also available in: Atom PDF