Run thermos jobs using json client.
Added an extra field to JobJson, ExecutorDataFile, that holds the path to the json file representing the executor configuration data. Added a new example job json file (examples/job_thermos.json) that is to be passed to the json client along with the config file to run a thermos job.
This commit is contained in:
parent
67ec630430
commit
db69f0268d
2 changed files with 45 additions and 10 deletions
11
examples/job_thermos.json
Normal file
11
examples/job_thermos.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"name": "hello_world_from_gorealis",
|
||||||
|
"cpu": 1.0,
|
||||||
|
"ram_mb": 64,
|
||||||
|
"disk_mb": 100,
|
||||||
|
"executor": "thermos",
|
||||||
|
"execDataFile": "examples/thermos_payload.json",
|
||||||
|
"service": true,
|
||||||
|
"ports": 1,
|
||||||
|
"instances": 1
|
||||||
|
}
|
|
@ -30,16 +30,17 @@ type URIJson struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type JobJson struct {
|
type JobJson struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
CPU float64 `json:"cpu"`
|
CPU float64 `json:"cpu"`
|
||||||
RAM int64 `json:"ram_mb"`
|
RAM int64 `json:"ram_mb"`
|
||||||
Disk int64 `json:"disk_mb"`
|
Disk int64 `json:"disk_mb"`
|
||||||
Executor string `json:"executor"`
|
Executor string `json:"executor"`
|
||||||
Instances int32 `json:"instances"`
|
ExecutorDataFile string `json:"execDataFile,omitempty"`
|
||||||
URIs []URIJson `json:"uris"`
|
Instances int32 `json:"instances"`
|
||||||
Labels map[string]string `json:"labels"`
|
URIs []URIJson `json:"uris"`
|
||||||
Service bool `json:"service"`
|
Labels map[string]string `json:"labels"`
|
||||||
Ports int `json:"ports"`
|
Service bool `json:"service"`
|
||||||
|
Ports int `json:"ports"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *JobJson) Validate() bool {
|
func (j *JobJson) Validate() bool {
|
||||||
|
@ -169,6 +170,29 @@ func main() {
|
||||||
InstanceCount(job.Instances).
|
InstanceCount(job.Instances).
|
||||||
AddPorts(job.Ports)
|
AddPorts(job.Ports)
|
||||||
|
|
||||||
|
// If thermos executor, then reading in the thermos payload.
|
||||||
|
if (job.Executor == aurora.AURORA_EXECUTOR_NAME) || (job.Executor == "thermos") {
|
||||||
|
payload, err := ioutil.ReadFile(job.ExecutorDataFile)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(errors.Wrap(err, "Invalid thermos payload file!"))
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
auroraJob.ExecutorName(aurora.AURORA_EXECUTOR_NAME).
|
||||||
|
ExecutorData(string(payload))
|
||||||
|
} else {
|
||||||
|
auroraJob.ExecutorName(job.Executor)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adding URIs.
|
||||||
|
for _, uri := range uris {
|
||||||
|
auroraJob.AddURIs(uri.Extract, uri.Cache, uri.URI)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adding Labels.
|
||||||
|
for key, value := range labels {
|
||||||
|
auroraJob.AddLabel(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println("Creating Job...")
|
fmt.Println("Creating Job...")
|
||||||
if resp, jobCreationErr := r.CreateJob(auroraJob); jobCreationErr != nil {
|
if resp, jobCreationErr := r.CreateJob(auroraJob); jobCreationErr != nil {
|
||||||
fmt.Println("Error creating Aurora job: ", jobCreationErr)
|
fmt.Println("Error creating Aurora job: ", jobCreationErr)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue