mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-25 14:30:22 +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 (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
libcephfs "github.com/ceph/go-ceph/cephfs"
|
||||
fsAdmin "github.com/ceph/go-ceph/cephfs/admin"
|
||||
)
|
||||
|
||||
@ -133,8 +133,7 @@ func (s *subVolumeClient) UnsetAllMetadata(keys []string) error {
|
||||
if errors.Is(err, ErrSubVolMetadataNotSupported) {
|
||||
return nil
|
||||
}
|
||||
// TODO: replace string comparison with errno.
|
||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
||||
if err != nil && !errors.Is(err, libcephfs.ErrNotExist) {
|
||||
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) {
|
||||
return nil
|
||||
}
|
||||
// TODO: replace string comparison with errno.
|
||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
||||
if err != nil && !errors.Is(err, libcephfs.ErrNotExist) {
|
||||
return fmt.Errorf("failed to unset metadata key %q on subvolume %v: %w", clusterNameKey, s, err)
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ package core
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
libcephfs "github.com/ceph/go-ceph/cephfs"
|
||||
fsAdmin "github.com/ceph/go-ceph/cephfs/admin"
|
||||
)
|
||||
|
||||
@ -121,16 +121,14 @@ func (s *snapshotClient) UnsetAllSnapshotMetadata(keys []string) error {
|
||||
|
||||
for _, key := range keys {
|
||||
err := s.removeSnapshotMetadata(key)
|
||||
// TODO: replace string comparison with errno.
|
||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
||||
if err != nil && !errors.Is(err, libcephfs.ErrNotExist) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
err := s.removeSnapshotMetadata(clusterNameKey)
|
||||
// TODO: replace string comparison with errno.
|
||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
||||
if err != nil && !errors.Is(err, libcephfs.ErrNotExist) {
|
||||
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)
|
||||
}
|
||||
|
@ -2143,15 +2143,13 @@ func (rv *rbdVolume) setAllMetadata(parameters map[string]string) error {
|
||||
func (rv *rbdVolume) unsetAllMetadata(keys []string) error {
|
||||
for _, key := range keys {
|
||||
err := rv.RemoveMetadata(key)
|
||||
// TODO: replace string comparison with errno.
|
||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
||||
if err != nil && !errors.Is(err, librbd.ErrNotExist) {
|
||||
return fmt.Errorf("failed to unset metadata key %q on %q: %w", key, rv, err)
|
||||
}
|
||||
}
|
||||
|
||||
err := rv.RemoveMetadata(clusterNameKey)
|
||||
// TODO: replace string comparison with errno.
|
||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
||||
if err != nil && !errors.Is(err, librbd.ErrNotExist) {
|
||||
return fmt.Errorf("failed to unset metadata key %q on %q: %w", clusterNameKey, rv, err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user