From 10076ca11f72a5bede7c3ae90d5955c1dac9b047 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 2 Oct 2024 17:11:11 +0200 Subject: [PATCH] rbd: use the new go-ceph rbd.ErrExist for checking rbd.GroupCreate() The go-ceph rbd.GroupCreate() now returns ErrExist in case the group that is created, already exists. The previous check only ever matched the string comparison, which is prone to errors in case the contents is modified by go-ceph. Signed-off-by: Niels de Vos --- internal/rbd/group/volume_group.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/rbd/group/volume_group.go b/internal/rbd/group/volume_group.go index 7de46131a..d23b26d99 100644 --- a/internal/rbd/group/volume_group.go +++ b/internal/rbd/group/volume_group.go @@ -20,7 +20,6 @@ import ( "context" "errors" "fmt" - "strings" "github.com/ceph/go-ceph/rados" librbd "github.com/ceph/go-ceph/rbd" @@ -164,7 +163,7 @@ func (vg *volumeGroup) Create(ctx context.Context) error { err = librbd.GroupCreate(ioctx, name) if err != nil { - if !errors.Is(rados.ErrObjectExists, err) && !strings.Contains(err.Error(), "rbd: ret=-17, File exists") { + if !errors.Is(err, librbd.ErrExist) { return fmt.Errorf("failed to create volume group %q: %w", name, err) }