From 0d9b8695833d6095f3fa6c2853464071f2a64191 Mon Sep 17 00:00:00 2001 From: "Mukkavilli, Sunil" Date: Tue, 21 Mar 2017 12:52:29 -0700 Subject: [PATCH 1/2] Updating the client to not use instanceId 0 by default, instead get the instanceId from the list of active Instances --- examples/client.go | 31 ++++++++++++++++++++++++++++--- realis.go | 2 +- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/examples/client.go b/examples/client.go index 23a04a5..e90555b 100644 --- a/examples/client.go +++ b/examples/client.go @@ -282,7 +282,12 @@ func main() { } currInstances := int32(len(live)) fmt.Println("Current num of instances: ", currInstances) - resp, err := r.AddInstances(aurora.InstanceKey{job.JobKey(), 0}, numOfInstances) + var instId int32 + for k := range live{ + instId = k + break + } + resp, err := r.AddInstances(aurora.InstanceKey{job.JobKey(), instId}, numOfInstances) if err != nil { fmt.Println(err) os.Exit(1) @@ -324,7 +329,17 @@ func main() { break case "update": fmt.Println("Updating a job with with more RAM and to 5 instances") - taskConfig, err := r.FetchTaskConfig(aurora.InstanceKey{job.JobKey(), 0}) + live, err := r.GetInstanceIds(job.JobKey(), aurora.ACTIVE_STATES) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + var instId int32 + for k := range live{ + instId = k + break + } + taskConfig, err := r.FetchTaskConfig(aurora.InstanceKey{job.JobKey(), instId}) if err != nil { fmt.Println(err) os.Exit(1) @@ -372,7 +387,17 @@ func main() { break case "taskConfig": fmt.Println("Getting job info") - config, err := r.FetchTaskConfig(aurora.InstanceKey{job.JobKey(), 0}) + live, err := r.GetInstanceIds(job.JobKey(), aurora.ACTIVE_STATES) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + var instId int32 + for k := range live{ + instId = k + break + } + config, err := r.FetchTaskConfig(aurora.InstanceKey{job.JobKey(), instId}) if err != nil { fmt.Println(err) diff --git a/realis.go b/realis.go index 5bd1c0b..c069dc4 100644 --- a/realis.go +++ b/realis.go @@ -327,7 +327,7 @@ func (r *realisClient) AddInstances(instKey aurora.InstanceKey, count int32) (*a return response.ResponseCodeCheck(resp) } -//Scale down the number of instances under a job configuration using the configuratipn of a specific instance +//Scale down the number of instances under a job configuration using the configuration of a specific instance func (r *realisClient) RemoveInstances(key *aurora.JobKey, count int32) (*aurora.Response, error) { instanceIds, err := r.GetInstanceIds(key, aurora.ACTIVE_STATES) if err != nil { From 68d5b9c8fc635f36479e78d634bd7ba7db9b980b Mon Sep 17 00:00:00 2001 From: "Mukkavilli, Sunil" Date: Tue, 18 Apr 2017 16:35:27 -0700 Subject: [PATCH 2/2] Mustn't print the whole config object in logs, just printing the url --- realis.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/realis.go b/realis.go index a604eec..d66a4a2 100644 --- a/realis.go +++ b/realis.go @@ -208,7 +208,7 @@ func NewRealisClient(options ...option) (Realis, error) { fmt.Printf(" updating default backoff : %+v\n", *config.backoff) } - fmt.Printf("gorealis config: %+v\n", config) + fmt.Printf("gorealis config url: %+v\n", config.url) return &realisClient{ config: config, @@ -488,7 +488,7 @@ func (r *realisClient) ReestablishConn() error { fmt.Println(" r.config.url: ", r.config.url) return errors.New(" Missing Data for ReestablishConn ") } - fmt.Printf(" config before return: %+v\n", r.config) + fmt.Printf(" config url before return: %+v\n", r.config.url) return nil }