mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-10 00:10:20 +00:00
util: addresed few todo
this commit replaces string comparsion with error code at few places Signed-off-by: Riya Singhal <rsinghal@redhat.com>
This commit is contained in:
parent
4ccb299fd5
commit
4b5cdd5316
@ -19,8 +19,8 @@ package core
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
|
libcephfs "github.com/ceph/go-ceph/cephfs"
|
||||||
fsAdmin "github.com/ceph/go-ceph/cephfs/admin"
|
fsAdmin "github.com/ceph/go-ceph/cephfs/admin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -133,8 +133,7 @@ func (s *subVolumeClient) UnsetAllMetadata(keys []string) error {
|
|||||||
if errors.Is(err, ErrSubVolMetadataNotSupported) {
|
if errors.Is(err, ErrSubVolMetadataNotSupported) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// TODO: replace string comparison with errno.
|
if err != nil && !errors.Is(err, libcephfs.ErrNotExist) {
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,8 +143,7 @@ func (s *subVolumeClient) UnsetAllMetadata(keys []string) error {
|
|||||||
if errors.Is(err, ErrSubVolMetadataNotSupported) {
|
if errors.Is(err, ErrSubVolMetadataNotSupported) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// TODO: replace string comparison with errno.
|
if err != nil && !errors.Is(err, libcephfs.ErrNotExist) {
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ package core
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
|
libcephfs "github.com/ceph/go-ceph/cephfs"
|
||||||
fsAdmin "github.com/ceph/go-ceph/cephfs/admin"
|
fsAdmin "github.com/ceph/go-ceph/cephfs/admin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -121,16 +121,14 @@ func (s *snapshotClient) UnsetAllSnapshotMetadata(keys []string) error {
|
|||||||
|
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
err := s.removeSnapshotMetadata(key)
|
err := s.removeSnapshotMetadata(key)
|
||||||
// TODO: replace string comparison with errno.
|
if err != nil && !errors.Is(err, libcephfs.ErrNotExist) {
|
||||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
|
||||||
return fmt.Errorf("failed to unset metadata key %q on subvolume snapshot %s %s in fs %s: %w",
|
return fmt.Errorf("failed to unset metadata key %q on subvolume snapshot %s %s in fs %s: %w",
|
||||||
key, s.SnapshotID, s.VolID, s.FsName, err)
|
key, s.SnapshotID, s.VolID, s.FsName, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := s.removeSnapshotMetadata(clusterNameKey)
|
err := s.removeSnapshotMetadata(clusterNameKey)
|
||||||
// TODO: replace string comparison with errno.
|
if err != nil && !errors.Is(err, libcephfs.ErrNotExist) {
|
||||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
|
||||||
return fmt.Errorf("failed to unset metadata key %q on subvolume snapshot %s %s in fs %s: %w",
|
return fmt.Errorf("failed to unset metadata key %q on subvolume snapshot %s %s in fs %s: %w",
|
||||||
clusterNameKey, s.SnapshotID, s.VolID, s.FsName, err)
|
clusterNameKey, s.SnapshotID, s.VolID, s.FsName, err)
|
||||||
}
|
}
|
||||||
|
@ -2143,15 +2143,13 @@ func (rv *rbdVolume) setAllMetadata(parameters map[string]string) error {
|
|||||||
func (rv *rbdVolume) unsetAllMetadata(keys []string) error {
|
func (rv *rbdVolume) unsetAllMetadata(keys []string) error {
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
err := rv.RemoveMetadata(key)
|
err := rv.RemoveMetadata(key)
|
||||||
// TODO: replace string comparison with errno.
|
if err != nil && !errors.Is(err, librbd.ErrNotExist) {
|
||||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
|
||||||
return fmt.Errorf("failed to unset metadata key %q on %q: %w", key, rv, err)
|
return fmt.Errorf("failed to unset metadata key %q on %q: %w", key, rv, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := rv.RemoveMetadata(clusterNameKey)
|
err := rv.RemoveMetadata(clusterNameKey)
|
||||||
// TODO: replace string comparison with errno.
|
if err != nil && !errors.Is(err, librbd.ErrNotExist) {
|
||||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
|
||||||
return fmt.Errorf("failed to unset metadata key %q on %q: %w", clusterNameKey, rv, err)
|
return fmt.Errorf("failed to unset metadata key %q on %q: %w", clusterNameKey, rv, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user