[lxc-devel] [lxd/master] Storage: Fixes migration quota
tomponline on Github
lxc-bot at linuxcontainers.org
Mon Nov 16 13:04:24 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201116/2c528ab8/attachment.bin>
-------------- next part --------------
From 02249b25f207f647f1d63c7e60d919607ea81f0e Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 16 Nov 2020 11:27:07 +0000
Subject: [PATCH 1/7] lxd/device/nic/ovn: Removes unused Add function
Same as common device's Add function.
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/device/nic_ovn.go | 5 -----
1 file changed, 5 deletions(-)
diff --git a/lxd/device/nic_ovn.go b/lxd/device/nic_ovn.go
index 5eb94e5125..48bc65fd4d 100644
--- a/lxd/device/nic_ovn.go
+++ b/lxd/device/nic_ovn.go
@@ -212,11 +212,6 @@ func (d *nicOVN) CanHotPlug() (bool, []string) {
return true, []string{}
}
-// Add is run when a device is added to an instance whether or not the instance is running.
-func (d *nicOVN) Add() error {
- return nil
-}
-
// Start is run when the device is added to a running instance or instance is starting up.
func (d *nicOVN) Start() (*deviceConfig.RunConfig, error) {
err := d.validateEnvironment()
From 86cf7529e400d342ef41e42eb967ac17d232f036 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 16 Nov 2020 11:27:32 +0000
Subject: [PATCH 2/7] lxd/device/nic/bridged: Clarifies when device's Add
function is called
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/device/nic_bridged.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/device/nic_bridged.go b/lxd/device/nic_bridged.go
index b6c339de3f..f4b6144adf 100644
--- a/lxd/device/nic_bridged.go
+++ b/lxd/device/nic_bridged.go
@@ -221,7 +221,7 @@ func (d *nicBridged) CanHotPlug() (bool, []string) {
return true, []string{"limits.ingress", "limits.egress", "limits.max", "ipv4.routes", "ipv6.routes", "ipv4.address", "ipv6.address", "security.mac_filtering", "security.ipv4_filtering", "security.ipv6_filtering"}
}
-// Add is run when a device is added to an instance whether or not the instance is running.
+// Add is run when a device is added to a non-snapshot instance whether or not the instance is running.
func (d *nicBridged) Add() error {
// Rebuild dnsmasq entry if needed and reload.
err := d.rebuildDnsmasqEntry()
From 656de3fac283129b9ee5a4d2927be6dafa375490 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 16 Nov 2020 13:00:16 +0000
Subject: [PATCH 3/7] lxd/migrate/instance: Improves comments when
instantiating migration.VolumeTargetArgs
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/migrate_instance.go | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lxd/migrate_instance.go b/lxd/migrate_instance.go
index f633eae312..2f5f970818 100644
--- a/lxd/migrate_instance.go
+++ b/lxd/migrate_instance.go
@@ -872,10 +872,10 @@ func (c *migrationSink) Do(state *state.State, migrateOp *operations.Operation)
volTargetArgs := migration.VolumeTargetArgs{
Name: args.Instance.Name(),
MigrationType: respTypes[0],
- Refresh: args.Refresh, // Indicate to receiver volume should exist.
- TrackProgress: false, // Do not use a progress tracker on receiver.
- Live: args.Live, // Indicates we will get a final rootfs sync.
- VolumeSize: args.VolumeSize,
+ Refresh: args.Refresh, // Indicate to receiver volume should exist.
+ TrackProgress: false, // Do not use a progress tracker on receiver.
+ Live: args.Live, // Indicates we will get a final rootfs sync.
+ VolumeSize: args.VolumeSize, // Block size setting override.
}
// At this point we have already figured out the parent container's root
@@ -1045,7 +1045,7 @@ func (c *migrationSink) Do(state *state.State, migrateOp *operations.Operation)
Refresh: c.refresh,
RsyncFeatures: rsyncFeatures,
Snapshots: snapshots,
- VolumeSize: offerHeader.GetVolumeSize(),
+ VolumeSize: offerHeader.GetVolumeSize(), // Block size setting override.
}
err = myTarget(fsConn, migrateOp, args)
From 14ae58156cea7864c36880cb5356ac36b73b0577 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 16 Nov 2020 13:00:52 +0000
Subject: [PATCH 4/7] lxd/storage/backend/lxd: Improves comments when
instantiating migration.VolumeTargetArgs
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/backend_lxd.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go
index 3d84d673ba..4f8b9cc948 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -757,8 +757,8 @@ func (b *lxdBackend) CreateInstanceFromCopy(inst instance.Instance, src instance
Name: inst.Name(),
Snapshots: snapshotNames,
MigrationType: migrationTypes[0],
- VolumeSize: srcVolumeSize,
- TrackProgress: false, // Do not use a progress tracker on receiver.
+ VolumeSize: srcVolumeSize, // Block size setting override.
+ TrackProgress: false, // Do not use a progress tracker on receiver.
}, op)
if err != nil {
@@ -2559,7 +2559,7 @@ func (b *lxdBackend) CreateCustomVolumeFromCopy(projectName string, volName stri
MigrationType: migrationTypes[0],
TrackProgress: false, // Do not use a progress tracker on receiver.
ContentType: string(contentType),
- VolumeSize: volSize,
+ VolumeSize: volSize, // Block size setting override.
}, op)
if err != nil {
From 46671869a3191f6fc55daf1cfaf550e60656abec Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 16 Nov 2020 13:01:36 +0000
Subject: [PATCH 5/7] lxd/storage/backend/lxd: Reject custom volume config if
supplied in CreateInstanceFromMigration
Avoids confusion around where disk config is coming from.
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/backend_lxd.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go
index 4f8b9cc948..c1b63dad58 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -1085,6 +1085,10 @@ func (b *lxdBackend) CreateInstanceFromMigration(inst instance.Instance, conn io
logger.Debug("CreateInstanceFromMigration started")
defer logger.Debug("CreateInstanceFromMigration finished")
+ if args.Config != nil {
+ return fmt.Errorf("Migration VolumeTargetArgs.Config cannot be set")
+ }
+
volType, err := InstanceTypeToVolumeType(inst.Type())
if err != nil {
return err
From 40a5c7521051e3d4ff8b95cd1618e3a40214df23 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 16 Nov 2020 13:02:14 +0000
Subject: [PATCH 6/7] lxd/storage/drivers/driver/zfs/volumes: Use
srcVol.NewVMBlockFilesystemVolume in CreateVolumeFromCopy
Ensures VM filesystem volume has correct quota set.
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/drivers/driver_zfs_volumes.go | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/lxd/storage/drivers/driver_zfs_volumes.go b/lxd/storage/drivers/driver_zfs_volumes.go
index ce60248503..bb6ff607cc 100644
--- a/lxd/storage/drivers/driver_zfs_volumes.go
+++ b/lxd/storage/drivers/driver_zfs_volumes.go
@@ -444,19 +444,18 @@ func (d *zfs) CreateVolumeFromCopy(vol Volume, srcVol Volume, copySnapshots bool
}
// For VMs, also copy the filesystem dataset.
- if vol.volType == VolumeTypeVM && vol.contentType == ContentTypeBlock {
- fsVol := NewVolume(d, d.name, vol.volType, ContentTypeFS, vol.name, vol.config, vol.poolConfig)
- fsSrcVol := NewVolume(d, d.name, srcVol.volType, ContentTypeFS, srcVol.name, srcVol.config, srcVol.poolConfig)
+ if vol.IsVMBlock() {
+ // For VMs, also copy the filesystem volume.
+ srcFSVol := srcVol.NewVMBlockFilesystemVolume()
+ fsVol := vol.NewVMBlockFilesystemVolume()
- err := d.CreateVolumeFromCopy(fsVol, fsSrcVol, copySnapshots, op)
+ err := d.CreateVolumeFromCopy(fsVol, srcFSVol, copySnapshots, op)
if err != nil {
return err
}
// Delete on revert.
- revert.Add(func() {
- d.DeleteVolume(fsVol, op)
- })
+ revert.Add(func() { d.DeleteVolume(fsVol, op) })
}
// Retrieve snapshots on the source.
From 59f92e958736f266e7a4977bca2f3d820fee7bb4 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 16 Nov 2020 13:03:41 +0000
Subject: [PATCH 7/7] lxd/storage/drivers/driver/zfs/volumes: Apply filesystem
quota in CreateVolumeFromMigration
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/drivers/driver_zfs_volumes.go | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lxd/storage/drivers/driver_zfs_volumes.go b/lxd/storage/drivers/driver_zfs_volumes.go
index bb6ff607cc..e114c82e66 100644
--- a/lxd/storage/drivers/driver_zfs_volumes.go
+++ b/lxd/storage/drivers/driver_zfs_volumes.go
@@ -736,6 +736,12 @@ func (d *zfs) CreateVolumeFromMigration(vol Volume, conn io.ReadWriteCloser, vol
if err != nil {
return err
}
+
+ // Apply the size limit.
+ err = d.SetVolumeQuota(vol, vol.ConfigSize(), op)
+ if err != nil {
+ return err
+ }
}
return nil
More information about the lxc-devel
mailing list