Adding a separate function to add dedicated attributes. (#80)
Dedicated wrapper for "dedicated" constraints
This commit is contained in:
parent
e0f33ab60e
commit
231793df71
1 changed files with 18 additions and 3 deletions
21
job.go
21
job.go
|
@ -37,6 +37,15 @@ type Job interface {
|
|||
AddNamedPorts(names ...string) Job
|
||||
AddLimitConstraint(name string, limit int32) Job
|
||||
AddValueConstraint(name string, negated bool, values ...string) Job
|
||||
|
||||
// From Aurora Docs:
|
||||
// dedicated attribute. Aurora treats this specially, and only allows matching jobs
|
||||
// to run on these machines, and will only schedule matching jobs on these machines.
|
||||
// When a job is created, the scheduler requires that the $role component matches
|
||||
// the role field in the job configuration, and will reject the job creation otherwise.
|
||||
// A wildcard (*) may be used for the role portion of the dedicated attribute, which
|
||||
// will allow any owner to elect for a job to run on the host(s)
|
||||
AddDedicatedConstraint(role, name string) Job
|
||||
AddURIs(extract bool, cache bool, values ...string) Job
|
||||
JobKey() *aurora.JobKey
|
||||
JobConfig() *aurora.JobConfiguration
|
||||
|
@ -61,11 +70,11 @@ func NewJob() Job {
|
|||
taskConfig := aurora.NewTaskConfig()
|
||||
jobKey := aurora.NewJobKey()
|
||||
|
||||
//Job Config
|
||||
// Job Config
|
||||
jobConfig.Key = jobKey
|
||||
jobConfig.TaskConfig = taskConfig
|
||||
|
||||
//Task Config
|
||||
// Task Config
|
||||
taskConfig.Job = jobKey
|
||||
taskConfig.Container = aurora.NewContainer()
|
||||
taskConfig.Container.Mesos = aurora.NewMesosContainer()
|
||||
|
@ -73,7 +82,7 @@ func NewJob() Job {
|
|||
taskConfig.Metadata = make(map[*aurora.Metadata]bool)
|
||||
taskConfig.Constraints = make(map[*aurora.Constraint]bool)
|
||||
|
||||
//Resources
|
||||
// Resources
|
||||
numCpus := aurora.NewResource()
|
||||
ramMb := aurora.NewResource()
|
||||
diskMb := aurora.NewResource()
|
||||
|
@ -297,6 +306,12 @@ func (j *AuroraJob) AddLimitConstraint(name string, limit int32) Job {
|
|||
return j
|
||||
}
|
||||
|
||||
func (j *AuroraJob) AddDedicatedConstraint(role, name string) Job {
|
||||
j.AddValueConstraint("dedicated", false, role+"/"+name)
|
||||
|
||||
return j
|
||||
}
|
||||
|
||||
// Set a container to run for the job configuration to run.
|
||||
func (j *AuroraJob) Container(container Container) Job {
|
||||
j.jobConfig.TaskConfig.Container = container.Build()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue