Skip to content

Commit

Permalink
Add support for static storage container name (#107)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jonher937 authored Mar 26, 2024
1 parent e81b43f commit a665700
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cinder/block_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ type BlockStore struct {
ensureDeleted bool
ensureDeletedDelay int
cascadeDelete bool
containerName string
log logrus.FieldLogger
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit a665700

Please sign in to comment.