use return error code instead
Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
This commit is contained in:
1 parent
ff9230a10f
commit
b8c7e151bc
1 file changed
+11
-4
@@ -18,13 +18,14 @@ package client
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"strconv"
|
||||
|
||||
"regexp"
|
||||
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/util/exec"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -85,9 +86,15 @@ func CreateImage(context *clusterd.Context, clusterName, name, poolName, dataPoo
|
||||
}
|
||||
|
||||
buf, err := ExecuteRBDCommandNoFormat(context, clusterName, args)
|
||||
if err != nil && !strings.Contains(string(buf), fmt.Sprintf("%s already exists", name)) {
|
||||
return nil, fmt.Errorf("failed to create image %s in pool %s of size %d: %+v. output: %s",
|
||||
name, poolName, size, err, string(buf))
|
||||
if err != nil {
|
||||
cmdErr, ok := err.(*exec.CommandError)
|
||||
if ok && cmdErr.ExitStatus() == int(syscall.EEXIST) {
|
||||
// Image with the same name already exists in the given rbd pool. Continuing with the link to PV.
|
||||
logger.Warningf("Requested image %s exists in pool %s. Continuing", name, poolName)
|
||||
} else {
|
||||
return nil, fmt.Errorf("failed to create image %s in pool %s of size %d: %+v. output: %s",
|
||||
name, poolName, size, err, string(buf))
|
||||
}
|
||||
}
|
||||
|
||||
// now that the image is created, retrieve it
|
||||
|
||||
Reference in new issue
Block a user