ceph: make the timeout of ceph commands cofigurable

Sometimes the default 15s is not enough for timeout of ceph commands. For examples,
I encountered that `radosgw-admin` command took dozens of seconds under heavy load.

Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
This commit is contained in:
Satoru Takeuchi committed 2021-07-27 12:42:16 +00:00
1 parent 0330afeea6
commit 30e4fbb01f
20 files changed
+77 -14

No files matched your search

@@ -21,12 +21,14 @@ import (
"errors"
"fmt"
"reflect"
"strconv"
"strings"
"time"
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
"github.com/rook/rook/pkg/clusterd"
"github.com/rook/rook/pkg/operator/k8sutil"
"github.com/rook/rook/pkg/util/exec"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -81,6 +83,17 @@ func DiscoveryDaemonEnabled(context *clusterd.Context) bool {
return value == "true"
}
// SetCephCommandsTimeout sets the timeout value of Ceph commands which are executed from Rook
func SetCephCommandsTimeout(context *clusterd.Context) {
strTimeoutSeconds, _ := k8sutil.GetOperatorSetting(context.Clientset, OperatorSettingConfigMapName, "ROOK_CEPH_COMMANDS_TIMEOUT_SECONDS", "15")
timeoutSeconds, err := strconv.Atoi(strTimeoutSeconds)
if err != nil || timeoutSeconds < 1 {
logger.Warningf("ROOK_CEPH_COMMANDS_TIMEOUT is %q but it should be >= 1, set the default value 15", strTimeoutSeconds)
timeoutSeconds = 15
}
exec.CephCommandsTimeout = time.Duration(timeoutSeconds) * time.Second
}
// CheckForCancelledOrchestration checks whether a cancellation has been requested
func CheckForCancelledOrchestration(context *clusterd.Context) error {
defer context.RequestCancelOrchestration.UnSet()