From 8f9cc76a07f8bc50aac067c507e00b7d6c404df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Peliz=C3=A4us?= Date: Wed, 6 Dec 2023 11:50:47 +0100 Subject: [PATCH 1/7] [lxd-import] lxd/storage/s3/miniod: Discover port using IPv4 address family MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case MinIO gets enabled on a system with IPv6 disabled, binding to the IPv6 localhost address during port discovery will fail due to an unsupported address family. Signed-off-by: Julian Pelizäus --- internal/server/storage/s3/miniod/miniod.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/server/storage/s3/miniod/miniod.go b/internal/server/storage/s3/miniod/miniod.go index f78b38a1cd0..9c3807dcec2 100644 --- a/internal/server/storage/s3/miniod/miniod.go +++ b/internal/server/storage/s3/miniod/miniod.go @@ -30,7 +30,7 @@ import ( ) // minioHost is the host address that the local MinIO processes will listen on. -const minioHost = "[::1]" +const minioHost = "127.0.0.1" // minioLockPrefix is the prefix used for per-bucket MinIO spawn lock. const minioLockPrefix = "minio_" From a89a9e9b0f4f8a312c019b5379fbbfa374bac349 Mon Sep 17 00:00:00 2001 From: Din Music Date: Thu, 7 Dec 2023 14:25:33 +0100 Subject: [PATCH 2/7] [lxd-import] lxd-agent: Prevent panic when dev-incus server is stopped Signed-off-by: Din Music --- cmd/incus-agent/api_1.0.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/incus-agent/api_1.0.go b/cmd/incus-agent/api_1.0.go index 470b2af5b63..4bfd214cfa7 100644 --- a/cmd/incus-agent/api_1.0.go +++ b/cmd/incus-agent/api_1.0.go @@ -171,7 +171,11 @@ func stopDevIncusServer(d *Daemon) error { d.DevIncusRunning = false d.DevIncusMu.Unlock() - return servers["DevIncus"].Close() + if servers["DevIncus"] != nil { + return servers["DevIncus"].Close() + } + + return nil } func getClient(CID uint32, port int, serverCertificate string) (*http.Client, error) { From e76fe5e8c5765f07a57a8d7f7002de1cbfccd866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Peliz=C3=A4us?= Date: Thu, 7 Dec 2023 11:51:30 +0100 Subject: [PATCH 3/7] [lxd-import] lxd/storage/drivers: Always copy Ceph VMs filesystem volume MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Additionally pass down the information to copy snapshots from CreateVolumeFromCopy and revert the filesystem volume creation in case of error. Signed-off-by: Julian Pelizäus --- .../storage/drivers/driver_ceph_volumes.go | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/internal/server/storage/drivers/driver_ceph_volumes.go b/internal/server/storage/drivers/driver_ceph_volumes.go index 9fabec4d85b..587e5aaee4e 100644 --- a/internal/server/storage/drivers/driver_ceph_volumes.go +++ b/internal/server/storage/drivers/driver_ceph_volumes.go @@ -364,6 +364,19 @@ func (d *ceph) CreateVolumeFromCopy(vol Volume, srcVol Volume, copySnapshots boo return nil } + // For VMs, also copy the filesystem volume. + if vol.IsVMBlock() { + srcFSVol := srcVol.NewVMBlockFilesystemVolume() + fsVol := vol.NewVMBlockFilesystemVolume() + err := d.CreateVolumeFromCopy(fsVol, srcFSVol, copySnapshots, false, op) + if err != nil { + return err + } + + // Delete on revert. + revert.Add(func() { _ = d.DeleteVolume(fsVol, op) }) + } + // Retrieve snapshots on the source. snapshots := []string{} if !srcVol.IsSnapshot() && copySnapshots { @@ -433,16 +446,6 @@ func (d *ceph) CreateVolumeFromCopy(vol Volume, srcVol Volume, copySnapshots boo revert.Add(func() { _ = d.DeleteVolume(vol, op) }) } - // For VMs, also copy the filesystem volume. - if vol.IsVMBlock() { - srcFSVol := srcVol.NewVMBlockFilesystemVolume() - fsVol := vol.NewVMBlockFilesystemVolume() - err := d.CreateVolumeFromCopy(fsVol, srcFSVol, false, false, op) - if err != nil { - return err - } - } - err = postCreateTasks(vol) if err != nil { return err From a4f4de27b7fb92208fe2b8001cb81923d0bc5621 Mon Sep 17 00:00:00 2001 From: Ruth Fuchss Date: Thu, 7 Dec 2023 14:43:29 +0100 Subject: [PATCH 4/7] [lxd-import] doc/cloud-init: overwrite link text to make spell checker happy In the cloud-init doc, "config" is allowed as a word. It's not a word though. ;-) Signed-off-by: Ruth Fuchss --- doc/cloud-init.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cloud-init.md b/doc/cloud-init.md index a4384905939..3984deeabed 100644 --- a/doc/cloud-init.md +++ b/doc/cloud-init.md @@ -88,7 +88,7 @@ config: ``` ```{tip} -See {doc}`How to validate user data cloud configuration ` for information on how to check whether the syntax is correct. +See {ref}`How to validate user data ` for information on how to check whether the syntax is correct. ``` ## How to check the `cloud-init` status From 2a072579c23ad348a87d3f46f959c8d58b3fdd33 Mon Sep 17 00:00:00 2001 From: Mark Laing Date: Fri, 8 Dec 2023 10:00:21 +0000 Subject: [PATCH 5/7] [lxd-import] client: Always use event listener for operations. When long polling the operation wait endpoint, we can never guarantee that the request will not time out for very long operations (e.g. an exec session) because intermediate proxies or load balancers may timeout the request if there is no activity. This commit changes the `useEventListener` argument to getOperations to true for all requests. Regardless of whether the `operation_wait` API extension is present. Signed-off-by: Mark Laing --- client/incus_instances.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/incus_instances.go b/client/incus_instances.go index 0a14e3f3b45..f173ed53821 100644 --- a/client/incus_instances.go +++ b/client/incus_instances.go @@ -1112,8 +1112,7 @@ func (r *ProtocolIncus) ExecInstance(instanceName string, exec api.InstanceExecP } // Send the request - useEventListener := r.CheckExtension("operation_wait") != nil - op, _, err := r.queryOperation("POST", uri, exec, "", useEventListener) + op, _, err := r.queryOperation("POST", uri, exec, "", true) if err != nil { return nil, err } From 48071b1efc27a2c5d46173b871e135654907d316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Peliz=C3=A4us?= Date: Fri, 8 Dec 2023 14:55:05 +0000 Subject: [PATCH 6/7] [lxd-import] lxd/instance/drivers/qemu: Load storage pool before accessing it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was caused by a regression in https://github.com/lxc/incus/pull/12566. When validating the live migration of a VM, the pool needs to be loaded first since that is the first time the value gets accessed. Signed-off-by: Julian Pelizäus --- internal/server/instance/drivers/driver_qemu.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/server/instance/drivers/driver_qemu.go b/internal/server/instance/drivers/driver_qemu.go index da5efaa797b..55751f8ad34 100644 --- a/internal/server/instance/drivers/driver_qemu.go +++ b/internal/server/instance/drivers/driver_qemu.go @@ -1044,7 +1044,13 @@ func (d *qemu) validateStartup(stateful bool, statusCode api.StatusCode) error { return err } - stateDiskSizeStr := d.storagePool.Driver().Info().DefaultVMBlockFilesystemSize + // Don't access d.storagePool directly since it isn't populated at this stage. + pool, err := d.getStoragePool() + if err != nil { + return err + } + + stateDiskSizeStr := pool.Driver().Info().DefaultVMBlockFilesystemSize if rootDiskDevice["size.state"] != "" { stateDiskSizeStr = rootDiskDevice["size.state"] } From 9bfec57926ac460f6676f8a441d3e6d84a65124a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 8 Dec 2023 18:28:51 -0500 Subject: [PATCH 7/7] Revert "[lxd-import] client: Always use event listener for operations." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 2a072579c23ad348a87d3f46f959c8d58b3fdd33. Revert this one for now as it prevents events operations with OpenFGA. Signed-off-by: Stéphane Graber --- client/incus_instances.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/incus_instances.go b/client/incus_instances.go index f173ed53821..0a14e3f3b45 100644 --- a/client/incus_instances.go +++ b/client/incus_instances.go @@ -1112,7 +1112,8 @@ func (r *ProtocolIncus) ExecInstance(instanceName string, exec api.InstanceExecP } // Send the request - op, _, err := r.queryOperation("POST", uri, exec, "", true) + useEventListener := r.CheckExtension("operation_wait") != nil + op, _, err := r.queryOperation("POST", uri, exec, "", useEventListener) if err != nil { return nil, err }