mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Fix up validation and allow existing unset timeouts to continue to be unset
This commit is contained in:
@@ -1482,6 +1482,7 @@ func (tg *TaskGroup) GoString() string {
|
||||
}
|
||||
|
||||
const (
|
||||
// TODO add Consul TTL check
|
||||
ServiceCheckHTTP = "http"
|
||||
ServiceCheckTCP = "tcp"
|
||||
ServiceCheckScript = "script"
|
||||
@@ -1522,26 +1523,32 @@ func (sc *ServiceCheck) Copy() *ServiceCheck {
|
||||
func (sc *ServiceCheck) validate() error {
|
||||
switch strings.ToLower(sc.Type) {
|
||||
case ServiceCheckTCP:
|
||||
if sc.Timeout > 0 && sc.Timeout <= minCheckTimeout {
|
||||
return fmt.Errorf("timeout %v is lower than required minimum timeout %v", sc.Timeout, minCheckInterval)
|
||||
}
|
||||
case ServiceCheckHTTP:
|
||||
if sc.Path == "" {
|
||||
return fmt.Errorf("http type must have a valid http path")
|
||||
}
|
||||
|
||||
if sc.Timeout > 0 && sc.Timeout <= minCheckTimeout {
|
||||
return fmt.Errorf("timeout %v is lower than required minimum timeout %v", sc.Timeout, minCheckInterval)
|
||||
}
|
||||
case ServiceCheckScript:
|
||||
if sc.Command == "" {
|
||||
return fmt.Errorf("script type must have a valid script path")
|
||||
}
|
||||
|
||||
// TODO: enforce timeout on the Client side and reenable
|
||||
// validation.
|
||||
default:
|
||||
return fmt.Errorf(`invalid type (%+q), must be one of "http", "tcp", or "script" type`, sc.Type)
|
||||
}
|
||||
|
||||
if sc.Interval <= minCheckInterval {
|
||||
if sc.Interval > 0 && sc.Interval <= minCheckInterval {
|
||||
return fmt.Errorf("interval (%v) can not be lower than %v", sc.Interval, minCheckInterval)
|
||||
}
|
||||
|
||||
if sc.Timeout <= minCheckTimeout {
|
||||
return fmt.Errorf("timeout %v is lower than required minimum timeout %v", sc.Timeout, minCheckInterval)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user