Added a validator for log storage

This commit is contained in:
Diptanu Choudhury
2016-02-11 12:30:47 -08:00
parent 2d9ea67359
commit 8f17f00a31
2 changed files with 19 additions and 0 deletions

View File

@@ -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()
}

View File

@@ -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()