The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/5461
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === This is part 4 of a series of patches to add better progress tracking support for export and import. Add a tracker field to ContainerCreateFromImage and ImageCreate which can be used during Unpack. Signed-off-by: Joel Hockey <[email protected]>
From 31c858fe97ace735ad9803975badc59da81af841 Mon Sep 17 00:00:00 2001 From: Joel Hockey <[email protected]> Date: Sun, 3 Feb 2019 14:03:50 -0800 Subject: [PATCH] storage: Add ioprogress.ProgressTracker field to storage This is part 4 of a series of patches to add better progress tracking support for export and import. Add a tracker field to ContainerCreateFromImage and ImageCreate which can be used during Unpack. Signed-off-by: Joel Hockey <[email protected]> --- lxd/container.go | 5 +++-- lxd/containers_post.go | 4 ++-- lxd/images.go | 2 +- lxd/storage.go | 4 ++-- lxd/storage_btrfs.go | 9 +++++---- lxd/storage_ceph.go | 7 ++++--- lxd/storage_dir.go | 5 +++-- lxd/storage_lvm.go | 5 +++-- lxd/storage_lvm_utils.go | 2 +- lxd/storage_mock.go | 5 +++-- lxd/storage_zfs.go | 7 ++++--- 11 files changed, 31 insertions(+), 24 deletions(-) diff --git a/lxd/container.go b/lxd/container.go index b255f8e07b..af06c744ff 100644 --- a/lxd/container.go +++ b/lxd/container.go @@ -25,6 +25,7 @@ import ( "github.com/lxc/lxd/shared" "github.com/lxc/lxd/shared/api" "github.com/lxc/lxd/shared/idmap" + "github.com/lxc/lxd/shared/ioprogress" log "github.com/lxc/lxd/shared/log15" "github.com/lxc/lxd/shared/logger" "github.com/lxc/lxd/shared/osarch" @@ -768,7 +769,7 @@ func containerCreateEmptySnapshot(s *state.State, args db.ContainerArgs) (contai return c, nil } -func containerCreateFromImage(d *Daemon, args db.ContainerArgs, hash string) (container, error) { +func containerCreateFromImage(d *Daemon, args db.ContainerArgs, hash string, tracker *ioprogress.ProgressTracker) (container, error) { s := d.State() // Get the image properties @@ -827,7 +828,7 @@ func containerCreateFromImage(d *Daemon, args db.ContainerArgs, hash string) (co } // Now create the storage from an image - err = c.Storage().ContainerCreateFromImage(c, hash) + err = c.Storage().ContainerCreateFromImage(c, hash, tracker) if err != nil { c.Delete() return nil, errors.Wrap(err, "Create container from image") diff --git a/lxd/containers_post.go b/lxd/containers_post.go index 1ec8a6b3c6..ad6cdfb008 100644 --- a/lxd/containers_post.go +++ b/lxd/containers_post.go @@ -128,7 +128,7 @@ func createFromImage(d *Daemon, project string, req *api.ContainersPost) Respons return err } - _, err = containerCreateFromImage(d, args, info.Fingerprint) + _, err = containerCreateFromImage(d, args, info.Fingerprint, nil) return err } @@ -356,7 +356,7 @@ func createFromMigration(d *Daemon, project string, req *api.ContainersPost) Res } if ps.MigrationType() == migration.MigrationFSType_RSYNC { - c, err = containerCreateFromImage(d, args, req.Source.BaseImage) + c, err = containerCreateFromImage(d, args, req.Source.BaseImage, nil) if err != nil { return InternalError(err) } diff --git a/lxd/images.go b/lxd/images.go index 67db1b3c39..530d5a17b6 100644 --- a/lxd/images.go +++ b/lxd/images.go @@ -618,7 +618,7 @@ func imageCreateInPool(d *Daemon, info *api.Image, storagePool string) error { // Create the storage volume for the image on the requested storage // pool. - err = s.ImageCreate(info.Fingerprint) + err = s.ImageCreate(info.Fingerprint, nil) if err != nil { return err } diff --git a/lxd/storage.go b/lxd/storage.go index 3b2dca1ddc..3ed516ca2e 100644 --- a/lxd/storage.go +++ b/lxd/storage.go @@ -175,7 +175,7 @@ type storage interface { ContainerCreate(container container) error // ContainerCreateFromImage creates a container from a image. - ContainerCreateFromImage(c container, fingerprint string) error + ContainerCreateFromImage(c container, fingerprint string, tracker *ioprogress.ProgressTracker) error ContainerCanRestore(target container, source container) error ContainerDelete(c container) error ContainerCopy(target container, source container, containerOnly bool) error @@ -201,7 +201,7 @@ type storage interface { ContainerSnapshotCreateEmpty(c container) error // Functions dealing with image storage volumes. - ImageCreate(fingerprint string) error + ImageCreate(fingerprint string, tracker *ioprogress.ProgressTracker) error ImageDelete(fingerprint string) error ImageMount(fingerprint string) (bool, error) ImageUmount(fingerprint string) (bool, error) diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go index 26f6a95b26..e371848e12 100644 --- a/lxd/storage_btrfs.go +++ b/lxd/storage_btrfs.go @@ -22,6 +22,7 @@ import ( "github.com/lxc/lxd/lxd/util" "github.com/lxc/lxd/shared" "github.com/lxc/lxd/shared/api" + "github.com/lxc/lxd/shared/ioprogress" "github.com/lxc/lxd/shared/logger" ) @@ -868,7 +869,7 @@ func (s *storageBtrfs) ContainerCreate(container container) error { } // And this function is why I started hating on btrfs... -func (s *storageBtrfs) ContainerCreateFromImage(container container, fingerprint string) error { +func (s *storageBtrfs) ContainerCreateFromImage(container container, fingerprint string, tracker *ioprogress.ProgressTracker) error { logger.Debugf("Creating BTRFS storage volume for container \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name) source := s.pool.Config["source"] @@ -911,7 +912,7 @@ func (s *storageBtrfs) ContainerCreateFromImage(container container, fingerprint var imgerr error if !shared.PathExists(imageMntPoint) || !isBtrfsSubVolume(imageMntPoint) { - imgerr = s.ImageCreate(fingerprint) + imgerr = s.ImageCreate(fingerprint, tracker) } lxdStorageMapLock.Lock() @@ -2005,7 +2006,7 @@ func (s *storageBtrfs) ContainerBackupLoad(info backupInfo, data io.ReadSeeker, return s.doContainerBackupLoadVanilla(info, data, tarArgs) } -func (s *storageBtrfs) ImageCreate(fingerprint string) error { +func (s *storageBtrfs) ImageCreate(fingerprint string, tracker *ioprogress.ProgressTracker) error { logger.Debugf("Creating BTRFS storage volume for image \"%s\" on storage pool \"%s\"", fingerprint, s.pool.Name) // Create the subvolume. @@ -2057,7 +2058,7 @@ func (s *storageBtrfs) ImageCreate(fingerprint string) error { // Unpack the image in imageMntPoint. imagePath := shared.VarPath("images", fingerprint) - err = unpackImage(imagePath, tmpImageSubvolumeName, storageTypeBtrfs, s.s.OS.RunningInUserNS, nil) + err = unpackImage(imagePath, tmpImageSubvolumeName, storageTypeBtrfs, s.s.OS.RunningInUserNS, tracker) if err != nil { return err } diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go index 8dc18784c0..8158e7a1dc 100644 --- a/lxd/storage_ceph.go +++ b/lxd/storage_ceph.go @@ -15,6 +15,7 @@ import ( "github.com/lxc/lxd/lxd/state" "github.com/lxc/lxd/shared" "github.com/lxc/lxd/shared/api" + "github.com/lxc/lxd/shared/ioprogress" "github.com/lxc/lxd/shared/logger" "github.com/pborman/uuid" @@ -796,7 +797,7 @@ func (s *storageCeph) ContainerCreate(container container) error { return nil } -func (s *storageCeph) ContainerCreateFromImage(container container, fingerprint string) error { +func (s *storageCeph) ContainerCreateFromImage(container container, fingerprint string, tracker *ioprogress.ProgressTracker) error { logger.Debugf(`Creating RBD storage volume for container "%s" on storage pool "%s"`, s.volume.Name, s.pool.Name) revert := true @@ -837,7 +838,7 @@ func (s *storageCeph) ContainerCreateFromImage(container container, fingerprint } if !ok { - imgerr = s.ImageCreate(fingerprint) + imgerr = s.ImageCreate(fingerprint, tracker) } lxdStorageMapLock.Lock() @@ -2083,7 +2084,7 @@ func (s *storageCeph) ContainerBackupLoad(info backupInfo, data io.ReadSeeker, t return nil } -func (s *storageCeph) ImageCreate(fingerprint string) error { +func (s *storageCeph) ImageCreate(fingerprint string, tracker *ioprogress.ProgressTracker) error { logger.Debugf(`Creating RBD storage volume for image "%s" on storage pool "%s"`, fingerprint, s.pool.Name) revert := true diff --git a/lxd/storage_dir.go b/lxd/storage_dir.go index fc32a9d939..6fe7b3e5b1 100644 --- a/lxd/storage_dir.go +++ b/lxd/storage_dir.go @@ -16,6 +16,7 @@ import ( "github.com/lxc/lxd/lxd/state" "github.com/lxc/lxd/shared" "github.com/lxc/lxd/shared/api" + "github.com/lxc/lxd/shared/ioprogress" "github.com/lxc/lxd/shared/logger" ) @@ -513,7 +514,7 @@ func (s *storageDir) ContainerCreate(container container) error { return nil } -func (s *storageDir) ContainerCreateFromImage(container container, imageFingerprint string) error { +func (s *storageDir) ContainerCreateFromImage(container container, imageFingerprint string, tracker *ioprogress.ProgressTracker) error { logger.Debugf("Creating DIR storage volume for container \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name) _, err := s.StoragePoolMount() @@ -1242,7 +1243,7 @@ func (s *storageDir) ContainerBackupLoad(info backupInfo, data io.ReadSeeker, ta return nil } -func (s *storageDir) ImageCreate(fingerprint string) error { +func (s *storageDir) ImageCreate(fingerprint string, tracker *ioprogress.ProgressTracker) error { return nil } diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go index 91b1f9f413..cd1380894e 100644 --- a/lxd/storage_lvm.go +++ b/lxd/storage_lvm.go @@ -17,6 +17,7 @@ import ( "github.com/lxc/lxd/lxd/state" "github.com/lxc/lxd/shared" "github.com/lxc/lxd/shared/api" + "github.com/lxc/lxd/shared/ioprogress" "github.com/lxc/lxd/shared/logger" ) @@ -995,7 +996,7 @@ func (s *storageLvm) ContainerCreate(container container) error { return nil } -func (s *storageLvm) ContainerCreateFromImage(container container, fingerprint string) error { +func (s *storageLvm) ContainerCreateFromImage(container container, fingerprint string, tracker *ioprogress.ProgressTracker) error { logger.Debugf("Creating LVM storage volume for container \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name) tryUndo := true @@ -1908,7 +1909,7 @@ func (s *storageLvm) doContainerBackupLoad(project, containerName string, privil return containerPath, nil } -func (s *storageLvm) ImageCreate(fingerprint string) error { +func (s *storageLvm) ImageCreate(fingerprint string, tracker *ioprogress.ProgressTracker) error { logger.Debugf("Creating LVM storage volume for image \"%s\" on storage pool \"%s\"", fingerprint, s.pool.Name) tryUndo := true diff --git a/lxd/storage_lvm_utils.go b/lxd/storage_lvm_utils.go index 77e7ad8372..e73fc0cffa 100644 --- a/lxd/storage_lvm_utils.go +++ b/lxd/storage_lvm_utils.go @@ -548,7 +548,7 @@ func (s *storageLvm) containerCreateFromImageThinLv(c container, fp string) erro } if !ok { - imgerr = s.ImageCreate(fp) + imgerr = s.ImageCreate(fp, nil) } lxdStorageMapLock.Lock() diff --git a/lxd/storage_mock.go b/lxd/storage_mock.go index c5f2e23772..58c993f511 100644 --- a/lxd/storage_mock.go +++ b/lxd/storage_mock.go @@ -8,6 +8,7 @@ import ( "github.com/lxc/lxd/lxd/migration" "github.com/lxc/lxd/lxd/state" "github.com/lxc/lxd/shared/api" + "github.com/lxc/lxd/shared/ioprogress" "github.com/lxc/lxd/shared/logger" ) @@ -117,7 +118,7 @@ func (s *storageMock) ContainerCreate(container container) error { } func (s *storageMock) ContainerCreateFromImage( - container container, imageFingerprint string) error { + container container, imageFingerprint string, tracker *ioprogress.ProgressTracker) error { return nil } @@ -200,7 +201,7 @@ func (s *storageMock) ContainerBackupLoad(info backupInfo, data io.ReadSeeker, t return nil } -func (s *storageMock) ImageCreate(fingerprint string) error { +func (s *storageMock) ImageCreate(fingerprint string, tracker *ioprogress.ProgressTracker) error { return nil } diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go index 6eff09ff19..0c0f169f4b 100644 --- a/lxd/storage_zfs.go +++ b/lxd/storage_zfs.go @@ -19,6 +19,7 @@ import ( "github.com/lxc/lxd/lxd/util" "github.com/lxc/lxd/shared" "github.com/lxc/lxd/shared/api" + "github.com/lxc/lxd/shared/ioprogress" "github.com/lxc/lxd/shared/logger" "github.com/pborman/uuid" @@ -851,7 +852,7 @@ func (s *storageZfs) ContainerCreate(container container) error { return nil } -func (s *storageZfs) ContainerCreateFromImage(container container, fingerprint string) error { +func (s *storageZfs) ContainerCreateFromImage(container container, fingerprint string, tracker *ioprogress.ProgressTracker) error { logger.Debugf("Creating ZFS storage volume for container \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name) containerPath := container.Path() @@ -876,7 +877,7 @@ func (s *storageZfs) ContainerCreateFromImage(container container, fingerprint s var imgerr error if !zfsFilesystemEntityExists(poolName, fsImage) { - imgerr = s.ImageCreate(fingerprint) + imgerr = s.ImageCreate(fingerprint, tracker) } lxdStorageMapLock.Lock() @@ -2348,7 +2349,7 @@ func (s *storageZfs) ContainerBackupLoad(info backupInfo, data io.ReadSeeker, ta // - mark new zfs volume images/<fingerprint> readonly // - remove mountpoint property from zfs volume images/<fingerprint> // - create read-write snapshot from zfs volume images/<fingerprint> -func (s *storageZfs) ImageCreate(fingerprint string) error { +func (s *storageZfs) ImageCreate(fingerprint string, tracker *ioprogress.ProgressTracker) error { logger.Debugf("Creating ZFS storage volume for image \"%s\" on storage pool \"%s\"", fingerprint, s.pool.Name) poolName := s.getOnDiskPoolName()
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
