From a665700076881e0835dcf2bca1c518cc2eea6e77 Mon Sep 17 00:00:00 2001 From: Jonathan Herlin Date: Tue, 26 Mar 2024 09:08:59 +0100 Subject: [PATCH] Add support for static storage container name (#107) Depending on the backend used a static container name might be needed. In a scenario of ceph-driver this corresponds to a ceph pool that holds the backups, which is not something the user can create themselves through Openstack Cinder. --- src/cinder/block_store.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cinder/block_store.go b/src/cinder/block_store.go index 1500836..22af962 100644 --- a/src/cinder/block_store.go +++ b/src/cinder/block_store.go @@ -97,6 +97,7 @@ type BlockStore struct { ensureDeleted bool ensureDeletedDelay int cascadeDelete bool + containerName string log logrus.FieldLogger } @@ -158,6 +159,9 @@ func (b *BlockStore) Init(config map[string]string) error { return fmt.Errorf("cannot parse cascadeDelete config variable: %w", err) } + // load optional containerName + b.containerName = utils.GetConf(b.config, "containerName", "") + // Authenticate to OpenStack err = utils.Authenticate(&b.provider, "cinder", config, b.log) if err != nil { @@ -607,6 +611,12 @@ func (b *BlockStore) createBackup(volumeID, volumeAZ string, tags map[string]str Metadata: utils.Merge(originVolume.Metadata, tags), Force: true, } + + // Override container if one was passed by the user + if b.containerName != "" { + opts.Container = b.containerName + } + backup, err := backups.Create(b.client, opts).Extract() if err != nil { logWithFields.Error("failed to create backup from volume")