rbd: provide option to disable setting metadata on rbd images

As we added support to set the metadata on the rbd images created for
the PVC and volume snapshot, by default metadata is set on all the images.

As we have seen we are hitting issues#2327 a lot of times with this,
we start to leave a lot of stale images. Currently, we rely on
`--extra-create-metadata=true` to decide to set the metadata or not,
we cannot set this option to false to disable setting metadata because we
use this for encryption too.

This changes is to provide an option to disable setting the image
metadata when starting cephcsi.

Fixes: #3009
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
Prasanna Kumar Kalever
2022-04-12 09:33:00 +05:30
committed by mergify[bot]
parent 8a47904e8f
commit caf4090657
8 changed files with 26 additions and 0 deletions

View File

@ -132,6 +132,8 @@ type rbdImage struct {
// Cluster name
ClusterName string
// Set metadata on volume
EnableMetadata bool
// encryption provides access to optional VolumeEncryption functions
encryption *util.VolumeEncryption
@ -2061,6 +2063,10 @@ func genVolFromVolIDWithMigration(
// setAllMetadata set all the metadata from arg parameters on RBD image.
func (rv *rbdVolume) setAllMetadata(parameters map[string]string) error {
if !rv.EnableMetadata {
return nil
}
for k, v := range parameters {
err := rv.SetMetadata(k, v)
if err != nil {
@ -2081,6 +2087,10 @@ func (rv *rbdVolume) setAllMetadata(parameters map[string]string) error {
// unsetAllMetadata unset all the metadata from arg keys on RBD image.
func (rv *rbdVolume) unsetAllMetadata(keys []string) error {
if !rv.EnableMetadata {
return nil
}
for _, key := range keys {
err := rv.RemoveMetadata(key)
// TODO: replace string comparison with errno.