Skip to content

Commit 80f49e7

Browse files
author
David Morin
committed
Merge branch 'master' of github.com:ovh/data-processing-spark-submit
2 parents 9c9a1c3 + 614e90d commit 80f49e7

File tree

6 files changed

+29
-1
lines changed

6 files changed

+29
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Options:
7777
--repositories REPOSITORIES
7878
Comma-delimited list of additional repositories (or resolvers in SBT)
7979
--properties-file Read properties from the given file
80+
--ttl Maximum "Time To Live" (in RFC3339 (duration) eg. "P1DT30H4S") of this job, after which it will be automatically terminated
8081
--help, -h display this help and exit
8182
8283

data_processing.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type (
6161
EngineVersion string `json:"engineVersion"`
6262
EngineParameters []*JobEngineParameter `json:"engineParameters"`
6363
Status string `json:"status"`
64+
Ttl string `json:"ttl"`
6465
}
6566

6667
// JobEngineParameter representation of JobEngineParameter in OVH API
@@ -89,6 +90,7 @@ type (
8990
Engine string `json:"engine"`
9091
Name string `json:"name"`
9192
Region string `json:"region"`
93+
Ttl string `json:"ttl,omitempty"`
9294
EngineVersion string `json:"engineVersion"`
9395
EngineParameters []*JobEngineParameter `json:"engineParameters"`
9496
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/gabriel-vasile/mimetype v1.1.0
1010
github.com/ncw/swift v1.0.52
1111
github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014
12+
github.com/peterhellberg/duration v0.0.0-20191119133758-ec6baeebcd10
1213
github.com/smartystreets/goconvey v1.6.4 // indirect
1314
gopkg.in/ini.v1 v1.55.0
1415
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ github.com/ncw/swift v1.0.52 h1:ACF3JufDGgeKp/9mrDgQlEgS8kRYC4XKcuzj/8EJjQU=
1818
github.com/ncw/swift v1.0.52/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM=
1919
github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014 h1:37VE5TYj2m/FLA9SNr4z0+A0JefvTmR60Zwf8XSEV7c=
2020
github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014/go.mod h1:joRatxRJaZBsY3JAOEMcoOp05CnZzsx4scTxi95DHyQ=
21+
github.com/peterhellberg/duration v0.0.0-20191119133758-ec6baeebcd10 h1:Jf08dx6hxr6aNpHzUmYitsKGm6BmCFbwDGPb27/Boyc=
22+
github.com/peterhellberg/duration v0.0.0-20191119133758-ec6baeebcd10/go.mod h1:x5xjkH61fUOJVgCCDgqNzlJvdLXiYpmMzSuum2FBOaw=
2123
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2224
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2325
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=

submit.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
"github.com/Pallinder/go-randomdata"
1818
"github.com/alexflint/go-arg"
19+
"github.com/peterhellberg/duration"
1920
"github.com/ovh/go-ovh/ovh"
2021
"gopkg.in/ini.v1"
2122
)
@@ -42,6 +43,7 @@ var (
4243
Packages string `arg:"--packages" help:"Comma-delimited list of Maven coordinates"`
4344
Repositories string `arg:"--repositories" help:"Comma-delimited list of additional repositories (or resolvers in SBT)"`
4445
PropertiesFile string `arg:"--properties-file" help:"Read properties from the given file"`
46+
Ttl string `arg:"--ttl" help:"Maximum \"Time To Live\" (in RFC3339 (duration) eg. "P1DT30H4S") of this job, after which it will be automatically terminated"`
4547
File string `arg:"positional,required"`
4648
Parameters []string `arg:"positional"`
4749
}
@@ -157,6 +159,7 @@ func ParsArgs() *JobSubmit {
157159
Region: args.Region,
158160
EngineVersion: args.SparkVersion,
159161
EngineParameters: []*JobEngineParameter{},
162+
Ttl: args.Ttl,
160163
}
161164

162165
if args.JobName == "" {
@@ -255,6 +258,13 @@ func ParsArgs() *JobSubmit {
255258
})
256259
}
257260

261+
if args.Ttl != "" {
262+
_, err := duration.Parse(args.Ttl);
263+
if err != nil {
264+
p.Fail("Invalid value for --ttl. It must be in RFC3339 (duration) format (i.e. PT30H for 30 hours)")
265+
}
266+
}
267+
258268
jobSubmit.EngineParameters = append(jobSubmit.EngineParameters, &JobEngineParameter{
259269
Name: ParameterExecutorNumber,
260270
Value: args.ExecutorNum,

submit_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ func TestParsArgsJava(t *testing.T) {
2828
t.Fail()
2929
}
3030

31+
if job.Ttl != "" {
32+
t.Fail()
33+
}
34+
3135
if args.ProjectID != "1377b21260f05b410e4652445ac7c95b" {
3236
t.Fail()
3337
}
@@ -86,6 +90,10 @@ func TestParsArgsPython(t *testing.T) {
8690
t.Fail()
8791
}
8892

93+
if job.Ttl != "" {
94+
t.Fail()
95+
}
96+
8997
if args.ProjectID != "1377b21260f05b410e4652445ac7c95b" {
9098
t.Fail()
9199
}
@@ -125,7 +133,7 @@ func TestParsArgsPython(t *testing.T) {
125133
func TestParsArgs3(t *testing.T) {
126134
// These are the args you would pass in on the command line
127135
os.Setenv("OS_PROJECT_ID", "1377b21260f05b410e4652445ac7c95b")
128-
os.Args = strings.Split("./ovh-spark-submit --class org.apache.spark.examples.SparkPi --driver-cores 1 --driver-memory 4G --driver-memoryOverhead 385M --executor-cores 1 --executor-memory 1G --executor-memoryOverhead 385M --num-executors 1 s3://odp/test/spark-examples.jar 1000", " ")
136+
os.Args = strings.Split("./ovh-spark-submit --class org.apache.spark.examples.SparkPi --driver-cores 1 --driver-memory 4G --driver-memoryOverhead 385M --executor-cores 1 --executor-memory 1G --executor-memoryOverhead 385M --num-executors 1 --ttl P1DT30H4S s3://odp/test/spark-examples.jar 1000", " ")
129137

130138
job := ParsArgs()
131139

@@ -144,6 +152,10 @@ func TestParsArgs3(t *testing.T) {
144152
t.Fail()
145153
}
146154

155+
if job.Ttl != "P1DT30H4S" {
156+
t.Fail()
157+
}
158+
147159
if args.ProjectID != "1377b21260f05b410e4652445ac7c95b" {
148160
t.Fail()
149161
}

0 commit comments

Comments
 (0)