Skip to content

Commit

Permalink
rbd: use the new go-ceph rbd.ErrExist for checking rbd.GroupCreate()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nixpanic authored and mergify[bot] committed Oct 4, 2024
1 parent 88b964f commit 10076ca
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internal/rbd/group/volume_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"strings"

"github.com/ceph/go-ceph/rados"
librbd "github.com/ceph/go-ceph/rbd"
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 10076ca

Please sign in to comment.