cephfs: return success if metadata operation not supported

If the ceph cluster is of older version and doesnot
support metadata operation, Instead of failing
the request return the success if metadata
operation is not supported.

fixes #3347

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2022-08-29 11:03:18 +05:30 committed by mergify[bot]
parent 40134772a7
commit 038462ff43

View File

@ -99,6 +99,10 @@ func (s *subVolumeClient) SetAllMetadata(parameters map[string]string) error {
for k, v := range parameters { for k, v := range parameters {
err := s.setMetadata(k, v) err := s.setMetadata(k, v)
// If setMetadata is not supported return nil
if errors.Is(err, ErrSubVolMetadataNotSupported) {
return nil
}
if err != nil { if err != nil {
return fmt.Errorf("failed to set metadata key %q, value %q on subvolume %v: %w", k, v, s, err) return fmt.Errorf("failed to set metadata key %q, value %q on subvolume %v: %w", k, v, s, err)
} }
@ -106,6 +110,10 @@ func (s *subVolumeClient) SetAllMetadata(parameters map[string]string) error {
if s.clusterName != "" { if s.clusterName != "" {
err := s.setMetadata(clusterNameKey, s.clusterName) err := s.setMetadata(clusterNameKey, s.clusterName)
// If setMetadata is not supported return nil
if errors.Is(err, ErrSubVolMetadataNotSupported) {
return nil
}
if err != nil { if err != nil {
return fmt.Errorf("failed to set metadata key %q, value %q on subvolume %v: %w", return fmt.Errorf("failed to set metadata key %q, value %q on subvolume %v: %w",
clusterNameKey, s.clusterName, s, err) clusterNameKey, s.clusterName, s, err)
@ -123,6 +131,10 @@ func (s *subVolumeClient) UnsetAllMetadata(keys []string) error {
for _, key := range keys { for _, key := range keys {
err := s.removeMetadata(key) err := s.removeMetadata(key)
// If setMetadata is not supported return nil
if errors.Is(err, ErrSubVolMetadataNotSupported) {
return nil
}
// TODO: replace string comparison with errno. // TODO: replace string comparison with errno.
if err != nil && !strings.Contains(err.Error(), "No such file or directory") { if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
return fmt.Errorf("failed to unset metadata key %q on subvolume %v: %w", key, s, err) return fmt.Errorf("failed to unset metadata key %q on subvolume %v: %w", key, s, err)
@ -130,6 +142,10 @@ func (s *subVolumeClient) UnsetAllMetadata(keys []string) error {
} }
err := s.removeMetadata(clusterNameKey) err := s.removeMetadata(clusterNameKey)
// If setMetadata is not supported return nil
if errors.Is(err, ErrSubVolMetadataNotSupported) {
return nil
}
// TODO: replace string comparison with errno. // TODO: replace string comparison with errno.
if err != nil && !strings.Contains(err.Error(), "No such file or directory") { if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
return fmt.Errorf("failed to unset metadata key %q on subvolume %v: %w", clusterNameKey, s, err) return fmt.Errorf("failed to unset metadata key %q on subvolume %v: %w", clusterNameKey, s, err)