Commit b5434360 authored by Jayson Reis's avatar Jayson Reis Committed by Derek Su
Browse files

feat: Make command timeout configurable

parent e57acf73
......@@ -41,9 +41,11 @@ const (
envVolSize = "VOL_SIZE_BYTES"
)
var (
CmdTimeoutCounts = 120
const (
defaultCmdTimeoutSeconds = 120
)
var (
ConfigFileCheckInterval = 30 * time.Second
HelperPodNameMaxLength = 128
......@@ -71,6 +73,8 @@ type NodePathMapData struct {
type ConfigData struct {
NodePathMap []*NodePathMapData `json:"nodePathMap,omitempty"`
CmdTimeoutSeconds int `json:"cmdTimeoutSeconds,omitempty"`
}
type NodePathMap struct {
......@@ -78,7 +82,8 @@ type NodePathMap struct {
}
type Config struct {
NodePathMap map[string]*NodePathMap
NodePathMap map[string]*NodePathMap
CmdTimeoutSeconds int
}
func NewProvisioner(stopCh chan struct{}, kubeClient *clientset.Clientset,
......@@ -447,7 +452,7 @@ func (p *LocalPathProvisioner) createHelperPod(action ActionType, cmd []string,
}()
completed := false
for i := 0; i < CmdTimeoutCounts; i++ {
for i := 0; i < p.config.CmdTimeoutSeconds; i++ {
if pod, err := p.kubeClient.CoreV1().Pods(p.namespace).Get(helperPod.Name, metav1.GetOptions{}); err != nil {
return err
} else if pod.Status.Phase == v1.PodSucceeded {
......@@ -457,7 +462,7 @@ func (p *LocalPathProvisioner) createHelperPod(action ActionType, cmd []string,
time.Sleep(1 * time.Second)
}
if !completed {
return fmt.Errorf("create process timeout after %v seconds", CmdTimeoutCounts)
return fmt.Errorf("create process timeout after %v seconds", p.config.CmdTimeoutSeconds)
}
logrus.Infof("Volume %v has been %vd on %v:%v", o.Name, action, o.Node, o.Path)
......@@ -540,5 +545,10 @@ func canonicalizeConfig(data *ConfigData) (cfg *Config, err error) {
npMap.Paths[path] = struct{}{}
}
}
if data.CmdTimeoutSeconds > 0 {
cfg.CmdTimeoutSeconds = data.CmdTimeoutSeconds
} else {
cfg.CmdTimeoutSeconds = defaultCmdTimeoutSeconds
}
return cfg, nil
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment