Merge pull request #12727 from rook/mergify/bp/release-1.12/pr-12725

file: ignore exit code 22 when addding datapool (backport #12725)
This commit is contained in:
Travis Nielsen authored and GitHub committed 2023-08-15 13:14:45 -06:00
commit 3de55e23f5
1 file changed
+9
+9
View File
@@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"strconv"
"syscall"
"time"
"github.com/pkg/errors"
@@ -168,6 +169,14 @@ func AddDataPoolToFilesystem(context *clusterd.Context, clusterInfo *ClusterInfo
args := []string{"fs", "add_data_pool", name, poolName}
_, err := NewCephCommand(context, clusterInfo, args).Run()
if err != nil {
// Reef disallows calling add_data_pool for a pool that has already
// been added, so ignore the error code.
// Previous releases do not return an error when an existing data pool is added.
if clusterInfo.CephVersion.IsAtLeastReef() {
if code, ok := exec.ExitStatus(err); ok && code == int(syscall.EINVAL) {
return nil
}
}
return errors.Wrapf(err, "failed to add pool %q to file system %q. (%v)", poolName, name, err)
}
return nil