The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7051
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
From 8b31ffd6743cd9ae5fafcb21a36e714bfd6dddf5 Mon Sep 17 00:00:00 2001 From: Thomas Hipp <thomas.h...@canonical.com> Date: Tue, 17 Mar 2020 22:00:06 +0100 Subject: [PATCH] lxd: Clean up logging for expired volume snapshots Signed-off-by: Thomas Hipp <thomas.h...@canonical.com> --- lxd/storage_volumes_snapshot.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lxd/storage_volumes_snapshot.go b/lxd/storage_volumes_snapshot.go index 0753c0578b..e9e770ccc2 100644 --- a/lxd/storage_volumes_snapshot.go +++ b/lxd/storage_volumes_snapshot.go @@ -552,8 +552,19 @@ func storagePoolVolumeSnapshotTypeDelete(d *Daemon, r *http.Request) response.Re func pruneExpireCustomVolumeSnapshotsTask(d *Daemon) (task.Func, task.Schedule) { f := func(ctx context.Context) { + // Get the list of expired custom volume snapshots. + expiredSnapshots, err := d.cluster.StorageVolumeSnapshotsGetExpired() + if err != nil { + logger.Error("Unable to retrieve the list of expired custom volume snapshots", log.Ctx{"err": err}) + return + } + + if len(expiredSnapshots) == 0 { + return + } + opRun := func(op *operations.Operation) error { - return pruneExpiredCustomVolumeSnapshots(ctx, d) + return pruneExpiredCustomVolumeSnapshots(ctx, d, expiredSnapshots) } op, err := operations.OperationCreate(d.State(), "", operations.OperationClassTask, db.OperationCustomVolumeSnapshotsExpire, nil, nil, opRun, nil, nil) @@ -587,14 +598,8 @@ func pruneExpireCustomVolumeSnapshotsTask(d *Daemon) (task.Func, task.Schedule) return f, schedule } -func pruneExpiredCustomVolumeSnapshots(ctx context.Context, d *Daemon) error { - // Get the list of expired custom volume snapshots. - snapshots, err := d.cluster.StorageVolumeSnapshotsGetExpired() - if err != nil { - return errors.Wrap(err, "Unable to retrieve the list of expired custom volume snapshots") - } - - for _, s := range snapshots { +func pruneExpiredCustomVolumeSnapshots(ctx context.Context, d *Daemon, expiredSnapshots []db.StorageVolumeArgs) error { + for _, s := range expiredSnapshots { pool, err := storagePools.GetPoolByName(d.State(), s.PoolName) if err != nil { return errors.Wrapf(err, "Failed to get pool %q", s.PoolName)
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel