mirror of
https://github.com/kemko/nomad.git
synced 2026-01-03 00:45:43 +03:00
Added a validator for log storage
This commit is contained in:
@@ -1683,6 +1683,10 @@ func (t *Task) Validate() error {
|
||||
mErr.Errors = append(mErr.Errors, err)
|
||||
}
|
||||
}
|
||||
|
||||
if t.Resources.DiskMB <= (t.LogConfig.MaxFiles * t.LogConfig.MaxFileSizeMB) {
|
||||
mErr.Errors = append(mErr.Errors, fmt.Errorf("log storage exceeds requested disk capacity"))
|
||||
}
|
||||
return mErr.ErrorOrNil()
|
||||
}
|
||||
|
||||
|
||||
@@ -266,6 +266,21 @@ func TestTask_Validate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTask_Validate_LogConfig(t *testing.T) {
|
||||
task := &Task{
|
||||
LogConfig: DefaultLogConfig(),
|
||||
Resources: &Resources{
|
||||
DiskMB: 1,
|
||||
},
|
||||
}
|
||||
|
||||
err := task.Validate()
|
||||
mErr := err.(*multierror.Error)
|
||||
if !strings.Contains(mErr.Errors[3].Error(), "log storage") {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConstraint_Validate(t *testing.T) {
|
||||
c := &Constraint{}
|
||||
err := c.Validate()
|
||||
|
||||
Reference in New Issue
Block a user