mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
handle nil resources limits
Config may not express resource constraints on the job!
This commit is contained in:
@@ -303,14 +303,10 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
|
||||
Env: cfg.EnvList(),
|
||||
User: cfg.User,
|
||||
ResourceLimits: true,
|
||||
Resources: &executor.Resources{
|
||||
CPU: cfg.Resources.NomadResources.CPU,
|
||||
MemoryMB: cfg.Resources.NomadResources.MemoryMB,
|
||||
DiskMB: cfg.Resources.NomadResources.DiskMB,
|
||||
},
|
||||
TaskDir: cfg.TaskDir().Dir,
|
||||
StdoutPath: cfg.StdoutPath,
|
||||
StderrPath: cfg.StderrPath,
|
||||
Resources: toExecResources(cfg.Resources),
|
||||
TaskDir: cfg.TaskDir().Dir,
|
||||
StdoutPath: cfg.StdoutPath,
|
||||
StderrPath: cfg.StderrPath,
|
||||
}
|
||||
|
||||
ps, err := exec.Launch(execCmd)
|
||||
@@ -348,6 +344,19 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
|
||||
return handle, nil, nil
|
||||
}
|
||||
|
||||
func toExecResources(resources *drivers.Resources) *executor.Resources {
|
||||
if resources == nil || resources.NomadResources == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &executor.Resources{
|
||||
CPU: resources.NomadResources.CPU,
|
||||
MemoryMB: resources.NomadResources.MemoryMB,
|
||||
DiskMB: resources.NomadResources.DiskMB,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error) {
|
||||
handle, ok := d.tasks.Get(taskID)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user