Changing some of the API to allow killing of a single task
Updated AddInstances command to now use InstanceKey allow flexibility Removing line that's not needed
This commit is contained in:
parent
155940c761
commit
07173df33c
3 changed files with 21 additions and 9 deletions
|
@ -58,8 +58,7 @@ Finally, terminate the job:
|
|||
$ go run $GOPATH/src/github.com/rdelval/gorealis.git/examples/client.go -executor=compose -url=http://192.168.33.7:8081 -cmd=kill
|
||||
```
|
||||
|
||||
### Leveraging the library
|
||||
Commands available: create, kill, restart
|
||||
### How to leverage the library (based on the [sample client](examples/client.go))
|
||||
|
||||
Create a default configuration file (alternatively, manually create your own Config):
|
||||
```
|
||||
|
@ -107,7 +106,7 @@ r.RestartJob(job.GetKey())
|
|||
|
||||
Adding instances (based on config of instance 0) to Aurora:
|
||||
```
|
||||
r.AddInstances(job.GetKey(), 5)
|
||||
r.AddInstances(&aurora.InstanceKey{job.GetKey(),0}, 5)
|
||||
```
|
||||
|
||||
Updating the job configuration of a service job:
|
||||
|
@ -126,7 +125,7 @@ msg, err := r.UpdateJob(updateJob, "")
|
|||
|CreateJob | `*Job` | Sends a job create request to Apache Aurora |
|
||||
|KillJob | `*aurora.JobKey` | Attempts to kill all active instances running in Aurora. Only needs environment, role, name |
|
||||
|RestartJob| `*aurora.JobKey` | Attempts to restart all active instances running in Aurora |
|
||||
|AddInstances|`*aurora.JobKey`, `int32`| Launches the specified number of new instances based on existing job config |
|
||||
|AddInstances|`*aurora.InstanceKey`, `int32`| Launches the specified number of new instances based on existing job config |
|
||||
|StartUpdateJob|`*UpdateJob`, `string`| Updates a service job with a new configuration |
|
||||
|AbortUpdateJob|`*aurora.Jobkey`, `string`, `string`| Abort the job update that matches the ID |
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ func main() {
|
|||
break
|
||||
case "flexUp":
|
||||
fmt.Println("Flexing up job")
|
||||
response, err := r.AddInstances(job.JobKey(), 5)
|
||||
response, err := r.AddInstances(&aurora.InstanceKey{job.JobKey(), 0}, 5)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
|
|
21
realis.go
21
realis.go
|
@ -110,6 +110,22 @@ func (r *Realis) getActiveTaskIds(key *aurora.JobKey) (map[int32]bool, error) {
|
|||
return jobTaskIds, nil
|
||||
}
|
||||
|
||||
|
||||
func (r *Realis) KillTask(key *aurora.JobKey, taskId int32) {
|
||||
|
||||
taskIds := make(map[int32]bool)
|
||||
taskIds[taskId] = true
|
||||
|
||||
response, err := r.client.KillTasks(key, taskIds)
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Error sending Kill command to Aurora Scheduler.")
|
||||
}
|
||||
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
// Sends a kill message to the scheduler for all active tasks under a job
|
||||
func (r *Realis) KillJob(key *aurora.JobKey) (*aurora.Response, error) {
|
||||
|
||||
|
@ -190,10 +206,7 @@ func (r *Realis) AbortJobUpdate(
|
|||
}
|
||||
|
||||
// Scale up the number of instances under a job configuration
|
||||
func (r *Realis) AddInstances(key *aurora.JobKey, count int32) (*aurora.Response, error) {
|
||||
|
||||
//Scale up using the config from task 0. All tasks should be homogeneous.
|
||||
instKey := &aurora.InstanceKey{key, 0}
|
||||
func (r *Realis) AddInstances(instKey *aurora.InstanceKey, count int32) (*aurora.Response, error) {
|
||||
|
||||
response, err := r.client.AddInstances(instKey, count)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue