Skip to content

Commit

Permalink
ovirt: use go-ovirt ConflictErr instead of string check
Browse files Browse the repository at this point in the history
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
  • Loading branch information
bennyz authored and ahadas committed Aug 14, 2023
1 parent 16dc9dc commit 34d9944
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/controller/plan/adapter/ovirt/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ovirt
import (
"crypto/md5"
"encoding/hex"
"errors"
"fmt"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -65,7 +65,8 @@ func (r *Client) CreateSnapshot(vmRef ref.Ref) (snapshot string, err error) {
MustBuild(),
).Query("correlation_id", correlationID).Send()
if err != nil {
if strings.Contains(err.Error(), "Cannot create Snapshot") {
var conflictErr *ovirtsdk.ConflictError
if errors.As(err, &conflictErr) {
err = web.ConflictError{
Provider: r.Source.Provider,
Err: err,
Expand Down Expand Up @@ -488,7 +489,8 @@ func (r Client) removePrecopies(precopies []planapi.Precopy, vmService *ovirtsdk
// Try to remove the snapshot
_, err = snapService.Remove().Query("correlation_id", correlationID).Send()
if err != nil {
if strings.Contains(err.Error(), "Cannot remove Snapshot") {
var conflictErr *ovirtsdk.ConflictError
if errors.As(err, &conflictErr) {
err = web.ConflictError{
Provider: r.Source.Provider,
Err: err,
Expand Down

0 comments on commit 34d9944

Please sign in to comment.