Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cubelet/storage/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ var (
defaultPoolTriggerIntervalInMs = 1000
defaultWarningPercent = 100
defaultFormatSize = "1Gi"
defaultCmdTimeout = 3 * time.Second

unifiedStorageSize = resource.MustParse(defaultFormatSize)
otherFormatSize = "othersv2"
Expand Down
16 changes: 16 additions & 0 deletions Cubelet/storage/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ type Config struct {

FreeInodesThreshold int32 `toml:"free_inodes_threshold"`
ReconcileInterval tomlext.Duration `toml:"reconcile_interval"`

// CmdTimeout overrides the per-command timeout for utils.ExecV
// invocations in shell.go (cp / truncate / e2fsck / resize2fs /
// mkfs.ext4). Defaults to defaultCmdTimeout when zero. The slow
// ext4-create path on multi-GiB images can need noticeably more
// than the 3s default; this knob lets operators bump it without
// recompiling.
CmdTimeout tomlext.Duration `toml:"cmd_timeout"`
}

func init() {
Expand All @@ -76,6 +84,14 @@ func init() {
if localStorage.config.PoolType == "" {
localStorage.config.PoolType = cp_type
}
if localStorage.config.CmdTimeout == 0 {
localStorage.config.CmdTimeout = tomlext.FromStdTime(defaultCmdTimeout)
}
if tomlext.ToStdTime(localStorage.config.CmdTimeout) < 0 {
return nil, fmt.Errorf("cmd_timeout must be non-negative, got %v",
tomlext.ToStdTime(localStorage.config.CmdTimeout))
}
cmdTimeout = tomlext.ToStdTime(localStorage.config.CmdTimeout)
checkPoolType(localStorage.config)

cubeboxAPIObj, err := ic.GetByID(constants.CubeStorePlugin, constants.CubeboxID.ID())
Expand Down
9 changes: 8 additions & 1 deletion Cubelet/storage/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ import (
"github.com/tencentcloud/CubeSandbox/Cubelet/pkg/utils"
)

const cmdTimeout = time.Second * 3
// cmdTimeout is the per-command timeout for utils.ExecV calls in this
// package (cp, truncate, e2fsck, resize2fs, mkfs.ext4, ...). The
// default of 3s is fine for the small pre-formatted images on the
// pool fast path; the live `mkfs + reflink-copy + e2fsck + resize2fs`
// slow path on multi-GiB images can need longer. Override via the
// storage plugin config `cmd_timeout` (see Config.CmdTimeout); set
// during plugin initialization.
var cmdTimeout = 3 * time.Second

const diskSizeOverheadInBytes = 1024 * 1024 * 100

Expand Down