Added copy method to LocalDisk
This commit is contained in:
parent
b844dc3600
commit
2f681b6415
|
@ -1,5 +1,11 @@
|
|||
job "binstore-storagelocker" {
|
||||
group "binsl" {
|
||||
local_disk {
|
||||
disk = 500
|
||||
}
|
||||
local_disk {
|
||||
disk = 100
|
||||
}
|
||||
count = 5
|
||||
task "binstore" {
|
||||
driver = "docker"
|
||||
|
|
|
@ -364,13 +364,10 @@ func (s *StateStore) UpsertJob(index uint64, job *structs.Job) error {
|
|||
continue
|
||||
}
|
||||
var diskMB int
|
||||
for j, task := range tg.Tasks {
|
||||
for _, task := range tg.Tasks {
|
||||
if task.Resources != nil {
|
||||
resources := task.Resources
|
||||
diskMB += resources.DiskMB
|
||||
resources.DiskMB = 0
|
||||
task.Resources = resources
|
||||
tg.Tasks[j] = task
|
||||
diskMB += task.Resources.DiskMB
|
||||
task.Resources.DiskMB = 0
|
||||
}
|
||||
}
|
||||
tg.LocalDisk = &structs.LocalDisk{
|
||||
|
@ -1720,13 +1717,10 @@ func (r *StateRestore) JobRestore(job *structs.Job) error {
|
|||
continue
|
||||
}
|
||||
var diskMB int
|
||||
for j, task := range tg.Tasks {
|
||||
for _, task := range tg.Tasks {
|
||||
if task.Resources != nil {
|
||||
resources := task.Resources
|
||||
diskMB += resources.DiskMB
|
||||
resources.DiskMB = 0
|
||||
task.Resources = resources
|
||||
tg.Tasks[j] = task
|
||||
diskMB += task.Resources.DiskMB
|
||||
task.Resources.DiskMB = 0
|
||||
}
|
||||
}
|
||||
tg.LocalDisk = &structs.LocalDisk{
|
||||
|
|
|
@ -1564,6 +1564,10 @@ func (tg *TaskGroup) Copy() *TaskGroup {
|
|||
}
|
||||
|
||||
ntg.Meta = CopyMapStringString(ntg.Meta)
|
||||
|
||||
if tg.LocalDisk != nil {
|
||||
ntg.LocalDisk = tg.LocalDisk.Copy()
|
||||
}
|
||||
return ntg
|
||||
}
|
||||
|
||||
|
@ -2056,7 +2060,7 @@ func (t *Task) Validate(localDisk *LocalDisk) error {
|
|||
mErr.Errors = append(mErr.Errors, err)
|
||||
}
|
||||
|
||||
// Esnure the task isn't asking for disk resources
|
||||
// Ensure the task isn't asking for disk resources
|
||||
if t.Resources != nil {
|
||||
if t.Resources.DiskMB > 0 {
|
||||
mErr.Errors = append(mErr.Errors, errors.New("Task can't ask for disk resources, they have to be specified at the task group level."))
|
||||
|
@ -2590,6 +2594,13 @@ func (d *LocalDisk) Validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Copy copies the LocalDisk struct and returns a new one
|
||||
func (d *LocalDisk) Copy() *LocalDisk {
|
||||
ld := new(LocalDisk)
|
||||
*ld = *d
|
||||
return ld
|
||||
}
|
||||
|
||||
// Vault stores the set of premissions a task needs access to from Vault.
|
||||
type Vault struct {
|
||||
// Policies is the set of policies that the task needs access to
|
||||
|
|
Loading…
Reference in a new issue