mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-14 02:10:21 +00:00
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>
(cherry picked from commit 038462ff43
)
This commit is contained in:
parent
3a4c7c9d79
commit
3092b46774
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user