From e1c32d2aae9f6ade144649048a799b4968c92671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:20:13 -0400 Subject: [PATCH 01/14] incusd/storage/s3: Rename admin user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- incusd/storage/s3/miniod/miniod.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/incusd/storage/s3/miniod/miniod.go b/incusd/storage/s3/miniod/miniod.go index a54c80e1223..4f1dff6175c 100644 --- a/incusd/storage/s3/miniod/miniod.go +++ b/incusd/storage/s3/miniod/miniod.go @@ -35,7 +35,7 @@ const minioHost = "[::1]" const minioLockPrefix = "minio_" // minioAdminUser in MinIO. -const minioAdminUser = "lxd-admin" +const minioAdminUser = "incus-admin" // minioBucketDir the directory on the storage volume used for the MinIO bucket. const minioBucketDir = "minio" From 8cbf2080820024ef70681e6155f3ebdbd7d0f697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:20:43 -0400 Subject: [PATCH 02/14] incusd/storage: Rename lxdBackend to backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- .../storage/{backend_incus.go => backend.go} | 224 +++++++++--------- ...nd_incus_patches.go => backend_patches.go} | 10 +- incusd/storage/pool_load.go | 6 +- incusd/storage/utils.go | 30 +-- 4 files changed, 135 insertions(+), 135 deletions(-) rename incusd/storage/{backend_incus.go => backend.go} (94%) rename incusd/storage/{backend_incus_patches.go => backend_patches.go} (95%) diff --git a/incusd/storage/backend_incus.go b/incusd/storage/backend.go similarity index 94% rename from incusd/storage/backend_incus.go rename to incusd/storage/backend.go index 73e999bb7a3..f613c763a4a 100644 --- a/incusd/storage/backend_incus.go +++ b/incusd/storage/backend.go @@ -64,7 +64,7 @@ var instanceDiskVolumeEffectiveFields = []string{ "size.state", } -type lxdBackend struct { +type backend struct { driver drivers.Driver id int64 db api.StoragePool @@ -75,22 +75,22 @@ type lxdBackend struct { } // ID returns the storage pool ID. -func (b *lxdBackend) ID() int64 { +func (b *backend) ID() int64 { return b.id } // Name returns the storage pool name. -func (b *lxdBackend) Name() string { +func (b *backend) Name() string { return b.name } // Description returns the storage pool description. -func (b *lxdBackend) Description() string { +func (b *backend) Description() string { return b.db.Description } // ValidateName validates the provided name, and returns an error if it's not a valid storage name. -func (b *lxdBackend) ValidateName(value string) error { +func (b *backend) ValidateName(value string) error { if strings.Contains(value, "/") { return fmt.Errorf(`Storage name cannot contain "/"`) } @@ -105,17 +105,17 @@ func (b *lxdBackend) ValidateName(value string) error { } // Validate storage pool config. -func (b *lxdBackend) Validate(config map[string]string) error { +func (b *backend) Validate(config map[string]string) error { return b.Driver().Validate(config) } // Status returns the storage pool status. -func (b *lxdBackend) Status() string { +func (b *backend) Status() string { return b.db.Status } // LocalStatus returns storage pool status of the local cluster member. -func (b *lxdBackend) LocalStatus() string { +func (b *backend) LocalStatus() string { // Check if pool is unavailable locally and replace status if so. // But don't modify b.db.Status as the status may be recovered later so we don't want to persist it here. if !IsAvailable(b.name) { @@ -131,7 +131,7 @@ func (b *lxdBackend) LocalStatus() string { } // isStatusReady returns an error if pool is not ready for use on this server. -func (b *lxdBackend) isStatusReady() error { +func (b *backend) isStatusReady() error { if b.Status() == api.StoragePoolStatusPending { return fmt.Errorf("Specified pool is not fully created") } @@ -144,12 +144,12 @@ func (b *lxdBackend) isStatusReady() error { } // ToAPI returns the storage pool as an API representation. -func (b *lxdBackend) ToAPI() api.StoragePool { +func (b *backend) ToAPI() api.StoragePool { return b.db } // Driver returns the storage pool driver. -func (b *lxdBackend) Driver() drivers.Driver { +func (b *backend) Driver() drivers.Driver { return b.driver } @@ -157,13 +157,13 @@ func (b *lxdBackend) Driver() drivers.Driver { // based on the migration method requested by the driver's ability. The snapshots argument // indicates whether snapshots are migrated as well. It is used to determine whether to use // optimized migration. -func (b *lxdBackend) MigrationTypes(contentType drivers.ContentType, refresh bool, copySnapshots bool) []migration.Type { +func (b *backend) MigrationTypes(contentType drivers.ContentType, refresh bool, copySnapshots bool) []migration.Type { return b.driver.MigrationTypes(contentType, refresh, copySnapshots) } // Create creates the storage pool layout on the storage device. // localOnly is used for clustering where only a single node should do remote storage setup. -func (b *lxdBackend) Create(clientType request.ClientType, op *operations.Operation) error { +func (b *backend) Create(clientType request.ClientType, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"config": b.db.Config, "description": b.db.Description, "clientType": clientType}) l.Debug("Create started") defer l.Debug("Create finished") @@ -242,12 +242,12 @@ func (b *lxdBackend) Create(clientType request.ClientType, op *operations.Operat } // GetVolume returns a drivers.Volume containing copies of the supplied volume config and the pools config. -func (b *lxdBackend) GetVolume(volType drivers.VolumeType, contentType drivers.ContentType, volName string, volConfig map[string]string) drivers.Volume { +func (b *backend) GetVolume(volType drivers.VolumeType, contentType drivers.ContentType, volName string, volConfig map[string]string) drivers.Volume { return drivers.NewVolume(b.driver, b.name, volType, contentType, volName, volConfig, b.db.Config).Clone() } // GetResources returns utilisation information about the pool. -func (b *lxdBackend) GetResources() (*api.ResourcesStoragePool, error) { +func (b *backend) GetResources() (*api.ResourcesStoragePool, error) { l := b.logger.AddContext(nil) l.Debug("GetResources started") defer l.Debug("GetResources finished") @@ -256,7 +256,7 @@ func (b *lxdBackend) GetResources() (*api.ResourcesStoragePool, error) { } // IsUsed returns whether the storage pool is used by any volumes or profiles (excluding image volumes). -func (b *lxdBackend) IsUsed() (bool, error) { +func (b *backend) IsUsed() (bool, error) { usedBy, err := UsedBy(context.TODO(), b.state, b, true, true, db.StoragePoolVolumeTypeNameImage) if err != nil { return false, err @@ -266,7 +266,7 @@ func (b *lxdBackend) IsUsed() (bool, error) { } // Update updates the pool config. -func (b *lxdBackend) Update(clientType request.ClientType, newDesc string, newConfig map[string]string, op *operations.Operation) error { +func (b *backend) Update(clientType request.ClientType, newDesc string, newConfig map[string]string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"newDesc": newDesc, "newConfig": newConfig}) l.Debug("Update started") defer l.Debug("Update finished") @@ -318,7 +318,7 @@ func (b *lxdBackend) Update(clientType request.ClientType, newDesc string, newCo } // warningsDelete deletes any persistent warnings for the pool. -func (b *lxdBackend) warningsDelete() error { +func (b *backend) warningsDelete() error { err := b.state.DB.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error { return cluster.DeleteWarnings(ctx, tx.Tx(), cluster.TypeStoragePool, int(b.ID())) }) @@ -330,7 +330,7 @@ func (b *lxdBackend) warningsDelete() error { } // Delete removes the pool. -func (b *lxdBackend) Delete(clientType request.ClientType, op *operations.Operation) error { +func (b *backend) Delete(clientType request.ClientType, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"clientType": clientType}) l.Debug("Delete started") defer l.Debug("Delete finished") @@ -402,7 +402,7 @@ func (b *lxdBackend) Delete(clientType request.ClientType, op *operations.Operat } // Mount mounts the storage pool. -func (b *lxdBackend) Mount() (bool, error) { +func (b *backend) Mount() (bool, error) { b.logger.Debug("Mount started") defer b.logger.Debug("Mount finished") @@ -451,7 +451,7 @@ func (b *lxdBackend) Mount() (bool, error) { } // Unmount unmounts the storage pool. -func (b *lxdBackend) Unmount() (bool, error) { +func (b *backend) Unmount() (bool, error) { b.logger.Debug("Unmount started") defer b.logger.Debug("Unmount finished") @@ -459,11 +459,11 @@ func (b *lxdBackend) Unmount() (bool, error) { } // ApplyPatch runs the requested patch at both backend and driver level. -func (b *lxdBackend) ApplyPatch(name string) error { +func (b *backend) ApplyPatch(name string) error { b.logger.Info("Applying patch", logger.Ctx{"name": name}) // Run early backend patches. - patch, ok := lxdEarlyPatches[name] + patch, ok := earlyPatches[name] if ok { err := patch(b) if err != nil { @@ -478,7 +478,7 @@ func (b *lxdBackend) ApplyPatch(name string) error { } // Run late backend patches. - patch, ok = lxdLatePatches[name] + patch, ok = latePatches[name] if ok { err := patch(b) if err != nil { @@ -491,7 +491,7 @@ func (b *lxdBackend) ApplyPatch(name string) error { // ensureInstanceSymlink creates a symlink in the instance directory to the instance's mount path // if doesn't exist already. -func (b *lxdBackend) ensureInstanceSymlink(instanceType instancetype.Type, projectName string, instanceName string, mountPath string) error { +func (b *backend) ensureInstanceSymlink(instanceType instancetype.Type, projectName string, instanceName string, mountPath string) error { if shared.IsSnapshot(instanceName) { return fmt.Errorf("Instance must not be snapshot") } @@ -516,7 +516,7 @@ func (b *lxdBackend) ensureInstanceSymlink(instanceType instancetype.Type, proje } // removeInstanceSymlink removes a symlink in the instance directory to the instance's mount path. -func (b *lxdBackend) removeInstanceSymlink(instanceType instancetype.Type, projectName string, instanceName string) error { +func (b *backend) removeInstanceSymlink(instanceType instancetype.Type, projectName string, instanceName string) error { symlinkPath := InstancePath(instanceType, projectName, instanceName, false) if shared.PathExists(symlinkPath) { @@ -531,7 +531,7 @@ func (b *lxdBackend) removeInstanceSymlink(instanceType instancetype.Type, proje // ensureInstanceSnapshotSymlink creates a symlink in the snapshot directory to the instance's // snapshot path if doesn't exist already. -func (b *lxdBackend) ensureInstanceSnapshotSymlink(instanceType instancetype.Type, projectName string, instanceName string) error { +func (b *backend) ensureInstanceSnapshotSymlink(instanceType instancetype.Type, projectName string, instanceName string) error { // Check we can convert the instance to the volume type needed. volType, err := InstanceTypeToVolumeType(instanceType) if err != nil { @@ -564,7 +564,7 @@ func (b *lxdBackend) ensureInstanceSnapshotSymlink(instanceType instancetype.Typ // removeInstanceSnapshotSymlinkIfUnused removes the symlink in the snapshot directory to the // instance's snapshot path if the snapshot path is missing. It is expected that the driver will // remove the instance's snapshot path after the last snapshot is removed or the volume is deleted. -func (b *lxdBackend) removeInstanceSnapshotSymlinkIfUnused(instanceType instancetype.Type, projectName string, instanceName string) error { +func (b *backend) removeInstanceSnapshotSymlinkIfUnused(instanceType instancetype.Type, projectName string, instanceName string) error { // Check we can convert the instance to the volume type needed. volType, err := InstanceTypeToVolumeType(instanceType) if err != nil { @@ -591,7 +591,7 @@ func (b *lxdBackend) removeInstanceSnapshotSymlinkIfUnused(instanceType instance } // applyInstanceRootDiskOverrides applies the instance's root disk config to the volume's config. -func (b *lxdBackend) applyInstanceRootDiskOverrides(inst instance.Instance, vol *drivers.Volume) error { +func (b *backend) applyInstanceRootDiskOverrides(inst instance.Instance, vol *drivers.Volume) error { _, rootDiskConf, err := shared.GetRootDiskDevice(inst.ExpandedDevices().CloneNative()) if err != nil { return err @@ -614,7 +614,7 @@ func (b *lxdBackend) applyInstanceRootDiskOverrides(inst instance.Instance, vol } // CreateInstance creates an empty instance. -func (b *lxdBackend) CreateInstance(inst instance.Instance, op *operations.Operation) error { +func (b *backend) CreateInstance(inst instance.Instance, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("CreateInstance started") defer l.Debug("CreateInstance finished") @@ -677,7 +677,7 @@ func (b *lxdBackend) CreateInstance(inst instance.Instance, op *operations.Opera // it is necessary to return two functions; a post hook that can be run once the instance has been // created in the database to run any storage layer finalisations, and a revert hook that can be // run if the instance database load process fails that will remove anything created thus far. -func (b *lxdBackend) CreateInstanceFromBackup(srcBackup backup.Info, srcData io.ReadSeeker, op *operations.Operation) (func(instance.Instance) error, revert.Hook, error) { +func (b *backend) CreateInstanceFromBackup(srcBackup backup.Info, srcData io.ReadSeeker, op *operations.Operation) (func(instance.Instance) error, revert.Hook, error) { l := b.logger.AddContext(logger.Ctx{"project": srcBackup.Project, "instance": srcBackup.Name, "snapshots": srcBackup.Snapshots, "optimizedStorage": *srcBackup.OptimizedStorage}) l.Debug("CreateInstanceFromBackup started") defer l.Debug("CreateInstanceFromBackup finished") @@ -917,7 +917,7 @@ func (b *lxdBackend) CreateInstanceFromBackup(srcBackup backup.Info, srcData io. } // CreateInstanceFromCopy copies an instance volume and optionally its snapshots to new volume(s). -func (b *lxdBackend) CreateInstanceFromCopy(inst instance.Instance, src instance.Instance, snapshots bool, allowInconsistent bool, op *operations.Operation) error { +func (b *backend) CreateInstanceFromCopy(inst instance.Instance, src instance.Instance, snapshots bool, allowInconsistent bool, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "src": src.Name(), "snapshots": snapshots}) l.Debug("CreateInstanceFromCopy started") defer l.Debug("CreateInstanceFromCopy finished") @@ -944,9 +944,9 @@ func (b *lxdBackend) CreateInstanceFromCopy(inst instance.Instance, src instance return err } - srcPoolBackend, ok := srcPool.(*lxdBackend) + srcPoolBackend, ok := srcPool.(*backend) if !ok { - return fmt.Errorf("Source pool is not a lxdBackend") + return fmt.Errorf("Source pool is not a backend") } // Check source volume exists, and get its config. @@ -1123,7 +1123,7 @@ func (b *lxdBackend) CreateInstanceFromCopy(inst instance.Instance, src instance // RefreshCustomVolume refreshes custom volumes (and optionally snapshots) during the custom volume copy operations. // Snapshots that are not present in the source but are in the destination are removed from the // destination if snapshots are included in the synchronization. -func (b *lxdBackend) RefreshCustomVolume(projectName string, srcProjectName string, volName string, desc string, config map[string]string, srcPoolName, srcVolName string, snapshots bool, op *operations.Operation) error { +func (b *backend) RefreshCustomVolume(projectName string, srcProjectName string, volName string, desc string, config map[string]string, srcPoolName, srcVolName string, snapshots bool, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "srcProjectName": srcProjectName, "volName": volName, "desc": desc, "config": config, "srcPoolName": srcPoolName, "srcVolName": srcVolName, "snapshots": snapshots}) l.Debug("RefreshCustomVolume started") defer l.Debug("RefreshCustomVolume finished") @@ -1295,9 +1295,9 @@ func (b *lxdBackend) RefreshCustomVolume(projectName string, srcProjectName stri if contentType == drivers.ContentTypeBlock { err = srcVol.MountTask(func(mountPath string, op *operations.Operation) error { - srcPoolBackend, ok := srcPool.(*lxdBackend) + srcPoolBackend, ok := srcPool.(*backend) if !ok { - return fmt.Errorf("Pool is not a lxdBackend") + return fmt.Errorf("Pool is not a backend") } volDiskPath, err := srcPoolBackend.driver.GetVolumeDiskPath(srcVol) @@ -1392,7 +1392,7 @@ func (b *lxdBackend) RefreshCustomVolume(projectName string, srcProjectName stri // Snapshots that are not present in the source but are in the destination are removed from the // destination if snapshots are included in the synchronisation. An empty srcSnapshots argument // indicates a volume-only refresh. -func (b *lxdBackend) RefreshInstance(inst instance.Instance, src instance.Instance, srcSnapshots []instance.Instance, allowInconsistent bool, op *operations.Operation) error { +func (b *backend) RefreshInstance(inst instance.Instance, src instance.Instance, srcSnapshots []instance.Instance, allowInconsistent bool, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "src": src.Name(), "srcSnapshots": len(srcSnapshots)}) l.Debug("RefreshInstance started") defer l.Debug("RefreshInstance finished") @@ -1431,9 +1431,9 @@ func (b *lxdBackend) RefreshInstance(inst instance.Instance, src instance.Instan return err } - srcPoolBackend, ok := srcPool.(*lxdBackend) + srcPoolBackend, ok := srcPool.(*backend) if !ok { - return fmt.Errorf("Source pool is not a lxdBackend") + return fmt.Errorf("Source pool is not a backend") } // Check source volume exists, and get its config. @@ -1590,7 +1590,7 @@ func (b *lxdBackend) RefreshInstance(inst instance.Instance, src instance.Instan // imageFiller returns a function that can be used as a filler function with CreateVolume(). // The function returned will unpack the specified image archive into the specified mount path // provided, and for VM images, a raw root block path is required to unpack the qcow2 image into. -func (b *lxdBackend) imageFiller(fingerprint string, op *operations.Operation) func(vol drivers.Volume, rootBlockPath string, allowUnsafeResize bool) (int64, error) { +func (b *backend) imageFiller(fingerprint string, op *operations.Operation) func(vol drivers.Volume, rootBlockPath string, allowUnsafeResize bool) (int64, error) { return func(vol drivers.Volume, rootBlockPath string, allowUnsafeResize bool) (int64, error) { var tracker *ioprogress.ProgressTracker if op != nil { // Not passed when being done as part of pre-migration setup. @@ -1610,7 +1610,7 @@ func (b *lxdBackend) imageFiller(fingerprint string, op *operations.Operation) f // isoFiller returns a function that can be used as a filler function with CreateVolume(). // The function returned will copy the ISO content into the specified mount path // provided. -func (b *lxdBackend) isoFiller(data io.Reader) func(vol drivers.Volume, rootBlockPath string, allowUnsafeResize bool) (int64, error) { +func (b *backend) isoFiller(data io.Reader) func(vol drivers.Volume, rootBlockPath string, allowUnsafeResize bool) (int64, error) { return func(vol drivers.Volume, rootBlockPath string, allowUnsafeResize bool) (int64, error) { f, err := os.OpenFile(rootBlockPath, os.O_CREATE|os.O_WRONLY, 0600) if err != nil { @@ -1625,7 +1625,7 @@ func (b *lxdBackend) isoFiller(data io.Reader) func(vol drivers.Volume, rootBloc // CreateInstanceFromImage creates a new volume for an instance populated with the image requested. // On failure caller is expected to call DeleteInstance() to clean up. -func (b *lxdBackend) CreateInstanceFromImage(inst instance.Instance, fingerprint string, op *operations.Operation) error { +func (b *backend) CreateInstanceFromImage(inst instance.Instance, fingerprint string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("CreateInstanceFromImage started") defer l.Debug("CreateInstanceFromImage finished") @@ -1747,7 +1747,7 @@ func (b *lxdBackend) CreateInstanceFromImage(inst instance.Instance, fingerprint // CreateInstanceFromMigration receives an instance being migrated. // The args.Name and args.Config fields are ignored and, instance properties are used instead. -func (b *lxdBackend) CreateInstanceFromMigration(inst instance.Instance, conn io.ReadWriteCloser, args migration.VolumeTargetArgs, op *operations.Operation) error { +func (b *backend) CreateInstanceFromMigration(inst instance.Instance, conn io.ReadWriteCloser, args migration.VolumeTargetArgs, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "args": fmt.Sprintf("%+v", args)}) l.Debug("CreateInstanceFromMigration started") defer l.Debug("CreateInstanceFromMigration finished") @@ -1989,7 +1989,7 @@ func (b *lxdBackend) CreateInstanceFromMigration(inst instance.Instance, conn io } // RenameInstance renames the instance's root volume and any snapshot volumes. -func (b *lxdBackend) RenameInstance(inst instance.Instance, newName string, op *operations.Operation) error { +func (b *backend) RenameInstance(inst instance.Instance, newName string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "newName": newName}) l.Debug("RenameInstance started") defer l.Debug("RenameInstance finished") @@ -2113,7 +2113,7 @@ func (b *lxdBackend) RenameInstance(inst instance.Instance, newName string, op * } // DeleteInstance removes the instance's root volume (all snapshots need to be removed first). -func (b *lxdBackend) DeleteInstance(inst instance.Instance, op *operations.Operation) error { +func (b *backend) DeleteInstance(inst instance.Instance, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("DeleteInstance started") defer l.Debug("DeleteInstance finished") @@ -2183,7 +2183,7 @@ func (b *lxdBackend) DeleteInstance(inst instance.Instance, op *operations.Opera } // UpdateInstance updates an instance volume's config. -func (b *lxdBackend) UpdateInstance(inst instance.Instance, newDesc string, newConfig map[string]string, op *operations.Operation) error { +func (b *backend) UpdateInstance(inst instance.Instance, newDesc string, newConfig map[string]string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "newDesc": newDesc, "newConfig": newConfig}) l.Debug("UpdateInstance started") defer l.Debug("UpdateInstance finished") @@ -2274,7 +2274,7 @@ func (b *lxdBackend) UpdateInstance(inst instance.Instance, newDesc string, newC // UpdateInstanceSnapshot updates an instance snapshot volume's description. // Volume config is not allowed to be updated and will return an error. -func (b *lxdBackend) UpdateInstanceSnapshot(inst instance.Instance, newDesc string, newConfig map[string]string, op *operations.Operation) error { +func (b *backend) UpdateInstanceSnapshot(inst instance.Instance, newDesc string, newConfig map[string]string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "newDesc": newDesc, "newConfig": newConfig}) l.Debug("UpdateInstanceSnapshot started") defer l.Debug("UpdateInstanceSnapshot finished") @@ -2294,7 +2294,7 @@ func (b *lxdBackend) UpdateInstanceSnapshot(inst instance.Instance, newDesc stri // MigrateInstance sends an instance volume for migration. // The args.Name field is ignored and the name of the instance is used instead. -func (b *lxdBackend) MigrateInstance(inst instance.Instance, conn io.ReadWriteCloser, args *migration.VolumeSourceArgs, op *operations.Operation) error { +func (b *backend) MigrateInstance(inst instance.Instance, conn io.ReadWriteCloser, args *migration.VolumeSourceArgs, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "args": fmt.Sprintf("%+v", args)}) l.Debug("MigrateInstance started") defer l.Debug("MigrateInstance finished") @@ -2382,7 +2382,7 @@ func (b *lxdBackend) MigrateInstance(inst instance.Instance, conn io.ReadWriteCl } // CleanupInstancePaths removes any remaining mount paths and symlinks for the instance and its snapshots. -func (b *lxdBackend) CleanupInstancePaths(inst instance.Instance, op *operations.Operation) error { +func (b *backend) CleanupInstancePaths(inst instance.Instance, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("CleanupInstancePaths started") defer l.Debug("CleanupInstancePaths finished") @@ -2456,7 +2456,7 @@ func (b *lxdBackend) CleanupInstancePaths(inst instance.Instance, op *operations } // BackupInstance creates an instance backup. -func (b *lxdBackend) BackupInstance(inst instance.Instance, tarWriter *instancewriter.InstanceTarWriter, optimized bool, snapshots bool, op *operations.Operation) error { +func (b *backend) BackupInstance(inst instance.Instance, tarWriter *instancewriter.InstanceTarWriter, optimized bool, snapshots bool, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "optimized": optimized, "snapshots": snapshots}) l.Debug("BackupInstance started") defer l.Debug("BackupInstance finished") @@ -2512,7 +2512,7 @@ func (b *lxdBackend) BackupInstance(inst instance.Instance, tarWriter *instancew } // GetInstanceUsage returns the disk usage of the instance's root volume. -func (b *lxdBackend) GetInstanceUsage(inst instance.Instance) (*VolumeUsage, error) { +func (b *backend) GetInstanceUsage(inst instance.Instance) (*VolumeUsage, error) { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("GetInstanceUsage started") defer l.Debug("GetInstanceUsage finished") @@ -2565,7 +2565,7 @@ func (b *lxdBackend) GetInstanceUsage(inst instance.Instance) (*VolumeUsage, err // SetInstanceQuota sets the quota on the instance's root volume. // Returns ErrInUse if the instance is running and the storage driver doesn't support online resizing. -func (b *lxdBackend) SetInstanceQuota(inst instance.Instance, size string, vmStateSize string, op *operations.Operation) error { +func (b *backend) SetInstanceQuota(inst instance.Instance, size string, vmStateSize string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "size": size, "vm_state_size": vmStateSize}) l.Debug("SetInstanceQuota started") defer l.Debug("SetInstanceQuota finished") @@ -2614,7 +2614,7 @@ func (b *lxdBackend) SetInstanceQuota(inst instance.Instance, size string, vmSta } // MountInstance mounts the instance's root volume. -func (b *lxdBackend) MountInstance(inst instance.Instance, op *operations.Operation) (*MountInfo, error) { +func (b *backend) MountInstance(inst instance.Instance, op *operations.Operation) (*MountInfo, error) { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("MountInstance started") defer l.Debug("MountInstance finished") @@ -2678,7 +2678,7 @@ func (b *lxdBackend) MountInstance(inst instance.Instance, op *operations.Operat } // UnmountInstance unmounts the instance's root volume. -func (b *lxdBackend) UnmountInstance(inst instance.Instance, op *operations.Operation) error { +func (b *backend) UnmountInstance(inst instance.Instance, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("UnmountInstance started") defer l.Debug("UnmountInstance finished") @@ -2718,7 +2718,7 @@ func (b *lxdBackend) UnmountInstance(inst instance.Instance, op *operations.Oper } // getInstanceDisk returns the location of the disk. -func (b *lxdBackend) getInstanceDisk(inst instance.Instance) (string, error) { +func (b *backend) getInstanceDisk(inst instance.Instance) (string, error) { if inst.Type() != instancetype.VM { return "", drivers.ErrNotSupported } @@ -2747,7 +2747,7 @@ func (b *lxdBackend) getInstanceDisk(inst instance.Instance) (string, error) { } // CreateInstanceSnapshot creates a snaphot of an instance volume. -func (b *lxdBackend) CreateInstanceSnapshot(inst instance.Instance, src instance.Instance, op *operations.Operation) error { +func (b *backend) CreateInstanceSnapshot(inst instance.Instance, src instance.Instance, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "src": src.Name()}) l.Debug("CreateInstanceSnapshot started") defer l.Debug("CreateInstanceSnapshot finished") @@ -2829,7 +2829,7 @@ func (b *lxdBackend) CreateInstanceSnapshot(inst instance.Instance, src instance } // RenameInstanceSnapshot renames an instance snapshot. -func (b *lxdBackend) RenameInstanceSnapshot(inst instance.Instance, newName string, op *operations.Operation) error { +func (b *backend) RenameInstanceSnapshot(inst instance.Instance, newName string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "newName": newName}) l.Debug("RenameInstanceSnapshot started") defer l.Debug("RenameInstanceSnapshot finished") @@ -2901,7 +2901,7 @@ func (b *lxdBackend) RenameInstanceSnapshot(inst instance.Instance, newName stri } // DeleteInstanceSnapshot removes the snapshot volume for the supplied snapshot instance. -func (b *lxdBackend) DeleteInstanceSnapshot(inst instance.Instance, op *operations.Operation) error { +func (b *backend) DeleteInstanceSnapshot(inst instance.Instance, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("DeleteInstanceSnapshot started") defer l.Debug("DeleteInstanceSnapshot finished") @@ -2959,7 +2959,7 @@ func (b *lxdBackend) DeleteInstanceSnapshot(inst instance.Instance, op *operatio } // RestoreInstanceSnapshot restores an instance snapshot. -func (b *lxdBackend) RestoreInstanceSnapshot(inst instance.Instance, src instance.Instance, op *operations.Operation) error { +func (b *backend) RestoreInstanceSnapshot(inst instance.Instance, src instance.Instance, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name(), "src": src.Name()}) l.Debug("RestoreInstanceSnapshot started") defer l.Debug("RestoreInstanceSnapshot finished") @@ -3076,7 +3076,7 @@ func (b *lxdBackend) RestoreInstanceSnapshot(inst instance.Instance, src instanc // MountInstanceSnapshot mounts an instance snapshot. It is mounted as read only so that the // snapshot cannot be modified. -func (b *lxdBackend) MountInstanceSnapshot(inst instance.Instance, op *operations.Operation) (*MountInfo, error) { +func (b *backend) MountInstanceSnapshot(inst instance.Instance, op *operations.Operation) (*MountInfo, error) { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("MountInstanceSnapshot started") defer l.Debug("MountInstanceSnapshot finished") @@ -3125,7 +3125,7 @@ func (b *lxdBackend) MountInstanceSnapshot(inst instance.Instance, op *operation } // UnmountInstanceSnapshot unmounts an instance snapshot. -func (b *lxdBackend) UnmountInstanceSnapshot(inst instance.Instance, op *operations.Operation) error { +func (b *backend) UnmountInstanceSnapshot(inst instance.Instance, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("UnmountInstanceSnapshot started") defer l.Debug("UnmountInstanceSnapshot finished") @@ -3162,7 +3162,7 @@ func (b *lxdBackend) UnmountInstanceSnapshot(inst instance.Instance, op *operati } // poolBlockFilesystem returns the filesystem used for new block device filesystems. -func (b *lxdBackend) poolBlockFilesystem() string { +func (b *backend) poolBlockFilesystem() string { if b.db.Config["volume.block.filesystem"] != "" { return b.db.Config["volume.block.filesystem"] } @@ -3174,7 +3174,7 @@ func (b *lxdBackend) poolBlockFilesystem() string { // doesn't already exist. If the volume already exists then it is checked to ensure it matches the pools current // volume settings ("volume.size" and "block.filesystem" if applicable). If not the optimized volume is removed // and regenerated to apply the pool's current volume settings. -func (b *lxdBackend) EnsureImage(fingerprint string, op *operations.Operation) error { +func (b *backend) EnsureImage(fingerprint string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"fingerprint": fingerprint}) l.Debug("EnsureImage started") defer l.Debug("EnsureImage finished") @@ -3344,7 +3344,7 @@ func (b *lxdBackend) EnsureImage(fingerprint string, op *operations.Operation) e } // DeleteImage removes an image from the database and underlying storage device if needed. -func (b *lxdBackend) DeleteImage(fingerprint string, op *operations.Operation) error { +func (b *backend) DeleteImage(fingerprint string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"fingerprint": fingerprint}) l.Debug("DeleteImage started") defer l.Debug("DeleteImage finished") @@ -3397,7 +3397,7 @@ func (b *lxdBackend) DeleteImage(fingerprint string, op *operations.Operation) e // updateVolumeDescriptionOnly is a helper function used when handling update requests for volumes // that only allow their descriptions to be updated. If any config supplied differs from the // current volume's config then an error is returned. -func (b *lxdBackend) updateVolumeDescriptionOnly(projectName string, volName string, volType drivers.VolumeType, newDesc string, newConfig map[string]string, op *operations.Operation) error { +func (b *backend) updateVolumeDescriptionOnly(projectName string, volName string, volType drivers.VolumeType, newDesc string, newConfig map[string]string, op *operations.Operation) error { volDBType, err := VolumeTypeToDBType(volType) if err != nil { return err @@ -3448,7 +3448,7 @@ func (b *lxdBackend) updateVolumeDescriptionOnly(projectName string, volName str } // UpdateImage updates image config. -func (b *lxdBackend) UpdateImage(fingerprint, newDesc string, newConfig map[string]string, op *operations.Operation) error { +func (b *backend) UpdateImage(fingerprint, newDesc string, newConfig map[string]string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"fingerprint": fingerprint, "newDesc": newDesc, "newConfig": newConfig}) l.Debug("UpdateImage started") defer l.Debug("UpdateImage finished") @@ -3457,7 +3457,7 @@ func (b *lxdBackend) UpdateImage(fingerprint, newDesc string, newConfig map[stri } // CreateBucket creates an object bucket. -func (b *lxdBackend) CreateBucket(projectName string, bucket api.StorageBucketsPost, op *operations.Operation) error { +func (b *backend) CreateBucket(projectName string, bucket api.StorageBucketsPost, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "bucketName": bucket.Name, "desc": bucket.Description, "config": bucket.Config}) l.Debug("CreateBucket started") defer l.Debug("CreateBucket finished") @@ -3541,7 +3541,7 @@ func (b *lxdBackend) CreateBucket(projectName string, bucket api.StorageBucketsP } // UpdateBucket updates an object bucket. -func (b *lxdBackend) UpdateBucket(projectName string, bucketName string, bucket api.StorageBucketPut, op *operations.Operation) error { +func (b *backend) UpdateBucket(projectName string, bucketName string, bucket api.StorageBucketPut, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "bucketName": bucketName, "desc": bucket.Description, "config": bucket.Config}) l.Debug("UpdateBucket started") defer l.Debug("UpdateBucket finished") @@ -3638,7 +3638,7 @@ func (b *lxdBackend) UpdateBucket(projectName string, bucketName string, bucket } // DeleteBucket deletes an object bucket. -func (b *lxdBackend) DeleteBucket(projectName string, bucketName string, op *operations.Operation) error { +func (b *backend) DeleteBucket(projectName string, bucketName string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "bucketName": bucketName}) l.Debug("DeleteBucket started") defer l.Debug("DeleteBucket finished") @@ -3702,7 +3702,7 @@ func (b *lxdBackend) DeleteBucket(projectName string, bucketName string, op *ope // ImportBucket takes an existing bucket on the storage backend and ensures that the DB records // are restored as needed to make it operational with LXD. // Used during the recovery import stage. -func (b *lxdBackend) ImportBucket(projectName string, poolVol *backupConfig.Config, op *operations.Operation) (revert.Hook, error) { +func (b *backend) ImportBucket(projectName string, poolVol *backupConfig.Config, op *operations.Operation) (revert.Hook, error) { if poolVol.Bucket == nil { return nil, fmt.Errorf("Invalid pool bucket config supplied") } @@ -3772,7 +3772,7 @@ func (b *lxdBackend) ImportBucket(projectName string, poolVol *backupConfig.Conf } // recoverMinIOKeys retrieves existing bucket keys from MinIO for each service account associated with the given bucket. -func (b *lxdBackend) recoverMinIOKeys(projectName string, bucketName string, op *operations.Operation) ([]api.StorageBucketKeysPost, error) { +func (b *backend) recoverMinIOKeys(projectName string, bucketName string, op *operations.Operation) ([]api.StorageBucketKeysPost, error) { // Start minio process. minioProc, err := b.ActivateBucket(projectName, bucketName, op) if err != nil { @@ -3865,7 +3865,7 @@ func (b *lxdBackend) recoverMinIOKeys(projectName string, bucketName string, op } // CreateBucketKey creates an object bucket key. -func (b *lxdBackend) CreateBucketKey(projectName string, bucketName string, key api.StorageBucketKeysPost, op *operations.Operation) (*api.StorageBucketKey, error) { +func (b *backend) CreateBucketKey(projectName string, bucketName string, key api.StorageBucketKeysPost, op *operations.Operation) (*api.StorageBucketKey, error) { l := b.logger.AddContext(logger.Ctx{"project": projectName, "bucketName": bucketName, "keyName": key.Name, "desc": key.Description, "role": key.Role}) l.Debug("CreateBucketKey started") defer l.Debug("CreateBucketKey finished") @@ -3980,7 +3980,7 @@ func (b *lxdBackend) CreateBucketKey(projectName string, bucketName string, key return &newKey, err } -func (b *lxdBackend) UpdateBucketKey(projectName string, bucketName string, keyName string, key api.StorageBucketKeyPut, op *operations.Operation) error { +func (b *backend) UpdateBucketKey(projectName string, bucketName string, keyName string, key api.StorageBucketKeyPut, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "bucketName": bucketName, "keyName": keyName, "desc": key.Description, "role": key.Role}) l.Debug("UpdateBucketKey started") defer l.Debug("UpdateBucketKey finished") @@ -4123,7 +4123,7 @@ func (b *lxdBackend) UpdateBucketKey(projectName string, bucketName string, keyN } // DeleteBucketKey deletes an object bucket key. -func (b *lxdBackend) DeleteBucketKey(projectName string, bucketName string, keyName string, op *operations.Operation) error { +func (b *backend) DeleteBucketKey(projectName string, bucketName string, keyName string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "bucketName": bucketName, "keyName": keyName}) l.Debug("DeleteBucketKey started") defer l.Debug("DeleteBucketKey finished") @@ -4201,7 +4201,7 @@ func (b *lxdBackend) DeleteBucketKey(projectName string, bucketName string, keyN } // ActivateBucket mounts the local bucket volume and returns the MinIO S3 process for it. -func (b *lxdBackend) ActivateBucket(projectName string, bucketName string, op *operations.Operation) (*miniod.Process, error) { +func (b *backend) ActivateBucket(projectName string, bucketName string, op *operations.Operation) (*miniod.Process, error) { if !b.Driver().Info().Buckets { return nil, fmt.Errorf("Storage pool does not support buckets") } @@ -4217,7 +4217,7 @@ func (b *lxdBackend) ActivateBucket(projectName string, bucketName string, op *o } // GetBucketURL returns S3 URL for bucket. -func (b *lxdBackend) GetBucketURL(bucketName string) *url.URL { +func (b *backend) GetBucketURL(bucketName string) *url.URL { err := b.isStatusReady() if err != nil { return nil @@ -4246,7 +4246,7 @@ func (b *lxdBackend) GetBucketURL(bucketName string) *url.URL { } // CreateCustomVolume creates an empty custom volume. -func (b *lxdBackend) CreateCustomVolume(projectName string, volName string, desc string, config map[string]string, contentType drivers.ContentType, op *operations.Operation) error { +func (b *backend) CreateCustomVolume(projectName string, volName string, desc string, config map[string]string, contentType drivers.ContentType, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": volName, "desc": desc, "config": config, "contentType": contentType}) l.Debug("CreateCustomVolume started") defer l.Debug("CreateCustomVolume finished") @@ -4308,7 +4308,7 @@ func (b *lxdBackend) CreateCustomVolume(projectName string, volName string, desc // CreateCustomVolumeFromCopy creates a custom volume from an existing custom volume. // It copies the snapshots from the source volume by default, but can be disabled if requested. -func (b *lxdBackend) CreateCustomVolumeFromCopy(projectName string, srcProjectName string, volName string, desc string, config map[string]string, srcPoolName, srcVolName string, snapshots bool, op *operations.Operation) error { +func (b *backend) CreateCustomVolumeFromCopy(projectName string, srcProjectName string, volName string, desc string, config map[string]string, srcPoolName, srcVolName string, snapshots bool, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "srcProjectName": srcProjectName, "volName": volName, "desc": desc, "config": config, "srcPoolName": srcPoolName, "srcVolName": srcVolName, "snapshots": snapshots}) l.Debug("CreateCustomVolumeFromCopy started") defer l.Debug("CreateCustomVolumeFromCopy finished") @@ -4458,9 +4458,9 @@ func (b *lxdBackend) CreateCustomVolumeFromCopy(projectName string, srcProjectNa if drivers.IsContentBlock(contentType) { err = srcVol.MountTask(func(mountPath string, op *operations.Operation) error { - srcPoolBackend, ok := srcPool.(*lxdBackend) + srcPoolBackend, ok := srcPool.(*backend) if !ok { - return fmt.Errorf("Pool is not a lxdBackend") + return fmt.Errorf("Pool is not a backend") } volDiskPath, err := srcPoolBackend.driver.GetVolumeDiskPath(srcVol) @@ -4552,7 +4552,7 @@ func (b *lxdBackend) CreateCustomVolumeFromCopy(projectName string, srcProjectNa } // migrationIndexHeaderSend sends the migration index header to target and waits for confirmation of receipt. -func (b *lxdBackend) migrationIndexHeaderSend(l logger.Logger, indexHeaderVersion uint32, conn io.ReadWriteCloser, info *migration.Info) (*migration.InfoResponse, error) { +func (b *backend) migrationIndexHeaderSend(l logger.Logger, indexHeaderVersion uint32, conn io.ReadWriteCloser, info *migration.Info) (*migration.InfoResponse, error) { infoResp := migration.InfoResponse{} // Send migration index header frame to target if applicable and wait for receipt. @@ -4596,7 +4596,7 @@ func (b *lxdBackend) migrationIndexHeaderSend(l logger.Logger, indexHeaderVersio // migrationIndexHeaderReceive receives migration index header from source and sends confirmation of receipt. // Returns the received source index header info. -func (b *lxdBackend) migrationIndexHeaderReceive(l logger.Logger, indexHeaderVersion uint32, conn io.ReadWriteCloser, refresh bool) (*migration.Info, error) { +func (b *backend) migrationIndexHeaderReceive(l logger.Logger, indexHeaderVersion uint32, conn io.ReadWriteCloser, refresh bool) (*migration.Info, error) { info := migration.Info{} // Receive index header from source if applicable and respond confirming receipt. @@ -4638,7 +4638,7 @@ func (b *lxdBackend) migrationIndexHeaderReceive(l logger.Logger, indexHeaderVer } // MigrateCustomVolume sends a volume for migration. -func (b *lxdBackend) MigrateCustomVolume(projectName string, conn io.ReadWriteCloser, args *migration.VolumeSourceArgs, op *operations.Operation) error { +func (b *backend) MigrateCustomVolume(projectName string, conn io.ReadWriteCloser, args *migration.VolumeSourceArgs, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": args.Name, "args": fmt.Sprintf("%+v", args)}) l.Debug("MigrateCustomVolume started") defer l.Debug("MigrateCustomVolume finished") @@ -4688,7 +4688,7 @@ func (b *lxdBackend) MigrateCustomVolume(projectName string, conn io.ReadWriteCl } // CreateCustomVolumeFromMigration receives a volume being migrated. -func (b *lxdBackend) CreateCustomVolumeFromMigration(projectName string, conn io.ReadWriteCloser, args migration.VolumeTargetArgs, op *operations.Operation) error { +func (b *backend) CreateCustomVolumeFromMigration(projectName string, conn io.ReadWriteCloser, args migration.VolumeTargetArgs, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": args.Name, "args": fmt.Sprintf("%+v", args)}) l.Debug("CreateCustomVolumeFromMigration started") defer l.Debug("CreateCustomVolumeFromMigration finished") @@ -4838,7 +4838,7 @@ func (b *lxdBackend) CreateCustomVolumeFromMigration(projectName string, conn io } // RenameCustomVolume renames a custom volume and its snapshots. -func (b *lxdBackend) RenameCustomVolume(projectName string, volName string, newVolName string, op *operations.Operation) error { +func (b *backend) RenameCustomVolume(projectName string, volName string, newVolName string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": volName, "newVolName": newVolName}) l.Debug("RenameCustomVolume started") defer l.Debug("RenameCustomVolume finished") @@ -4929,7 +4929,7 @@ func (b *lxdBackend) RenameCustomVolume(projectName string, volName string, newV // detectChangedConfig returns the config that has changed between current and new config maps. // Also returns a boolean indicating whether all of the changed keys start with "user.". // Deleted keys will be returned as having an empty string value. -func (b *lxdBackend) detectChangedConfig(curConfig, newConfig map[string]string) (map[string]string, bool) { +func (b *backend) detectChangedConfig(curConfig, newConfig map[string]string) (map[string]string, bool) { // Diff the configurations. changedConfig := make(map[string]string) userOnly := true @@ -4957,7 +4957,7 @@ func (b *lxdBackend) detectChangedConfig(curConfig, newConfig map[string]string) } // UpdateCustomVolume applies the supplied config to the custom volume. -func (b *lxdBackend) UpdateCustomVolume(projectName string, volName string, newDesc string, newConfig map[string]string, op *operations.Operation) error { +func (b *backend) UpdateCustomVolume(projectName string, volName string, newDesc string, newConfig map[string]string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": volName, "newDesc": newDesc, "newConfig": newConfig}) l.Debug("UpdateCustomVolume started") defer l.Debug("UpdateCustomVolume finished") @@ -5061,7 +5061,7 @@ func (b *lxdBackend) UpdateCustomVolume(projectName string, volName string, newD // UpdateCustomVolumeSnapshot updates the description of a custom volume snapshot. // Volume config is not allowed to be updated and will return an error. -func (b *lxdBackend) UpdateCustomVolumeSnapshot(projectName string, volName string, newDesc string, newConfig map[string]string, newExpiryDate time.Time, op *operations.Operation) error { +func (b *backend) UpdateCustomVolumeSnapshot(projectName string, volName string, newDesc string, newConfig map[string]string, newExpiryDate time.Time, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": volName, "newDesc": newDesc, "newConfig": newConfig, "newExpiryDate": newExpiryDate}) l.Debug("UpdateCustomVolumeSnapshot started") defer l.Debug("UpdateCustomVolumeSnapshot finished") @@ -5103,7 +5103,7 @@ func (b *lxdBackend) UpdateCustomVolumeSnapshot(projectName string, volName stri } // DeleteCustomVolume removes a custom volume and its snapshots. -func (b *lxdBackend) DeleteCustomVolume(projectName string, volName string, op *operations.Operation) error { +func (b *backend) DeleteCustomVolume(projectName string, volName string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": volName}) l.Debug("DeleteCustomVolume started") defer l.Debug("DeleteCustomVolume finished") @@ -5184,7 +5184,7 @@ func (b *lxdBackend) DeleteCustomVolume(projectName string, volName string, op * } // GetCustomVolumeDisk returns the location of the disk. -func (b *lxdBackend) GetCustomVolumeDisk(projectName, volName string) (string, error) { +func (b *backend) GetCustomVolumeDisk(projectName, volName string) (string, error) { volume, err := VolumeDBGet(b, projectName, volName, drivers.VolumeTypeCustom) if err != nil { return "", err @@ -5200,7 +5200,7 @@ func (b *lxdBackend) GetCustomVolumeDisk(projectName, volName string) (string, e } // GetCustomVolumeUsage returns the disk space used by the custom volume. -func (b *lxdBackend) GetCustomVolumeUsage(projectName, volName string) (*VolumeUsage, error) { +func (b *backend) GetCustomVolumeUsage(projectName, volName string) (*VolumeUsage, error) { err := b.isStatusReady() if err != nil { return nil, err @@ -5244,7 +5244,7 @@ func (b *lxdBackend) GetCustomVolumeUsage(projectName, volName string) (*VolumeU } // MountCustomVolume mounts a custom volume. -func (b *lxdBackend) MountCustomVolume(projectName, volName string, op *operations.Operation) error { +func (b *backend) MountCustomVolume(projectName, volName string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": volName}) l.Debug("MountCustomVolume started") defer l.Debug("MountCustomVolume finished") @@ -5267,7 +5267,7 @@ func (b *lxdBackend) MountCustomVolume(projectName, volName string, op *operatio } // UnmountCustomVolume unmounts a custom volume. -func (b *lxdBackend) UnmountCustomVolume(projectName, volName string, op *operations.Operation) (bool, error) { +func (b *backend) UnmountCustomVolume(projectName, volName string, op *operations.Operation) (bool, error) { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": volName}) l.Debug("UnmountCustomVolume started") defer l.Debug("UnmountCustomVolume finished") @@ -5287,7 +5287,7 @@ func (b *lxdBackend) UnmountCustomVolume(projectName, volName string, op *operat // ImportCustomVolume takes an existing custom volume on the storage backend and ensures that the DB records, // volume directories and symlinks are restored as needed to make it operational with LXD. // Used during the recovery import stage. -func (b *lxdBackend) ImportCustomVolume(projectName string, poolVol *backupConfig.Config, op *operations.Operation) (revert.Hook, error) { +func (b *backend) ImportCustomVolume(projectName string, poolVol *backupConfig.Config, op *operations.Operation) (revert.Hook, error) { if poolVol.Volume == nil { return nil, fmt.Errorf("Invalid pool volume config supplied") } @@ -5364,7 +5364,7 @@ func (b *lxdBackend) ImportCustomVolume(projectName string, poolVol *backupConfi } // CreateCustomVolumeSnapshot creates a snapshot of a custom volume. -func (b *lxdBackend) CreateCustomVolumeSnapshot(projectName, volName string, newSnapshotName string, newExpiryDate time.Time, op *operations.Operation) error { +func (b *backend) CreateCustomVolumeSnapshot(projectName, volName string, newSnapshotName string, newExpiryDate time.Time, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": volName, "newSnapshotName": newSnapshotName, "newExpiryDate": newExpiryDate}) l.Debug("CreateCustomVolumeSnapshot started") defer l.Debug("CreateCustomVolumeSnapshot finished") @@ -5445,7 +5445,7 @@ func (b *lxdBackend) CreateCustomVolumeSnapshot(projectName, volName string, new } // RenameCustomVolumeSnapshot renames a custom volume. -func (b *lxdBackend) RenameCustomVolumeSnapshot(projectName, volName string, newSnapshotName string, op *operations.Operation) error { +func (b *backend) RenameCustomVolumeSnapshot(projectName, volName string, newSnapshotName string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": volName, "newSnapshotName": newSnapshotName}) l.Debug("RenameCustomVolumeSnapshot started") defer l.Debug("RenameCustomVolumeSnapshot finished") @@ -5493,7 +5493,7 @@ func (b *lxdBackend) RenameCustomVolumeSnapshot(projectName, volName string, new } // DeleteCustomVolumeSnapshot removes a custom volume snapshot. -func (b *lxdBackend) DeleteCustomVolumeSnapshot(projectName, volName string, op *operations.Operation) error { +func (b *backend) DeleteCustomVolumeSnapshot(projectName, volName string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": volName}) l.Debug("DeleteCustomVolumeSnapshot started") defer l.Debug("DeleteCustomVolumeSnapshot finished") @@ -5553,7 +5553,7 @@ func (b *lxdBackend) DeleteCustomVolumeSnapshot(projectName, volName string, op } // RestoreCustomVolume restores a custom volume from a snapshot. -func (b *lxdBackend) RestoreCustomVolume(projectName, volName string, snapshotName string, op *operations.Operation) error { +func (b *backend) RestoreCustomVolume(projectName, volName string, snapshotName string, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volName": volName, "snapshotName": snapshotName}) l.Debug("RestoreCustomVolume started") defer l.Debug("RestoreCustomVolume finished") @@ -5631,7 +5631,7 @@ func (b *lxdBackend) RestoreCustomVolume(projectName, volName string, snapshotNa return nil } -func (b *lxdBackend) createStorageStructure(path string) error { +func (b *backend) createStorageStructure(path string) error { for _, volType := range b.driver.Info().VolumeTypes { for _, name := range drivers.BaseDirectories[volType] { path := filepath.Join(path, name) @@ -5646,7 +5646,7 @@ func (b *lxdBackend) createStorageStructure(path string) error { } // GenerateCustomVolumeBackupConfig returns the backup config entry for this volume. -func (b *lxdBackend) GenerateCustomVolumeBackupConfig(projectName string, volName string, snapshots bool, op *operations.Operation) (*backupConfig.Config, error) { +func (b *backend) GenerateCustomVolumeBackupConfig(projectName string, volName string, snapshots bool, op *operations.Operation) (*backupConfig.Config, error) { vol, err := VolumeDBGet(b, projectName, volName, drivers.VolumeTypeCustom) if err != nil { return nil, err @@ -5689,7 +5689,7 @@ func (b *lxdBackend) GenerateCustomVolumeBackupConfig(projectName string, volNam // GenerateInstanceBackupConfig returns the backup config entry for this instance. // The Container field is only populated for non-snapshot instances. -func (b *lxdBackend) GenerateInstanceBackupConfig(inst instance.Instance, snapshots bool, op *operations.Operation) (*backupConfig.Config, error) { +func (b *backend) GenerateInstanceBackupConfig(inst instance.Instance, snapshots bool, op *operations.Operation) (*backupConfig.Config, error) { // Generate the YAML. ci, _, err := inst.Render() if err != nil { @@ -5781,7 +5781,7 @@ func (b *lxdBackend) GenerateInstanceBackupConfig(inst instance.Instance, snapsh } // UpdateInstanceBackupFile writes the instance's config to the backup.yaml file on the storage device. -func (b *lxdBackend) UpdateInstanceBackupFile(inst instance.Instance, op *operations.Operation) error { +func (b *backend) UpdateInstanceBackupFile(inst instance.Instance, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("UpdateInstanceBackupFile started") defer l.Debug("UpdateInstanceBackupFile finished") @@ -5847,7 +5847,7 @@ func (b *lxdBackend) UpdateInstanceBackupFile(inst instance.Instance, op *operat // config are removed from the storage device, and any snapshots that exist in the backup config but do not exist // on the storage device are ignored. The remaining set of snapshots that exist on both the storage device and the // backup config are returned. They set can be used to re-create the snapshot database entries when importing. -func (b *lxdBackend) CheckInstanceBackupFileSnapshots(backupConf *backupConfig.Config, projectName string, deleteMissing bool, op *operations.Operation) ([]*api.InstanceSnapshot, error) { +func (b *backend) CheckInstanceBackupFileSnapshots(backupConf *backupConfig.Config, projectName string, deleteMissing bool, op *operations.Operation) ([]*api.InstanceSnapshot, error) { l := b.logger.AddContext(logger.Ctx{"project": projectName, "instance": backupConf.Container.Name, "deleteMissing": deleteMissing}) l.Debug("CheckInstanceBackupFileSnapshots started") defer l.Debug("CheckInstanceBackupFileSnapshots finished") @@ -5946,7 +5946,7 @@ func (b *lxdBackend) CheckInstanceBackupFileSnapshots(backupConf *backupConfig.C // ListUnknownVolumes returns volumes that exist on the storage pool but don't have records in the database. // Returns the unknown volumes parsed/generated backup config in a slice (keyed on project name). -func (b *lxdBackend) ListUnknownVolumes(op *operations.Operation) (map[string][]*backupConfig.Config, error) { +func (b *backend) ListUnknownVolumes(op *operations.Operation) (map[string][]*backupConfig.Config, error) { // Get a list of volumes on the storage pool. We only expect to get 1 volume per logical LXD volume. // So for VMs we only expect to get the block volume for a VM and not its filesystem one too. This way we // can operate on the volume using the existing storage pool functions and let the pool then handle the @@ -5990,7 +5990,7 @@ func (b *lxdBackend) ListUnknownVolumes(op *operations.Operation) (map[string][] // detectUnknownInstanceVolume detects if a volume is unknown and if so attempts to mount the volume and parse the // backup stored on it. It then runs a series of consistency checks that compare the contents of the backup file to // the state of the volume on disk, and if all checks out, it adds the parsed backup file contents to projectVols. -func (b *lxdBackend) detectUnknownInstanceVolume(vol *drivers.Volume, projectVols map[string][]*backupConfig.Config, op *operations.Operation) error { +func (b *backend) detectUnknownInstanceVolume(vol *drivers.Volume, projectVols map[string][]*backupConfig.Config, op *operations.Operation) error { volType := vol.Type() projectName, instName := project.InstanceParts(vol.Name()) @@ -6136,7 +6136,7 @@ func (b *lxdBackend) detectUnknownInstanceVolume(vol *drivers.Volume, projectVol // detectUnknownCustomVolume detects if a volume is unknown and if so attempts to discover the filesystem of the // volume (for filesystem volumes). It then runs a series of consistency checks, and if all checks out, it adds // generates a simulated backup config for the custom volume and adds it to projectVols. -func (b *lxdBackend) detectUnknownCustomVolume(vol *drivers.Volume, projectVols map[string][]*backupConfig.Config, op *operations.Operation) error { +func (b *backend) detectUnknownCustomVolume(vol *drivers.Volume, projectVols map[string][]*backupConfig.Config, op *operations.Operation) error { volType := vol.Type() projectName, volName := project.StorageVolumeParts(vol.Name()) @@ -6242,7 +6242,7 @@ func (b *lxdBackend) detectUnknownCustomVolume(vol *drivers.Volume, projectVols // detectUnknownBuckets detects if a bucket is unknown and if so attempts to discover the filesystem of the // bucket. It then runs a series of consistency checks, and if all checks out, it generates a simulated backup // config for the bucket and adds it to projectVols. -func (b *lxdBackend) detectUnknownBuckets(vol *drivers.Volume, projectVols map[string][]*backupConfig.Config, op *operations.Operation) error { +func (b *backend) detectUnknownBuckets(vol *drivers.Volume, projectVols map[string][]*backupConfig.Config, op *operations.Operation) error { projectName, bucketName := project.StorageVolumeParts(vol.Name()) // Check if any entry for the bucket already exists in the DB. @@ -6289,7 +6289,7 @@ func (b *lxdBackend) detectUnknownBuckets(vol *drivers.Volume, projectVols map[s // and symlinks are restored as needed to make it operational with LXD. Used during the recovery import stage. // If the instance exists on the local cluster member then the local mount status is restored as needed. // If the optional poolVol argument is provided then it is used to create the storage volume database records. -func (b *lxdBackend) ImportInstance(inst instance.Instance, poolVol *backupConfig.Config, op *operations.Operation) (revert.Hook, error) { +func (b *backend) ImportInstance(inst instance.Instance, poolVol *backupConfig.Config, op *operations.Operation) (revert.Hook, error) { l := b.logger.AddContext(logger.Ctx{"project": inst.Project().Name, "instance": inst.Name()}) l.Debug("ImportInstance started") defer l.Debug("ImportInstance finished") @@ -6457,7 +6457,7 @@ func (b *lxdBackend) ImportInstance(inst instance.Instance, poolVol *backupConfi return cleanup, err } -func (b *lxdBackend) BackupCustomVolume(projectName string, volName string, tarWriter *instancewriter.InstanceTarWriter, optimized bool, snapshots bool, op *operations.Operation) error { +func (b *backend) BackupCustomVolume(projectName string, volName string, tarWriter *instancewriter.InstanceTarWriter, optimized bool, snapshots bool, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volume": volName, "optimized": optimized, "snapshots": snapshots}) l.Debug("BackupCustomVolume started") defer l.Debug("BackupCustomVolume finished") @@ -6509,7 +6509,7 @@ func (b *lxdBackend) BackupCustomVolume(projectName string, volName string, tarW return nil } -func (b *lxdBackend) CreateCustomVolumeFromISO(projectName string, volName string, srcData io.ReadSeeker, size int64, op *operations.Operation) error { +func (b *backend) CreateCustomVolumeFromISO(projectName string, volName string, srcData io.ReadSeeker, size int64, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": projectName, "volume": volName}) l.Debug("CreateCustomVolumeFromISO started") defer l.Debug("CreateCustomVolumeFromISO finished") @@ -6581,7 +6581,7 @@ func (b *lxdBackend) CreateCustomVolumeFromISO(projectName string, volName strin return nil } -func (b *lxdBackend) CreateCustomVolumeFromBackup(srcBackup backup.Info, srcData io.ReadSeeker, op *operations.Operation) error { +func (b *backend) CreateCustomVolumeFromBackup(srcBackup backup.Info, srcData io.ReadSeeker, op *operations.Operation) error { l := b.logger.AddContext(logger.Ctx{"project": srcBackup.Project, "volume": srcBackup.Name, "snapshots": srcBackup.Snapshots, "optimizedStorage": *srcBackup.OptimizedStorage}) l.Debug("CreateCustomVolumeFromBackup started") defer l.Debug("CreateCustomVolumeFromBackup finished") diff --git a/incusd/storage/backend_incus_patches.go b/incusd/storage/backend_patches.go similarity index 95% rename from incusd/storage/backend_incus_patches.go rename to incusd/storage/backend_patches.go index 7d0a23c4756..0374a936bd5 100644 --- a/incusd/storage/backend_incus_patches.go +++ b/incusd/storage/backend_patches.go @@ -16,13 +16,13 @@ import ( "github.com/lxc/incus/shared/logger" ) -var lxdEarlyPatches = map[string]func(b *lxdBackend) error{ +var earlyPatches = map[string]func(b *backend) error{ "storage_missing_snapshot_records": patchMissingSnapshotRecords, "storage_delete_old_snapshot_records": patchDeleteOldSnapshotRecords, "storage_prefix_bucket_names_with_project": patchBucketNames, } -var lxdLatePatches = map[string]func(b *lxdBackend) error{} +var latePatches = map[string]func(b *backend) error{} // Patches start here. @@ -30,7 +30,7 @@ var lxdLatePatches = map[string]func(b *lxdBackend) error{} // This is needed because it seems that in 2019 some instance snapshots did not have their associated volume DB // records created. This later caused problems when we started validating that the instance snapshot DB record // count matched the volume snapshot DB record count. -func patchMissingSnapshotRecords(b *lxdBackend) error { +func patchMissingSnapshotRecords(b *backend) error { var err error var localNode string @@ -131,7 +131,7 @@ func patchMissingSnapshotRecords(b *lxdBackend) error { // patchDeleteOldSnapshotRecords deletes the remaining snapshot records in storage_volumes // (a previous patch would have already moved them into storage_volume_snapshots). -func patchDeleteOldSnapshotRecords(b *lxdBackend) error { +func patchDeleteOldSnapshotRecords(b *backend) error { err := b.state.DB.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error { nodeID := tx.GetNodeID() _, err := tx.Tx().Exec(` @@ -161,7 +161,7 @@ DELETE FROM storage_volumes WHERE id IN ( // patchBucketNames modifies the naming convention of bucket volumes by adding // the corresponding project name as a prefix. -func patchBucketNames(b *lxdBackend) error { +func patchBucketNames(b *backend) error { // Apply patch only for btrfs, dir, lvm, and zfs drivers. if !shared.StringInSlice(b.driver.Info().Name, []string{"btrfs", "dir", "lvm", "zfs"}) { return nil diff --git a/incusd/storage/pool_load.go b/incusd/storage/pool_load.go index cb8f34b1ba3..25afb238a1d 100644 --- a/incusd/storage/pool_load.go +++ b/incusd/storage/pool_load.go @@ -102,7 +102,7 @@ func NewTemporary(state *state.State, info *api.StoragePool) (Pool, error) { } // Setup the pool struct. - pool := lxdBackend{} + pool := backend{} pool.driver = driver pool.id = poolID pool.db = *info @@ -124,7 +124,7 @@ func LoadByType(state *state.State, driverType string) (Type, error) { } // Setup the pool struct. - pool := lxdBackend{} + pool := backend{} pool.state = state pool.driver = driver pool.id = PoolIDTemporary @@ -150,7 +150,7 @@ func LoadByRecord(s *state.State, poolID int64, poolInfo api.StoragePool, poolMe } // Setup the pool struct. - pool := lxdBackend{} + pool := backend{} pool.driver = driver pool.id = poolID pool.db = poolInfo diff --git a/incusd/storage/utils.go b/incusd/storage/utils.go index 97349b47829..3c5a114213e 100644 --- a/incusd/storage/utils.go +++ b/incusd/storage/utils.go @@ -186,9 +186,9 @@ func VolumeContentTypeNameToContentType(contentTypeName string) (int, error) { // VolumeDBGet loads a volume from the database. func VolumeDBGet(pool Pool, projectName string, volumeName string, volumeType drivers.VolumeType) (*db.StorageVolume, error) { - p, ok := pool.(*lxdBackend) + p, ok := pool.(*backend) if !ok { - return nil, fmt.Errorf("Pool is not a lxdBackend") + return nil, fmt.Errorf("Pool is not a backend") } volDBType, err := VolumeTypeToDBType(volumeType) @@ -221,9 +221,9 @@ func VolumeDBGet(pool Pool, projectName string, volumeName string, volumeType dr // If volumeConfig is supplied, it is modified with any driver level default config options (if not set). // If removeUnknownKeys is true, any unknown config keys are removed from volumeConfig rather than failing. func VolumeDBCreate(pool Pool, projectName string, volumeName string, volumeDescription string, volumeType drivers.VolumeType, snapshot bool, volumeConfig map[string]string, creationDate time.Time, expiryDate time.Time, contentType drivers.ContentType, removeUnknownKeys bool, hasSource bool) error { - p, ok := pool.(*lxdBackend) + p, ok := pool.(*backend) if !ok { - return fmt.Errorf("Pool is not a lxdBackend") + return fmt.Errorf("Pool is not a backend") } // Prevent using this function to create storage volume bucket records. @@ -296,9 +296,9 @@ func VolumeDBCreate(pool Pool, projectName string, volumeName string, volumeDesc // VolumeDBDelete deletes a volume from the database. func VolumeDBDelete(pool Pool, projectName string, volumeName string, volumeType drivers.VolumeType) error { - p, ok := pool.(*lxdBackend) + p, ok := pool.(*backend) if !ok { - return fmt.Errorf("Pool is not a lxdBackend") + return fmt.Errorf("Pool is not a backend") } // Convert the volume type to our internal integer representation. @@ -317,9 +317,9 @@ func VolumeDBDelete(pool Pool, projectName string, volumeName string, volumeType // VolumeDBSnapshotsGet loads a list of snapshots volumes from the database. func VolumeDBSnapshotsGet(pool Pool, projectName string, volume string, volumeType drivers.VolumeType) ([]db.StorageVolumeArgs, error) { - p, ok := pool.(*lxdBackend) + p, ok := pool.(*backend) if !ok { - return nil, fmt.Errorf("Pool is not a lxdBackend") + return nil, fmt.Errorf("Pool is not a backend") } volDBType, err := VolumeTypeToDBType(volumeType) @@ -337,9 +337,9 @@ func VolumeDBSnapshotsGet(pool Pool, projectName string, volume string, volumeTy // BucketDBGet loads a bucket from the database. func BucketDBGet(pool Pool, projectName string, bucketName string, memberSpecific bool) (*db.StorageBucket, error) { - p, ok := pool.(*lxdBackend) + p, ok := pool.(*backend) if !ok { - return nil, fmt.Errorf("Pool is not a lxdBackend") + return nil, fmt.Errorf("Pool is not a backend") } var err error @@ -369,9 +369,9 @@ func BucketDBGet(pool Pool, projectName string, bucketName string, memberSpecifi // The supplied bucket's config may be modified with defaults for the storage pool being used. // Returns bucket DB record ID. func BucketDBCreate(ctx context.Context, pool Pool, projectName string, memberSpecific bool, bucket *api.StorageBucketsPost) (int64, error) { - p, ok := pool.(*lxdBackend) + p, ok := pool.(*backend) if !ok { - return -1, fmt.Errorf("Pool is not a lxdBackend") + return -1, fmt.Errorf("Pool is not a backend") } // Make sure that we don't pass a nil to the next function. @@ -411,9 +411,9 @@ func BucketDBCreate(ctx context.Context, pool Pool, projectName string, memberSp // BucketDBDelete deletes a bucket from the database. func BucketDBDelete(ctx context.Context, pool Pool, bucketID int64) error { - p, ok := pool.(*lxdBackend) + p, ok := pool.(*backend) if !ok { - return fmt.Errorf("Pool is not a lxdBackend") + return fmt.Errorf("Pool is not a backend") } err := p.state.DB.Cluster.DeleteStoragePoolBucket(ctx, p.ID(), bucketID) @@ -675,7 +675,7 @@ func ImageUnpack(imageFile string, vol drivers.Volume, destBlockFile string, blo } } else { // Dealing with unified tarballs require an initial unpack to a temporary directory. - tempDir, err := os.MkdirTemp(shared.VarPath("images"), "lxd_image_unpack_") + tempDir, err := os.MkdirTemp(shared.VarPath("images"), "incus_image_unpack_") if err != nil { return -1, err } From dfe7abf367901a587d39259b6d1a3c242ca8fe27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:26:08 -0400 Subject: [PATCH 03/14] incusd/storage: Remove all LXD mentions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- incusd/storage/backend.go | 12 ++++++------ incusd/storage/pool_interface.go | 4 ++-- incusd/storage/storage.go | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/incusd/storage/backend.go b/incusd/storage/backend.go index f613c763a4a..fc0e12d0751 100644 --- a/incusd/storage/backend.go +++ b/incusd/storage/backend.go @@ -3296,7 +3296,7 @@ func (b *backend) EnsureImage(fingerprint string, op *operations.Operation) erro } } else { // We have an unrecorded on-disk volume, assume it's a partial unpack and delete it. - // This can occur if LXD process exits unexpectedly during an image unpack or if the + // This can occur if Incus process exits unexpectedly during an image unpack or if the // storage pool has been recovered (which would not recreate the image volume DB records). l.Warn("Deleting leftover/partially unpacked image volume") err = b.driver.DeleteVolume(imgVol, op) @@ -3700,7 +3700,7 @@ func (b *backend) DeleteBucket(projectName string, bucketName string, op *operat } // ImportBucket takes an existing bucket on the storage backend and ensures that the DB records -// are restored as needed to make it operational with LXD. +// are restored as needed to make it operational with Incus. // Used during the recovery import stage. func (b *backend) ImportBucket(projectName string, poolVol *backupConfig.Config, op *operations.Operation) (revert.Hook, error) { if poolVol.Bucket == nil { @@ -5285,7 +5285,7 @@ func (b *backend) UnmountCustomVolume(projectName, volName string, op *operation } // ImportCustomVolume takes an existing custom volume on the storage backend and ensures that the DB records, -// volume directories and symlinks are restored as needed to make it operational with LXD. +// volume directories and symlinks are restored as needed to make it operational with Incus. // Used during the recovery import stage. func (b *backend) ImportCustomVolume(projectName string, poolVol *backupConfig.Config, op *operations.Operation) (revert.Hook, error) { if poolVol.Volume == nil { @@ -5947,7 +5947,7 @@ func (b *backend) CheckInstanceBackupFileSnapshots(backupConf *backupConfig.Conf // ListUnknownVolumes returns volumes that exist on the storage pool but don't have records in the database. // Returns the unknown volumes parsed/generated backup config in a slice (keyed on project name). func (b *backend) ListUnknownVolumes(op *operations.Operation) (map[string][]*backupConfig.Config, error) { - // Get a list of volumes on the storage pool. We only expect to get 1 volume per logical LXD volume. + // Get a list of volumes on the storage pool. We only expect to get 1 volume per logical Incus volume. // So for VMs we only expect to get the block volume for a VM and not its filesystem one too. This way we // can operate on the volume using the existing storage pool functions and let the pool then handle the // associated filesystem volume as needed. @@ -6286,7 +6286,7 @@ func (b *backend) detectUnknownBuckets(vol *drivers.Volume, projectVols map[stri } // ImportInstance takes an existing instance volume on the storage backend and ensures that the volume directories -// and symlinks are restored as needed to make it operational with LXD. Used during the recovery import stage. +// and symlinks are restored as needed to make it operational with Incus. Used during the recovery import stage. // If the instance exists on the local cluster member then the local mount status is restored as needed. // If the optional poolVol argument is provided then it is used to create the storage volume database records. func (b *backend) ImportInstance(inst instance.Instance, poolVol *backupConfig.Config, op *operations.Operation) (revert.Hook, error) { @@ -6397,7 +6397,7 @@ func (b *backend) ImportInstance(inst instance.Instance, poolVol *backupConfig.C l.Debug("Restoring local instance mount status") if inst.IsRunning() { - // If the instance is running then this implies the volume is mounted, but if the LXD + // If the instance is running then this implies the volume is mounted, but if the Incus // daemon has been restarted since the DB records were removed then there will be no mount // reference counter showing the volume is in use. If this is the case then call mount the // volume to increment the reference counter. diff --git a/incusd/storage/pool_interface.go b/incusd/storage/pool_interface.go index d2235c6cb46..2cb5ab7ad40 100644 --- a/incusd/storage/pool_interface.go +++ b/incusd/storage/pool_interface.go @@ -29,13 +29,13 @@ type MountInfo struct { DiskPath string // The location of the block disk (if supported). } -// Type represents a LXD storage pool type. +// Type represents an Incus storage pool type. type Type interface { ValidateName(name string) error Validate(config map[string]string) error } -// Pool represents a LXD storage pool. +// Pool represents an Incus storage pool. type Pool interface { Type diff --git a/incusd/storage/storage.go b/incusd/storage/storage.go index 80f329f8524..9ccc189e2af 100644 --- a/incusd/storage/storage.go +++ b/incusd/storage/storage.go @@ -35,8 +35,8 @@ func InstancePath(instanceType instancetype.Type, projectName, instanceName stri } // InstanceImportingFilePath returns the file path used to indicate an instance import is in progress. -// This marker file is created when using `lxd import` to import an instance that exists on the storage device -// but does not exist in the LXD database. The presence of this file causes the instance not to be removed from +// This marker file is created when using `incusd import` to import an instance that exists on the storage device +// but does not exist in the Incus database. The presence of this file causes the instance not to be removed from // the storage device if the import should fail for some reason. func InstanceImportingFilePath(instanceType instancetype.Type, poolName, projectName, instanceName string) string { fullName := project.Instance(projectName, instanceName) From 0a49ac8a1ee9f2e9e043f93b70e5be464cc08ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:27:25 -0400 Subject: [PATCH 04/14] incusd/acme: Remove all LXD mentions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- incusd/acme/acme.go | 4 ++-- incusd/acme/acme_test.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/incusd/acme/acme.go b/incusd/acme/acme.go index bbda1648b79..5b21c123b3b 100644 --- a/incusd/acme/acme.go +++ b/incusd/acme/acme.go @@ -22,13 +22,13 @@ import ( "github.com/lxc/incus/shared/logger" ) -// retries describes the number of retries after which LXD will give up registering a user or +// retries describes the number of retries after which Incus will give up registering a user or // issuing a new certificate. The number 5 was chosen because Let's Encrypt has a limit of 5 // failures per account, per hostname, per hour. const retries = 5 // ClusterCertFilename describes the filename of the new certificate which is stored in case it -// cannot be distributed in a cluster due to offline members. LXD will try to distribute this +// cannot be distributed in a cluster due to offline members. Incus will try to distribute this // certificate at a later stage. const ClusterCertFilename = "cluster.crt.new" diff --git a/incusd/acme/acme_test.go b/incusd/acme/acme_test.go index 502159883c9..7d9e9087b3a 100644 --- a/incusd/acme/acme_test.go +++ b/incusd/acme/acme_test.go @@ -22,9 +22,9 @@ func Test_certificateNeedsUpdate(t *testing.T) { { "Certificate is valid for more than 30 days", args{ - domain: "lxd.example.net", + domain: "foo.example.net", cert: &x509.Certificate{ - DNSNames: []string{"lxd.example.net"}, + DNSNames: []string{"foo.example.net"}, NotAfter: time.Now().Add(90 * 24 * time.Hour), }, }, @@ -33,9 +33,9 @@ func Test_certificateNeedsUpdate(t *testing.T) { { "Certificate is valid for less than 30 days", args{ - domain: "lxd.example.net", + domain: "foo.example.net", cert: &x509.Certificate{ - DNSNames: []string{"lxd.example.net"}, + DNSNames: []string{"foo.example.net"}, NotAfter: time.Now().Add(15 * 24 * time.Hour), }, }, @@ -44,9 +44,9 @@ func Test_certificateNeedsUpdate(t *testing.T) { { "Domain differs from certificate and is valid for more than 30 days", args{ - domain: "lxd.example.org", + domain: "foo.example.org", cert: &x509.Certificate{ - DNSNames: []string{"lxd.example.net"}, + DNSNames: []string{"foo.example.net"}, NotAfter: time.Now().Add(90 * 24 * time.Hour), }, }, @@ -55,9 +55,9 @@ func Test_certificateNeedsUpdate(t *testing.T) { { "Domain differs from certificate and is valid for less than 30 days", args{ - domain: "lxd.example.org", + domain: "foo.example.org", cert: &x509.Certificate{ - DNSNames: []string{"lxd.example.net"}, + DNSNames: []string{"foo.example.net"}, NotAfter: time.Now().Add(15 * 24 * time.Hour), }, }, From 201c5ee1688eb30768315f43399f9ec338a3e16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:28:50 -0400 Subject: [PATCH 05/14] incusd/dnsmasq: Remove all LXD mentions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- incusd/dnsmasq/dhcpalloc/dhcpalloc.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/incusd/dnsmasq/dhcpalloc/dhcpalloc.go b/incusd/dnsmasq/dhcpalloc/dhcpalloc.go index 085c4b9c291..42c8e87355c 100644 --- a/incusd/dnsmasq/dhcpalloc/dhcpalloc.go +++ b/incusd/dnsmasq/dhcpalloc/dhcpalloc.go @@ -75,7 +75,7 @@ func GetIP(subnet *net.IPNet, host int64) net.IP { return newIP } -// Network represents a LXD network responsible for running dnsmasq. +// Network represents an Incus network responsible for running dnsmasq. type Network interface { Name() string Type() string @@ -179,7 +179,7 @@ func (t *Transaction) AllocateIPv6() (net.IP, error) { // It first checks whether there is an existing allocation for the instance. // If no previous allocation, then a free IP is picked from the ranges configured. func (t *Transaction) getDHCPFreeIPv4(usedIPs map[[4]byte]dnsmasq.DHCPAllocation, deviceStaticFileName string, mac net.HardwareAddr) (net.IP, error) { - lxdIP, subnet, err := net.ParseCIDR(t.opts.Network.Config()["ipv4.address"]) + ip, subnet, err := net.ParseCIDR(t.opts.Network.Config()["ipv4.address"]) if err != nil { return nil, err } @@ -217,8 +217,8 @@ func (t *Transaction) getDHCPFreeIPv4(usedIPs map[[4]byte]dnsmasq.DHCPAllocation IP := net.IP(startBig.Bytes()) - // Check IP generated is not LXD's IP. - if IP.Equal(lxdIP) { + // Check IP generated is not Incus's IP. + if IP.Equal(ip) { startBig.Add(startBig, inc) continue } @@ -248,7 +248,7 @@ func (t *Transaction) getDHCPFreeIPv4(usedIPs map[[4]byte]dnsmasq.DHCPAllocation // device's MAC address. Finally if stateful custom ranges are enabled, then a free IP is picked // from the ranges configured. func (t *Transaction) getDHCPFreeIPv6(usedIPs map[[16]byte]dnsmasq.DHCPAllocation, deviceStaticFileName string, mac net.HardwareAddr) (net.IP, error) { - lxdIP, subnet, err := net.ParseCIDR(t.opts.Network.Config()["ipv6.address"]) + ip, subnet, err := net.ParseCIDR(t.opts.Network.Config()["ipv6.address"]) if err != nil { return nil, err } @@ -274,11 +274,11 @@ func (t *Transaction) getDHCPFreeIPv6(usedIPs map[[16]byte]dnsmasq.DHCPAllocatio return nil, err } - // Check IP is not already allocated and not the LXD IP. + // Check IP is not already allocated and not the Incus IP. var IPKey [16]byte copy(IPKey[:], IP.To16()) _, inUse := usedIPs[IPKey] - if !inUse && !IP.Equal(lxdIP) { + if !inUse && !IP.Equal(ip) { return IP, nil } } @@ -307,8 +307,8 @@ func (t *Transaction) getDHCPFreeIPv6(usedIPs map[[16]byte]dnsmasq.DHCPAllocatio IP := net.IP(startBig.Bytes()) - // Check IP generated is not LXD's IP. - if IP.Equal(lxdIP) { + // Check IP generated is not Incus's IP. + if IP.Equal(ip) { startBig.Add(startBig, inc) continue } From dd56a7aebd525be97050948989e3cf912f6909e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:29:33 -0400 Subject: [PATCH 06/14] incusd/auth: Remove all LXD mentions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- incusd/auth/oidc/oidc.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/incusd/auth/oidc/oidc.go b/incusd/auth/oidc/oidc.go index 2927a7ae4d6..6d5c2557c38 100644 --- a/incusd/auth/oidc/oidc.go +++ b/incusd/auth/oidc/oidc.go @@ -48,9 +48,9 @@ func (o *Verifier) Auth(ctx context.Context, w http.ResponseWriter, r *http.Requ if auth != "" { // When a client wants to authenticate, it needs to set the Authorization HTTP header like this: // Authorization Bearer - // If set correctly, LXD will attempt to verify the access token, and grant access if it's valid. - // If the verification fails, LXD will return an InvalidToken error. The client should then either use its refresh token to get a new valid access token, or log in again. - // If the Authorization header is missing, LXD returns an AuthenticationRequired error. + // If set correctly, Incus will attempt to verify the access token, and grant access if it's valid. + // If the verification fails, Incus will return an InvalidToken error. The client should then either use its refresh token to get a new valid access token, or log in again. + // If the Authorization header is missing, Incus returns an AuthenticationRequired error. // Both returned errors contain information which are needed for the client to authenticate. parts := strings.Split(auth, "Bearer ") if len(parts) != 2 { From 1cc55a8be38321e9d5bd7d2f1e65959ee29a63a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:31:16 -0400 Subject: [PATCH 07/14] incusd/firewall: Remove all LXD mentions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- incusd/firewall/firewall_interface.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/incusd/firewall/firewall_interface.go b/incusd/firewall/firewall_interface.go index 1a18875b488..ceba97ad06b 100644 --- a/incusd/firewall/firewall_interface.go +++ b/incusd/firewall/firewall_interface.go @@ -6,7 +6,7 @@ import ( drivers "github.com/lxc/incus/incusd/firewall/drivers" ) -// Firewall represents a Incus firewall. +// Firewall represents an Incus firewall. type Firewall interface { String() string Compat() (bool, error) From a1b32dd14ddefd940d8b34ca1664fa0baa3c31a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:35:00 -0400 Subject: [PATCH 08/14] incusd/resources: Remove all LXD mentions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- incusd/resources/cpu.go | 2 +- incusd/resources/gpu.go | 2 +- incusd/resources/memory.go | 2 +- incusd/resources/network.go | 2 +- incusd/resources/pci.go | 2 +- incusd/resources/resources.go | 2 +- incusd/resources/storage.go | 2 +- incusd/resources/system.go | 2 +- incusd/resources/usb.go | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/incusd/resources/cpu.go b/incusd/resources/cpu.go index 61200f62503..f80e64a211b 100644 --- a/incusd/resources/cpu.go +++ b/incusd/resources/cpu.go @@ -205,7 +205,7 @@ func getCPUdmi() (string, string, error) { return "", "", fmt.Errorf("No DMI table found") } -// GetCPU returns a filled api.ResourcesCPU struct ready for use by LXD. +// GetCPU returns a filled api.ResourcesCPU struct ready for use by Incus. func GetCPU() (*api.ResourcesCPU, error) { cpu := api.ResourcesCPU{} diff --git a/incusd/resources/gpu.go b/incusd/resources/gpu.go index a86f352f5ea..3abd142efcb 100644 --- a/incusd/resources/gpu.go +++ b/incusd/resources/gpu.go @@ -410,7 +410,7 @@ func gpuAddDeviceInfo(devicePath string, nvidiaCards map[string]*api.ResourcesGP return nil } -// GetGPU returns a filled api.ResourcesGPU struct ready for use by LXD. +// GetGPU returns a filled api.ResourcesGPU struct ready for use by Incus. func GetGPU() (*api.ResourcesGPU, error) { gpu := api.ResourcesGPU{} gpu.Cards = []api.ResourcesGPUCard{} diff --git a/incusd/resources/memory.go b/incusd/resources/memory.go index a8274cf8bc5..e277e90ed93 100644 --- a/incusd/resources/memory.go +++ b/incusd/resources/memory.go @@ -196,7 +196,7 @@ func getTotalMemory(sysDevicesBase string) uint64 { return blockSize * count } -// GetMemory returns a filled api.ResourcesMemory struct ready for use by LXD. +// GetMemory returns a filled api.ResourcesMemory struct ready for use by Incus. func GetMemory() (*api.ResourcesMemory, error) { memory := api.ResourcesMemory{} diff --git a/incusd/resources/network.go b/incusd/resources/network.go index a6235ada160..fd309360f67 100644 --- a/incusd/resources/network.go +++ b/incusd/resources/network.go @@ -301,7 +301,7 @@ func networkAddDeviceInfo(devicePath string, pciDB *pcidb.PCIDB, uname unix.Utsn return nil } -// GetNetwork returns a filled api.ResourcesNetwork struct ready for use by LXD. +// GetNetwork returns a filled api.ResourcesNetwork struct ready for use by Incus. func GetNetwork() (*api.ResourcesNetwork, error) { network := api.ResourcesNetwork{} network.Cards = []api.ResourcesNetworkCard{} diff --git a/incusd/resources/pci.go b/incusd/resources/pci.go index 22e8ed6acc7..1b94763ef80 100644 --- a/incusd/resources/pci.go +++ b/incusd/resources/pci.go @@ -13,7 +13,7 @@ import ( "github.com/lxc/incus/shared/api" ) -// GetPCI returns a filled api.ResourcesPCI struct ready for use by LXD. +// GetPCI returns a filled api.ResourcesPCI struct ready for use by Incus. func GetPCI() (*api.ResourcesPCI, error) { pci := api.ResourcesPCI{} pci.Devices = []api.ResourcesPCIDevice{} diff --git a/incusd/resources/resources.go b/incusd/resources/resources.go index 4653f65daaa..dde1322344c 100644 --- a/incusd/resources/resources.go +++ b/incusd/resources/resources.go @@ -6,7 +6,7 @@ import ( "github.com/lxc/incus/shared/api" ) -// GetResources returns a filled api.Resources struct ready for use by LXD. +// GetResources returns a filled api.Resources struct ready for use by Incus. func GetResources() (*api.Resources, error) { // Get CPU information cpu, err := GetCPU() diff --git a/incusd/resources/storage.go b/incusd/resources/storage.go index 15604c05018..520f3edb537 100644 --- a/incusd/resources/storage.go +++ b/incusd/resources/storage.go @@ -114,7 +114,7 @@ func storageAddDriveInfo(devicePath string, disk *api.ResourcesStorageDisk) erro return nil } -// GetStorage returns a filled api.ResourcesStorage struct ready for use by LXD. +// GetStorage returns a filled api.ResourcesStorage struct ready for use by Incus. func GetStorage() (*api.ResourcesStorage, error) { storage := api.ResourcesStorage{} storage.Disks = []api.ResourcesStorageDisk{} diff --git a/incusd/resources/system.go b/incusd/resources/system.go index 9ace1188231..76da4947b77 100644 --- a/incusd/resources/system.go +++ b/incusd/resources/system.go @@ -13,7 +13,7 @@ import ( var sysClassDMIID = "/sys/class/dmi/id" var systemType string -// GetSystem returns a filled api.ResourcesSystem struct ready for use by LXD. +// GetSystem returns a filled api.ResourcesSystem struct ready for use by Incus. func GetSystem() (*api.ResourcesSystem, error) { var err error system := api.ResourcesSystem{} diff --git a/incusd/resources/usb.go b/incusd/resources/usb.go index a1fe2cda1dc..708e2aafaf2 100644 --- a/incusd/resources/usb.go +++ b/incusd/resources/usb.go @@ -15,7 +15,7 @@ import ( var sysBusUSB = "/sys/bus/usb/devices" -// GetUSB returns a filled api.ResourcesUSB struct ready for use by LXD. +// GetUSB returns a filled api.ResourcesUSB struct ready for use by Incus. func GetUSB() (*api.ResourcesUSB, error) { // Load the USB database. usbid.Load() From 7ef2245461579aa11b1fd2748047f04c0a898e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:37:36 -0400 Subject: [PATCH 09/14] incusd/migration: Remove backward compatibility logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- incusd/migration/migration_volumes.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/incusd/migration/migration_volumes.go b/incusd/migration/migration_volumes.go index bf94f63da36..5539151b899 100644 --- a/incusd/migration/migration_volumes.go +++ b/incusd/migration/migration_volumes.go @@ -195,12 +195,6 @@ func MatchTypes(offer *MigrationHeader, fallbackType MigrationFSType, ourTypes [ offeredFeatures = offer.GetBtrfsFeaturesSlice() } else if offerFSType == MigrationFSType_RSYNC { offeredFeatures = offer.GetRsyncFeaturesSlice() - if !shared.StringInSlice("bidirectional", offeredFeatures) { - // If no bi-directional support, this means we are getting a response from - // an old LXD server that doesn't support bidirectional negotiation, so - // assume LXD 3.7 level. NOTE: Do NOT extend this list of arguments. - offeredFeatures = []string{"xattrs", "delete", "compress"} - } } // Find common features in both our type and offered type. From 6ab53df55a3ba4ded166b77b95789d9011ddc0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:38:03 -0400 Subject: [PATCH 10/14] incusd/cgroup: Remove all LXD mentions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- incusd/cgroup/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/incusd/cgroup/init.go b/incusd/cgroup/init.go index 69d17b354aa..45ac9edfda7 100644 --- a/incusd/cgroup/init.go +++ b/incusd/cgroup/init.go @@ -341,7 +341,7 @@ func Init() { cgNamespace = true } - // Go through the list of resource controllers for LXD. + // Go through the list of resource controllers for Incus. selfCg, err := os.Open("/proc/self/cgroup") if err != nil { if os.IsNotExist(err) { From a2e87c58cf7f54b7fe5f1d1c600d1358ca7fc882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:38:10 -0400 Subject: [PATCH 11/14] incusd/operations: Remove all LXD mentions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- incusd/operations/operations.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/incusd/operations/operations.go b/incusd/operations/operations.go index 3db28d3a664..9df52e61f5b 100644 --- a/incusd/operations/operations.go +++ b/incusd/operations/operations.go @@ -126,9 +126,9 @@ type Operation struct { // OperationCreate creates a new operation and returns it. If it cannot be // created, it returns an error. func OperationCreate(s *state.State, projectName string, opClass OperationClass, opType operationtype.Type, opResources map[string][]api.URL, opMetadata any, onRun func(*Operation) error, onCancel func(*Operation) error, onConnect func(*Operation, *http.Request, http.ResponseWriter) error, r *http.Request) (*Operation, error) { - // Don't allow new operations when LXD is shutting down. + // Don't allow new operations when Incus is shutting down. if s != nil && s.ShutdownCtx.Err() == context.Canceled { - return nil, fmt.Errorf("LXD is shutting down") + return nil, fmt.Errorf("Incus is shutting down") } // Main attributes From e235a77addf00677cbc586d60dc27a6dc19194c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 18 Aug 2023 23:38:17 -0400 Subject: [PATCH 12/14] incusd/rsync: Remove all LXD mentions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- incusd/rsync/rsync.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/incusd/rsync/rsync.go b/incusd/rsync/rsync.go index 0c20c660a01..d54ba959cac 100644 --- a/incusd/rsync/rsync.go +++ b/incusd/rsync/rsync.go @@ -135,7 +135,7 @@ func sendSetup(name string, path string, bwlimit string, execPath string, featur * stdin/stdout, but that also seemed messy. In any case, this seems to * work just fine. */ - auds := fmt.Sprintf("@lxd/%s", uuid.New()) + auds := fmt.Sprintf("@incusd/%s", uuid.New()) // We simply copy a part of the uuid if it's longer than the allowed // maximum. That should be safe enough for our purposes. if len(auds) > linux.ABSTRACT_UNIX_SOCK_LEN-1 { @@ -152,7 +152,7 @@ func sendSetup(name string, path string, bwlimit string, execPath string, featur /* * Here, the path /tmp/foo is ignored. Since we specify localhost, * rsync thinks we are syncing to a remote host (in this case, the - * other end of the lxd websocket), and so the path specified on the + * other end of the incus websocket), and so the path specified on the * --server instance of rsync takes precedence. */ rsyncCmd := fmt.Sprintf("%s netcat %s %s --", execPath, auds, name) From d16ccf614c36e3ffd041c305292c0e9826e136de Mon Sep 17 00:00:00 2001 From: Ruth Fuchss Date: Thu, 17 Aug 2023 11:27:00 +0200 Subject: [PATCH 13/14] doc: restrict Sphinx version The latest Sphinx version that was released today removes functions that some extensions require. Temporarily restrict the Sphinx version until the extensions have been fixed. Signed-off-by: Ruth Fuchss --- doc/.sphinx/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/.sphinx/requirements.txt b/doc/.sphinx/requirements.txt index 73a856e0904..465cd65130c 100644 --- a/doc/.sphinx/requirements.txt +++ b/doc/.sphinx/requirements.txt @@ -16,7 +16,7 @@ pytz requests six snowballstemmer -Sphinx +Sphinx<7.2.0 sphinx-autobuild sphinxcontrib-applehelp sphinxcontrib-devhelp From daf552e381dd906fc475e0d3ee316a4403a84690 Mon Sep 17 00:00:00 2001 From: Ruth Fuchss Date: Fri, 18 Aug 2023 11:39:38 +0200 Subject: [PATCH 14/14] doc: temporarily pin Sphinx requirement Seems the latest Sphinx update has caused more issues ... 7.2.2 doesn't work with the notfound extension (see https://github.com/readthedocs/sphinx-notfound-page/issues/219 ). When restricting Sphinx to <7.2.0, RTD uses 6.2.1 though, which is incompatible with a Furo change (see https://github.com/pradyunsg/furo/discussions/693 ). Therefore, restrict Sphinx to 7.1.2 until the issues are resolved. Signed-off-by: Ruth Fuchss --- doc/.sphinx/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/.sphinx/requirements.txt b/doc/.sphinx/requirements.txt index 465cd65130c..1300630892e 100644 --- a/doc/.sphinx/requirements.txt +++ b/doc/.sphinx/requirements.txt @@ -16,7 +16,7 @@ pytz requests six snowballstemmer -Sphinx<7.2.0 +Sphinx==7.1.2 sphinx-autobuild sphinxcontrib-applehelp sphinxcontrib-devhelp