diff --git a/container.go b/container.go index 37e7c60..5735ec8 100644 --- a/container.go +++ b/container.go @@ -44,7 +44,10 @@ func (c DockerContainer) Image(image string) DockerContainer { } func (c DockerContainer) AddParameter(name, value string) DockerContainer { - c.container.Parameters = append(c.container.Parameters, &aurora.DockerParameter{name, value}) + c.container.Parameters = append(c.container.Parameters, &aurora.DockerParameter{ + Name: name, + Value: value, + }) return c } @@ -61,7 +64,7 @@ func (c MesosContainer) DockerImage(name, tag string) MesosContainer { c.container.Image = aurora.NewImage() } - c.container.Image.Docker = &aurora.DockerImage{name, tag} + c.container.Image.Docker = &aurora.DockerImage{Name: name, Tag: tag} return c } @@ -70,6 +73,6 @@ func (c MesosContainer) AppcImage(name, imageId string) MesosContainer { c.container.Image = aurora.NewImage() } - c.container.Image.Appc = &aurora.AppcImage{name, imageId} + c.container.Image.Appc = &aurora.AppcImage{Name: name, ImageId: imageId} return c } diff --git a/examples/client.go b/examples/client.go index e94a34a..38e329e 100644 --- a/examples/client.go +++ b/examples/client.go @@ -348,7 +348,12 @@ func main() { instId = k break } - resp, err := r.AddInstances(aurora.InstanceKey{job.JobKey(), instId}, numOfInstances) + resp, err := r.AddInstances(aurora.InstanceKey{ + JobKey: job.JobKey(), + InstanceId: instId, + }, + numOfInstances) + if err != nil { fmt.Println(err) os.Exit(1) @@ -399,7 +404,10 @@ func main() { instId = k break } - taskConfig, err := r.FetchTaskConfig(aurora.InstanceKey{job.JobKey(), instId}) + taskConfig, err := r.FetchTaskConfig(aurora.InstanceKey{ + JobKey: job.JobKey(), + InstanceId: instId, + }) if err != nil { fmt.Println(err) os.Exit(1) @@ -418,7 +426,12 @@ func main() { break case "updateDetails": resp, err := r.JobUpdateDetails(aurora.JobUpdateQuery{ - Key: &aurora.JobUpdateKey{job.JobKey(), updateId}, Limit: 1}) + Key: &aurora.JobUpdateKey{ + Job: job.JobKey(), + ID: updateId, + }, + Limit: 1, + }) if err != nil { fmt.Println(err) @@ -428,7 +441,12 @@ func main() { break case "abortUpdate": fmt.Println("Abort update") - resp, err := r.AbortJobUpdate(aurora.JobUpdateKey{job.JobKey(), updateId}, "") + resp, err := r.AbortJobUpdate(aurora.JobUpdateKey{ + Job: job.JobKey(), + ID: updateId, + }, + "") + if err != nil { fmt.Println(err) os.Exit(1) @@ -437,7 +455,12 @@ func main() { break case "rollbackUpdate": fmt.Println("Abort update") - resp, err := r.RollbackJobUpdate(aurora.JobUpdateKey{job.JobKey(), updateId}, "") + resp, err := r.RollbackJobUpdate(aurora.JobUpdateKey{ + Job: job.JobKey(), + ID: updateId, + }, + "") + if err != nil { fmt.Println(err) os.Exit(1) @@ -456,7 +479,10 @@ func main() { instId = k break } - config, err := r.FetchTaskConfig(aurora.InstanceKey{job.JobKey(), instId}) + config, err := r.FetchTaskConfig(aurora.InstanceKey{ + JobKey: job.JobKey(), + InstanceId: instId, + }) if err != nil { fmt.Println(err) @@ -478,7 +504,8 @@ func main() { fmt.Println(updatesummary) case "taskStatus": fmt.Println("Getting task status") - taskQ := &aurora.TaskQuery{Role: job.JobKey().Role, + taskQ := &aurora.TaskQuery{ + Role: job.JobKey().Role, Environment: job.JobKey().Environment, JobName: job.JobKey().Name, } @@ -491,7 +518,8 @@ func main() { fmt.Printf("tasks: %+v\n", tasks) case "tasksWithoutConfig": fmt.Println("Getting task status") - taskQ := &aurora.TaskQuery{Role: job.JobKey().Role, + taskQ := &aurora.TaskQuery{ + Role: job.JobKey().Role, Environment: job.JobKey().Environment, JobName: job.JobKey().Name, } diff --git a/job.go b/job.go index 1173e3f..bc699c2 100644 --- a/job.go +++ b/job.go @@ -91,7 +91,11 @@ func NewJob() Job { ramMb.RamMb = new(int64) diskMb.DiskMb = new(int64) - return &AuroraJob{jobConfig, resources, 0} + return &AuroraJob{ + jobConfig: jobConfig, + resources: resources, + portCount: 0, + } } // Set Job Key environment. @@ -105,7 +109,7 @@ func (j *AuroraJob) Role(role string) Job { j.jobConfig.Key.Role = role //Will be deprecated - identity := &aurora.Identity{role} + identity := &aurora.Identity{User: role} j.jobConfig.Owner = identity j.jobConfig.TaskConfig.Owner = identity return j @@ -211,9 +215,11 @@ func (j *AuroraJob) TaskConfig() *aurora.TaskConfig { // --enable_mesos_fetcher flag enabled. Currently there is no duplicate detection. func (j *AuroraJob) AddURIs(extract bool, cache bool, values ...string) Job { for _, value := range values { - j.jobConfig. - TaskConfig. - MesosFetcherUris[&aurora.MesosFetcherURI{value, &extract, &cache}] = true + j.jobConfig.TaskConfig.MesosFetcherUris[&aurora.MesosFetcherURI{ + Value: value, + Extract: &extract, + Cache: &cache, + }] = true } return j } @@ -221,7 +227,7 @@ 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[&aurora.Metadata{key, value}] = true + j.jobConfig.TaskConfig.Metadata[&aurora.Metadata{Key: key, Value: value}] = true return j } @@ -261,8 +267,16 @@ func (j *AuroraJob) AddValueConstraint(name string, negated bool, values ...stri for _, value := range values { constraintValues[value] = true } - j.jobConfig.TaskConfig.Constraints[&aurora.Constraint{name, - &aurora.TaskConstraint{&aurora.ValueConstraint{negated, constraintValues}, nil}}] = true + j.jobConfig.TaskConfig.Constraints[&aurora.Constraint{ + Name: name, + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: negated, + Values: constraintValues, + }, + Limit: nil, + }, + }] = true return j } @@ -271,8 +285,13 @@ func (j *AuroraJob) AddValueConstraint(name string, negated bool, values ...stri // A constraint that specifies the maximum number of active tasks on a host with // a matching attribute that may be scheduled simultaneously. func (j *AuroraJob) AddLimitConstraint(name string, limit int32) Job { - j.jobConfig.TaskConfig.Constraints[&aurora.Constraint{name, - &aurora.TaskConstraint{nil, &aurora.LimitConstraint{limit}}}] = true + j.jobConfig.TaskConfig.Constraints[&aurora.Constraint{ + Name: name, + Constraint: &aurora.TaskConstraint{ + Value: nil, + Limit: &aurora.LimitConstraint{Limit: limit}, + }, + }] = true return j } diff --git a/realis.go b/realis.go index 5bf4436..6e55948 100644 --- a/realis.go +++ b/realis.go @@ -297,7 +297,8 @@ func Jitter(duration time.Duration, maxFactor float64) time.Duration { } func GetDefaultClusterFromZKUrl(zkurl string) *Cluster { - return &Cluster{Name: "defaultCluster", + return &Cluster{ + Name: "defaultCluster", AuthMechanism: "UNAUTHENTICATED", ZK: zkurl, SchedZKPath: "/aurora/scheduler", @@ -506,10 +507,12 @@ func (r *realisClient) Close() { // Uses predefined set of states to retrieve a set of active jobs in Apache Aurora. func (r *realisClient) GetInstanceIds(key *aurora.JobKey, states map[aurora.ScheduleStatus]bool) (map[int32]bool, error) { - taskQ := &aurora.TaskQuery{Role: key.Role, + taskQ := &aurora.TaskQuery{ + Role: key.Role, Environment: key.Environment, JobName: key.Name, - Statuses: states} + Statuses: states, + } var resp *aurora.Response var clientErr error @@ -977,11 +980,13 @@ func (r *realisClient) FetchTaskConfig(instKey aurora.InstanceKey) (*aurora.Task ids := make(map[int32]bool) ids[instKey.InstanceId] = true - taskQ := &aurora.TaskQuery{Role: instKey.JobKey.Role, + taskQ := &aurora.TaskQuery{ + Role: instKey.JobKey.Role, Environment: instKey.JobKey.Environment, JobName: instKey.JobKey.Name, InstanceIds: ids, - Statuses: aurora.ACTIVE_STATES} + Statuses: aurora.ACTIVE_STATES, + } var resp *aurora.Response var clientErr error diff --git a/realis_e2e_test.go b/realis_e2e_test.go index 30f42c9..7e3af92 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -45,7 +45,7 @@ func TestMain(m *testing.M) { } // Create monitor - monitor = &realis.Monitor{r} + monitor = &realis.Monitor{Client: r} thermosPayload, err = ioutil.ReadFile("examples/thermos_payload.json") if err != nil { diff --git a/updatejob.go b/updatejob.go index 502f54f..bffe285 100644 --- a/updatejob.go +++ b/updatejob.go @@ -63,7 +63,7 @@ func NewDefaultUpdateJob(config *aurora.TaskConfig) *UpdateJob { req.Settings.RollbackOnFailure = true //TODO(rdelvalle): Deep copy job struct to avoid unexpected behavior - return &UpdateJob{job, req} + return &UpdateJob{Job: job, req: req} } func NewUpdateJob(config *aurora.TaskConfig, settings *aurora.JobUpdateSettings) *UpdateJob { @@ -94,7 +94,7 @@ func NewUpdateJob(config *aurora.TaskConfig, settings *aurora.JobUpdateSettings) } //TODO(rdelvalle): Deep copy job struct to avoid unexpected behavior - return &UpdateJob{job, req} + return &UpdateJob{Job: job, req: req} } // Set instance count the job will have after the update.