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 <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2024-10-02 17:11:11 +02:00 committed by mergify[bot]
parent 88b964fe18
commit 10076ca11f

View File

@ -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)
}