Bug fix for metadata duplicates as well as un-initialized GPU re… (#103)

* Fix for metadata duplicates as well.
* Fix for un-initialized GPU resource when creating a new job update.
This commit is contained in:
Renan DelValle 2019-03-15 15:10:31 -07:00 committed by GitHub
parent c997b90720
commit f7bd7cc20f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

9
job.go
View file

@ -74,6 +74,7 @@ const (
type AuroraJob struct {
jobConfig *aurora.JobConfiguration
resources map[ResourceType]*aurora.Resource
metadata map[string]*aurora.Metadata
portCount int
}
@ -107,6 +108,7 @@ func NewJob() Job {
return &AuroraJob{
jobConfig: jobConfig,
resources: resources,
metadata: make(map[string]*aurora.Metadata),
portCount: 0,
}
}
@ -243,7 +245,12 @@ func (j *AuroraJob) AddURIs(extract bool, cache bool, values ...string) Job {
// Adds a Mesos label to the job. Note that Aurora will add the
// prefix "org.apache.aurora.metadata." to the beginning of each key.
func (j *AuroraJob) AddLabel(key string, value string) Job {
j.jobConfig.TaskConfig.Metadata = append(j.jobConfig.TaskConfig.Metadata, &aurora.Metadata{Key: key, Value: value})
if _, ok := j.metadata[key]; ok {
j.metadata[key].Value = value
} else {
j.metadata[key] = &aurora.Metadata{Key: key, Value: value}
j.jobConfig.TaskConfig.Metadata = append(j.jobConfig.TaskConfig.Metadata, j.metadata[key])
}
return j
}

View file

@ -96,6 +96,7 @@ func NewUpdateJob(config *aurora.TaskConfig, settings *aurora.JobUpdateSettings)
}
if ptr.NumGpus != nil {
job.resources[GPU] = &aurora.Resource{}
job.resources[GPU].NumGpus = ptr.NumGpus
continue // Guard against Union violations that Go won't enforce
}