marathon-api 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +11 -6
  4. data/bin/marathon +49 -41
  5. data/fixtures/vcr/Marathon/_info/returns_the_info_hash.yml +10 -2
  6. data/fixtures/vcr/Marathon/_ping/ping/.yml +7 -1
  7. data/fixtures/vcr/Marathon_App/_changes/changes_the_app.yml +21 -5
  8. data/fixtures/vcr/Marathon_App/_changes/fails_with_stange_attributes.yml +8 -2
  9. data/fixtures/vcr/Marathon_App/_delete/deletes_the_app.yml +11 -3
  10. data/fixtures/vcr/Marathon_App/_delete/fails_deleting_not_existing_app.yml +9 -1
  11. data/fixtures/vcr/Marathon_App/_get/fails_getting_not_existing_app.yml +9 -1
  12. data/fixtures/vcr/Marathon_App/_get/gets_the_app.yml +10 -2
  13. data/fixtures/vcr/Marathon_App/_list/lists_apps.yml +11 -4
  14. data/fixtures/vcr/Marathon_App/_restart/fails_restarting_not_existing_app.yml +9 -1
  15. data/fixtures/vcr/Marathon_App/_restart/restarts_an_app.yml +9 -3
  16. data/fixtures/vcr/Marathon_App/_start/fails_getting_not_existing_app.yml +9 -1
  17. data/fixtures/vcr/Marathon_App/_start/starts_the_app.yml +12 -4
  18. data/fixtures/vcr/Marathon_App/_version/gets_a_version.yml +19 -7
  19. data/fixtures/vcr/Marathon_App/_versions/gets_versions.yml +9 -3
  20. data/fixtures/vcr/Marathon_Deployment/_delete/cleans_app_from_marathon.yml +38 -0
  21. data/fixtures/vcr/Marathon_Deployment/_delete/deletes_deployments.yml +20 -8
  22. data/fixtures/vcr/Marathon_Deployment/_list/lists_deployments.yml +34 -14
  23. data/fixtures/vcr/Marathon_EventSubscriptions/_list/lists_callbacks.yml +10 -2
  24. data/fixtures/vcr/Marathon_EventSubscriptions/_register/registers_callback.yml +10 -2
  25. data/fixtures/vcr/Marathon_EventSubscriptions/_unregister/unregisters_callback.yml +10 -2
  26. data/fixtures/vcr/Marathon_Group/_changes/changes_the_group.yml +20 -8
  27. data/fixtures/vcr/Marathon_Group/_changes/previews_changes.yml +38 -0
  28. data/fixtures/vcr/Marathon_Group/_delete/deletes_the_group.yml +9 -3
  29. data/fixtures/vcr/Marathon_Group/_delete/fails_deleting_not_existing_app.yml +8 -2
  30. data/fixtures/vcr/Marathon_Group/_get/fails_getting_not_existing_app.yml +8 -2
  31. data/fixtures/vcr/Marathon_Group/_get/gets_the_group.yml +9 -3
  32. data/fixtures/vcr/Marathon_Group/_list/lists_apps.yml +12 -4
  33. data/fixtures/vcr/Marathon_Group/_start/fails_getting_not_existing_group.yml +8 -2
  34. data/fixtures/vcr/Marathon_Group/_start/starts_the_group.yml +9 -3
  35. data/fixtures/vcr/Marathon_Leader/_delete/delete/.yml +9 -1
  36. data/fixtures/vcr/Marathon_Leader/_get/get/.yml +10 -2
  37. data/fixtures/vcr/Marathon_Queue/_list/lists_queue.yml +9 -4
  38. data/fixtures/vcr/Marathon_Task/_delete/kills_a_tasks_of_an_app.yml +26 -10
  39. data/fixtures/vcr/Marathon_Task/_delete_all/kills_all_tasks_of_an_app.yml +10 -2
  40. data/fixtures/vcr/Marathon_Task/_get/gets_tasks_of_an_app.yml +10 -2
  41. data/fixtures/vcr/Marathon_Task/_list/lists_running_tasks.yml +10 -2
  42. data/fixtures/vcr/Marathon_Task/_list/lists_tasks.yml +10 -2
  43. data/lib/marathon/deployment.rb +5 -2
  44. data/lib/marathon/deployment_action.rb +23 -0
  45. data/lib/marathon/deployment_info.rb +17 -1
  46. data/lib/marathon/deployment_step.rb +21 -0
  47. data/lib/marathon/error.rb +1 -1
  48. data/lib/marathon/group.rb +13 -5
  49. data/lib/marathon/task.rb +7 -9
  50. data/lib/marathon/version.rb +1 -1
  51. data/lib/marathon.rb +2 -0
  52. data/spec/marathon/app_spec.rb +5 -7
  53. data/spec/marathon/deployment_action_spec.rb +25 -0
  54. data/spec/marathon/deployment_info_spec.rb +10 -1
  55. data/spec/marathon/deployment_spec.rb +7 -3
  56. data/spec/marathon/deployment_step_spec.rb +32 -0
  57. data/spec/marathon/event_subscriptions_spec.rb +2 -2
  58. data/spec/marathon/group_spec.rb +31 -19
  59. data/spec/marathon/leader_spec.rb +2 -4
  60. data/spec/marathon/queue_spec.rb +1 -2
  61. data/spec/marathon/task_spec.rb +4 -10
  62. metadata +10 -3
  63. data/fixtures/vcr/Marathon_App/_tasks/has_tasks.yml +0 -30
@@ -12,12 +12,18 @@ http_interactions:
12
12
  Accept:
13
13
  - application/json
14
14
  User-Agent:
15
- - ub0r/Marathon-API 0.9.0
15
+ - ub0r/Marathon-API 1.1.0
16
16
  response:
17
17
  status:
18
18
  code: 200
19
19
  message: OK
20
20
  headers:
21
+ Cache-Control:
22
+ - no-cache, no-store, must-revalidate
23
+ Pragma:
24
+ - no-cache
25
+ Expires:
26
+ - '0'
21
27
  Content-Type:
22
28
  - application/json
23
29
  Transfer-Encoding:
@@ -26,8 +32,10 @@ http_interactions:
26
32
  - Jetty(8.y.z-SNAPSHOT)
27
33
  body:
28
34
  encoding: UTF-8
29
- string: '{"id":"/","apps":[],"groups":[{"id":"/ubuntu2","apps":[],"groups":[],"dependencies":[],"version":"2015-03-09T10:33:39.889Z"},{"id":"/test-group","apps":[{"id":"/test-group/app","cmd":"sleep
30
- 30","args":null,"user":null,"env":{},"instances":1,"cpus":1.0,"mem":128.0,"disk":0.0,"executor":"","constraints":[],"uris":[],"storeUrls":[],"ports":[10000],"requirePorts":false,"backoffSeconds":1,"backoffFactor":1.15,"maxLaunchDelaySeconds":3600,"container":null,"healthChecks":[],"dependencies":[],"upgradeStrategy":{"minimumHealthCapacity":1.0,"maximumOverCapacity":0.0},"labels":{},"version":"2015-03-09T10:33:39.889Z"}],"groups":[],"dependencies":[],"version":"2015-03-09T10:33:39.889Z"}],"dependencies":[],"version":"2015-03-09T10:33:39.889Z"}'
35
+ string: '{"id":"/","apps":[{"id":"/ubuntu","cmd":"while sleep 10; do date -u
36
+ +%T; done","args":null,"user":null,"env":{},"instances":1,"cpus":0.1,"mem":64.0,"disk":0.0,"executor":"","constraints":[],"uris":[],"storeUrls":[],"ports":[],"requirePorts":false,"backoffSeconds":1,"backoffFactor":1.15,"maxLaunchDelaySeconds":3600,"container":{"type":"DOCKER","volumes":[],"docker":{"image":"libmesos/ubuntu","network":null,"portMappings":null,"privileged":false,"parameters":[]}},"healthChecks":[],"dependencies":[],"upgradeStrategy":{"minimumHealthCapacity":1.0,"maximumOverCapacity":1.0},"labels":{},"version":"2015-03-17T11:56:26.532Z"},{"id":"/ubuntu2","cmd":"while
37
+ sleep 10; do date -u +%T; done","args":null,"user":null,"env":{},"instances":2,"cpus":0.1,"mem":64.0,"disk":0.0,"executor":"","constraints":[["hostname","GROUP_BY"]],"uris":[],"storeUrls":[],"ports":[],"requirePorts":false,"backoffSeconds":1,"backoffFactor":1.15,"maxLaunchDelaySeconds":3600,"container":{"type":"DOCKER","volumes":[],"docker":{"image":"libmesos/ubuntu","network":null,"portMappings":null,"privileged":false,"parameters":[]}},"healthChecks":[],"dependencies":[],"upgradeStrategy":{"minimumHealthCapacity":1.0,"maximumOverCapacity":1.0},"labels":{},"version":"2015-03-17T13:05:44.561Z"}],"groups":[{"id":"/test","apps":[],"groups":[],"dependencies":[],"version":"2015-03-17T13:06:07.888Z"},{"id":"/develop-ci","apps":[],"groups":[{"id":"/develop-ci/ops","apps":[],"groups":[],"dependencies":[],"version":"2015-03-17T13:06:07.888Z"}],"dependencies":[],"version":"2015-03-17T13:06:07.888Z"},{"id":"/spark","apps":[],"groups":[],"dependencies":[],"version":"2015-03-17T13:06:07.888Z"},{"id":"/test-group","apps":[{"id":"/test-group/app","cmd":"sleep
38
+ 30","args":null,"user":null,"env":{},"instances":1,"cpus":1.0,"mem":128.0,"disk":0.0,"executor":"","constraints":[],"uris":[],"storeUrls":[],"ports":[10000],"requirePorts":false,"backoffSeconds":1,"backoffFactor":1.15,"maxLaunchDelaySeconds":3600,"container":null,"healthChecks":[],"dependencies":[],"upgradeStrategy":{"minimumHealthCapacity":1.0,"maximumOverCapacity":0.0},"labels":{},"version":"2015-03-17T13:06:07.888Z"}],"groups":[],"dependencies":[],"version":"2015-03-17T13:06:07.888Z"}],"dependencies":[],"version":"2015-03-17T13:06:07.888Z"}'
31
39
  http_version:
32
- recorded_at: Mon, 09 Mar 2015 10:33:40 GMT
40
+ recorded_at: Tue, 17 Mar 2015 13:06:08 GMT
33
41
  recorded_with: VCR 2.9.3
@@ -12,12 +12,18 @@ http_interactions:
12
12
  Accept:
13
13
  - application/json
14
14
  User-Agent:
15
- - ub0r/Marathon-API 0.9.0
15
+ - ub0r/Marathon-API 1.1.0
16
16
  response:
17
17
  status:
18
18
  code: 404
19
19
  message: Not Found
20
20
  headers:
21
+ Cache-Control:
22
+ - no-cache, no-store, must-revalidate
23
+ Pragma:
24
+ - no-cache
25
+ Expires:
26
+ - '0'
21
27
  Content-Type:
22
28
  - application/json
23
29
  Transfer-Encoding:
@@ -28,5 +34,5 @@ http_interactions:
28
34
  encoding: UTF-8
29
35
  string: '{"message":"Group ''/fooo group'' does not exist"}'
30
36
  http_version:
31
- recorded_at: Mon, 09 Mar 2015 10:33:40 GMT
37
+ recorded_at: Tue, 17 Mar 2015 13:06:08 GMT
32
38
  recorded_with: VCR 2.9.3
@@ -13,12 +13,18 @@ http_interactions:
13
13
  Accept:
14
14
  - application/json
15
15
  User-Agent:
16
- - ub0r/Marathon-API 0.9.0
16
+ - ub0r/Marathon-API 1.1.0
17
17
  response:
18
18
  status:
19
19
  code: 201
20
20
  message: Created
21
21
  headers:
22
+ Cache-Control:
23
+ - no-cache, no-store, must-revalidate
24
+ Pragma:
25
+ - no-cache
26
+ Expires:
27
+ - '0'
22
28
  Location:
23
29
  - http://localhost:8080/v2/groups/test-group
24
30
  Content-Type:
@@ -29,7 +35,7 @@ http_interactions:
29
35
  - Jetty(8.y.z-SNAPSHOT)
30
36
  body:
31
37
  encoding: UTF-8
32
- string: '{"version":"2015-03-09T10:33:39.889Z","deploymentId":"ad618509-e8ee-4949-8267-ef35a619426f"}'
38
+ string: '{"version":"2015-03-17T13:06:07.888Z","deploymentId":"b8ec8dda-f910-4339-9aff-fde4b7da31d4"}'
33
39
  http_version:
34
- recorded_at: Mon, 09 Mar 2015 10:33:40 GMT
40
+ recorded_at: Tue, 17 Mar 2015 13:06:08 GMT
35
41
  recorded_with: VCR 2.9.3
@@ -11,11 +11,19 @@ http_interactions:
11
11
  - application/json
12
12
  Accept:
13
13
  - application/json
14
+ User-Agent:
15
+ - ub0r/Marathon-API 1.1.0
14
16
  response:
15
17
  status:
16
18
  code: 200
17
19
  message: OK
18
20
  headers:
21
+ Cache-Control:
22
+ - no-cache, no-store, must-revalidate
23
+ Pragma:
24
+ - no-cache
25
+ Expires:
26
+ - '0'
19
27
  Content-Type:
20
28
  - application/json
21
29
  Transfer-Encoding:
@@ -26,5 +34,5 @@ http_interactions:
26
34
  encoding: UTF-8
27
35
  string: '{"message":"Leadership abdicted"}'
28
36
  http_version:
29
- recorded_at: Mon, 02 Mar 2015 10:49:28 GMT
37
+ recorded_at: Tue, 17 Mar 2015 13:06:09 GMT
30
38
  recorded_with: VCR 2.9.3
@@ -11,11 +11,19 @@ http_interactions:
11
11
  - application/json
12
12
  Accept:
13
13
  - application/json
14
+ User-Agent:
15
+ - ub0r/Marathon-API 1.1.0
14
16
  response:
15
17
  status:
16
18
  code: 200
17
19
  message: OK
18
20
  headers:
21
+ Cache-Control:
22
+ - no-cache, no-store, must-revalidate
23
+ Pragma:
24
+ - no-cache
25
+ Expires:
26
+ - '0'
19
27
  Content-Type:
20
28
  - application/json
21
29
  Transfer-Encoding:
@@ -24,7 +32,7 @@ http_interactions:
24
32
  - Jetty(8.y.z-SNAPSHOT)
25
33
  body:
26
34
  encoding: UTF-8
27
- string: '{"leader":"mesos:8080"}'
35
+ string: '{"leader":"mesos-dev-f999998.lhotse.ov.otto.de:8080"}'
28
36
  http_version:
29
- recorded_at: Mon, 02 Mar 2015 10:49:28 GMT
37
+ recorded_at: Tue, 17 Mar 2015 13:06:09 GMT
30
38
  recorded_with: VCR 2.9.3
@@ -12,12 +12,18 @@ http_interactions:
12
12
  Accept:
13
13
  - application/json
14
14
  User-Agent:
15
- - ub0r/Marathon-API 0.8.0
15
+ - ub0r/Marathon-API 1.1.0
16
16
  response:
17
17
  status:
18
18
  code: 200
19
19
  message: OK
20
20
  headers:
21
+ Cache-Control:
22
+ - no-cache, no-store, must-revalidate
23
+ Pragma:
24
+ - no-cache
25
+ Expires:
26
+ - '0'
21
27
  Content-Type:
22
28
  - application/json
23
29
  Transfer-Encoding:
@@ -26,8 +32,7 @@ http_interactions:
26
32
  - Jetty(8.y.z-SNAPSHOT)
27
33
  body:
28
34
  encoding: UTF-8
29
- string: '{"queue":[{"app":{"id":"/test","cmd":"sleep 10","args":null,"user":null,"env":{},"instances":1,"cpus":0.1,"mem":32.0,"disk":0.0,"executor":"","constraints":[],"uris":[],"storeUrls":[],"ports":[10002],"requirePorts":false,"backoffSeconds":1,"backoffFactor":1.15,"maxLaunchDelaySeconds":3600,"container":null,"healthChecks":[],"dependencies":[],"upgradeStrategy":{"minimumHealthCapacity":1.0,"maximumOverCapacity":1.0},"labels":{},"version":"2015-03-04T16:34:16.561Z"},"count":0},{"app":{"id":"/ubuntu2","cmd":"while
30
- sleep 10; do date -u +%T; done","args":null,"user":null,"env":{},"instances":1,"cpus":0.1,"mem":64.0,"disk":0.0,"executor":"","constraints":[],"uris":[],"storeUrls":[],"ports":[10001],"requirePorts":false,"backoffSeconds":1,"backoffFactor":1.15,"maxLaunchDelaySeconds":3600,"container":{"type":"DOCKER","volumes":[],"docker":{"image":"libmesos/ubuntu","network":null,"portMappings":null,"privileged":false,"parameters":[]}},"healthChecks":[],"dependencies":[],"upgradeStrategy":{"minimumHealthCapacity":1.0,"maximumOverCapacity":1.0},"labels":{},"version":"2015-03-04T16:34:15.691Z"},"count":0}]}'
35
+ string: '{"queue":[]}'
31
36
  http_version:
32
- recorded_at: Wed, 04 Mar 2015 18:38:40 GMT
37
+ recorded_at: Tue, 17 Mar 2015 13:06:09 GMT
33
38
  recorded_with: VCR 2.9.3
@@ -11,11 +11,19 @@ http_interactions:
11
11
  - application/json
12
12
  Accept:
13
13
  - application/json
14
+ User-Agent:
15
+ - ub0r/Marathon-API 1.1.0
14
16
  response:
15
17
  status:
16
18
  code: 200
17
19
  message: OK
18
20
  headers:
21
+ Cache-Control:
22
+ - no-cache, no-store, must-revalidate
23
+ Pragma:
24
+ - no-cache
25
+ Expires:
26
+ - '0'
19
27
  Content-Type:
20
28
  - application/json
21
29
  Transfer-Encoding:
@@ -24,34 +32,42 @@ http_interactions:
24
32
  - Jetty(8.y.z-SNAPSHOT)
25
33
  body:
26
34
  encoding: UTF-8
27
- string: '{"tasks":[{"appId":"/ubuntu2","id":"ubuntu2.37fbe1bc-c1d0-11e4-82d4-46b02d3b7f9e","host":"mesos","ports":[31290],"startedAt":"2015-03-03T18:07:57.097Z","stagedAt":"2015-03-03T18:07:56.457Z","version":"2015-03-03T18:07:47.581Z"}]}'
35
+ string: '{"tasks":[{"appId":"/ubuntu2","id":"ubuntu2.52c55930-cca6-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T13:05:46.755Z","stagedAt":"2015-03-17T13:05:45.326Z","version":"2015-03-17T13:05:39.490Z"},{"appId":"/ubuntu2","id":"ubuntu2.57c93911-cca6-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T13:05:55.629Z","stagedAt":"2015-03-17T13:05:53.741Z","version":"2015-03-17T13:05:39.559Z"}]}'
28
36
  http_version:
29
- recorded_at: Tue, 03 Mar 2015 18:08:30 GMT
37
+ recorded_at: Tue, 17 Mar 2015 13:06:10 GMT
30
38
  - request:
31
- method: delete
32
- uri: http://localhost:8080/v2/apps//ubuntu2/tasks/ubuntu2.37fbe1bc-c1d0-11e4-82d4-46b02d3b7f9e
39
+ method: post
40
+ uri: http://localhost:8080/v2/tasks/delete
33
41
  body:
34
- encoding: US-ASCII
35
- string: ''
42
+ encoding: UTF-8
43
+ string: '{"ids":["ubuntu2.52c55930-cca6-11e4-9cfc-080027d9edbf"]}'
36
44
  headers:
37
45
  Content-Type:
38
46
  - application/json
39
47
  Accept:
40
48
  - application/json
49
+ User-Agent:
50
+ - ub0r/Marathon-API 1.1.0
41
51
  response:
42
52
  status:
43
53
  code: 200
44
54
  message: OK
45
55
  headers:
56
+ Cache-Control:
57
+ - no-cache, no-store, must-revalidate
58
+ Pragma:
59
+ - no-cache
60
+ Expires:
61
+ - '0'
46
62
  Content-Type:
47
63
  - application/json
48
- Transfer-Encoding:
49
- - chunked
64
+ Content-Length:
65
+ - '0'
50
66
  Server:
51
67
  - Jetty(8.y.z-SNAPSHOT)
52
68
  body:
53
69
  encoding: UTF-8
54
- string: '{"task":{"id":"ubuntu2.37fbe1bc-c1d0-11e4-82d4-46b02d3b7f9e","host":"mesos","ports":[31290],"startedAt":"2015-03-03T18:07:57.097Z","stagedAt":"2015-03-03T18:07:56.457Z","version":"2015-03-03T18:07:47.581Z"}}'
70
+ string: ''
55
71
  http_version:
56
- recorded_at: Tue, 03 Mar 2015 18:08:30 GMT
72
+ recorded_at: Tue, 17 Mar 2015 13:06:10 GMT
57
73
  recorded_with: VCR 2.9.3
@@ -11,11 +11,19 @@ http_interactions:
11
11
  - application/json
12
12
  Accept:
13
13
  - application/json
14
+ User-Agent:
15
+ - ub0r/Marathon-API 1.1.0
14
16
  response:
15
17
  status:
16
18
  code: 200
17
19
  message: OK
18
20
  headers:
21
+ Cache-Control:
22
+ - no-cache, no-store, must-revalidate
23
+ Pragma:
24
+ - no-cache
25
+ Expires:
26
+ - '0'
19
27
  Content-Type:
20
28
  - application/json
21
29
  Transfer-Encoding:
@@ -24,7 +32,7 @@ http_interactions:
24
32
  - Jetty(8.y.z-SNAPSHOT)
25
33
  body:
26
34
  encoding: UTF-8
27
- string: '{"tasks":[{"id":"ubuntu2.37fbe1bc-c1d0-11e4-82d4-46b02d3b7f9e","host":"mesos","ports":[31290],"startedAt":"2015-03-03T18:07:57.097Z","stagedAt":"2015-03-03T18:07:56.457Z","version":"2015-03-03T18:07:47.581Z"}]}'
35
+ string: '{"tasks":[{"id":"ubuntu2.52c55930-cca6-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T13:05:46.755Z","stagedAt":"2015-03-17T13:05:45.326Z","version":"2015-03-17T13:05:39.490Z"},{"id":"ubuntu2.57c93911-cca6-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T13:05:55.629Z","stagedAt":"2015-03-17T13:05:53.741Z","version":"2015-03-17T13:05:39.559Z"}]}'
28
36
  http_version:
29
- recorded_at: Tue, 03 Mar 2015 18:08:30 GMT
37
+ recorded_at: Tue, 17 Mar 2015 13:06:10 GMT
30
38
  recorded_with: VCR 2.9.3
@@ -11,11 +11,19 @@ http_interactions:
11
11
  - application/json
12
12
  Accept:
13
13
  - application/json
14
+ User-Agent:
15
+ - ub0r/Marathon-API 1.1.0
14
16
  response:
15
17
  status:
16
18
  code: 200
17
19
  message: OK
18
20
  headers:
21
+ Cache-Control:
22
+ - no-cache, no-store, must-revalidate
23
+ Pragma:
24
+ - no-cache
25
+ Expires:
26
+ - '0'
19
27
  Content-Type:
20
28
  - application/json
21
29
  Transfer-Encoding:
@@ -24,7 +32,7 @@ http_interactions:
24
32
  - Jetty(8.y.z-SNAPSHOT)
25
33
  body:
26
34
  encoding: UTF-8
27
- string: '{"tasks":[{"appId":"/ubuntu2","id":"ubuntu2.37fbe1bc-c1d0-11e4-82d4-46b02d3b7f9e","host":"mesos","ports":[31290],"startedAt":"2015-03-03T18:07:57.097Z","stagedAt":"2015-03-03T18:07:56.457Z","version":"2015-03-03T18:07:47.581Z"}]}'
35
+ string: '{"tasks":[{"appId":"/ubuntu2","id":"ubuntu2.52c55930-cca6-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T13:05:46.755Z","stagedAt":"2015-03-17T13:05:45.326Z","version":"2015-03-17T13:05:39.490Z"},{"appId":"/ubuntu2","id":"ubuntu2.57c93911-cca6-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T13:05:55.629Z","stagedAt":"2015-03-17T13:05:53.741Z","version":"2015-03-17T13:05:39.559Z"}]}'
28
36
  http_version:
29
- recorded_at: Tue, 03 Mar 2015 18:08:30 GMT
37
+ recorded_at: Tue, 17 Mar 2015 13:06:10 GMT
30
38
  recorded_with: VCR 2.9.3
@@ -11,11 +11,19 @@ http_interactions:
11
11
  - application/json
12
12
  Accept:
13
13
  - application/json
14
+ User-Agent:
15
+ - ub0r/Marathon-API 1.1.0
14
16
  response:
15
17
  status:
16
18
  code: 200
17
19
  message: OK
18
20
  headers:
21
+ Cache-Control:
22
+ - no-cache, no-store, must-revalidate
23
+ Pragma:
24
+ - no-cache
25
+ Expires:
26
+ - '0'
19
27
  Content-Type:
20
28
  - application/json
21
29
  Transfer-Encoding:
@@ -24,7 +32,7 @@ http_interactions:
24
32
  - Jetty(8.y.z-SNAPSHOT)
25
33
  body:
26
34
  encoding: UTF-8
27
- string: '{"tasks":[{"appId":"/test","id":"test.482155d0-c1d0-11e4-82d4-46b02d3b7f9e","host":"mesos","ports":[31026],"startedAt":"2015-03-03T18:08:24.116Z","stagedAt":"2015-03-03T18:08:23.546Z","version":"2015-03-02T11:30:30.096Z","servicePorts":[10002]},{"appId":"/ubuntu2","id":"ubuntu2.37fbe1bc-c1d0-11e4-82d4-46b02d3b7f9e","host":"mesos","ports":[31290],"startedAt":"2015-03-03T18:07:57.097Z","stagedAt":"2015-03-03T18:07:56.457Z","version":"2015-03-03T18:07:47.581Z","servicePorts":[10001]}]}'
35
+ string: '{"tasks":[{"appId":"/ubuntu","id":"ubuntu.a6c4d769-cc9c-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T11:56:36.225Z","stagedAt":"2015-03-17T11:56:31.284Z","version":"2015-03-17T11:56:26.532Z"},{"appId":"/ubuntu2","id":"ubuntu2.52c55930-cca6-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T13:05:46.755Z","stagedAt":"2015-03-17T13:05:45.326Z","version":"2015-03-17T13:05:39.490Z"},{"appId":"/ubuntu2","id":"ubuntu2.57c93911-cca6-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T13:05:55.629Z","stagedAt":"2015-03-17T13:05:53.741Z","version":"2015-03-17T13:05:39.559Z"}]}'
28
36
  http_version:
29
- recorded_at: Tue, 03 Mar 2015 18:08:30 GMT
37
+ recorded_at: Tue, 17 Mar 2015 13:06:09 GMT
30
38
  recorded_with: VCR 2.9.3
@@ -11,11 +11,19 @@ http_interactions:
11
11
  - application/json
12
12
  Accept:
13
13
  - application/json
14
+ User-Agent:
15
+ - ub0r/Marathon-API 1.1.0
14
16
  response:
15
17
  status:
16
18
  code: 200
17
19
  message: OK
18
20
  headers:
21
+ Cache-Control:
22
+ - no-cache, no-store, must-revalidate
23
+ Pragma:
24
+ - no-cache
25
+ Expires:
26
+ - '0'
19
27
  Content-Type:
20
28
  - application/json
21
29
  Transfer-Encoding:
@@ -24,7 +32,7 @@ http_interactions:
24
32
  - Jetty(8.y.z-SNAPSHOT)
25
33
  body:
26
34
  encoding: UTF-8
27
- string: '{"tasks":[{"appId":"/test","id":"test.482155d0-c1d0-11e4-82d4-46b02d3b7f9e","host":"mesos","ports":[31026],"startedAt":"2015-03-03T18:08:24.116Z","stagedAt":"2015-03-03T18:08:23.546Z","version":"2015-03-02T11:30:30.096Z","servicePorts":[10002]},{"appId":"/ubuntu2","id":"ubuntu2.37fbe1bc-c1d0-11e4-82d4-46b02d3b7f9e","host":"mesos","ports":[31290],"startedAt":"2015-03-03T18:07:57.097Z","stagedAt":"2015-03-03T18:07:56.457Z","version":"2015-03-03T18:07:47.581Z","servicePorts":[10001]}]}'
35
+ string: '{"tasks":[{"appId":"/ubuntu","id":"ubuntu.a6c4d769-cc9c-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T11:56:36.225Z","stagedAt":"2015-03-17T11:56:31.284Z","version":"2015-03-17T11:56:26.532Z"},{"appId":"/ubuntu2","id":"ubuntu2.52c55930-cca6-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T13:05:46.755Z","stagedAt":"2015-03-17T13:05:45.326Z","version":"2015-03-17T13:05:39.490Z"},{"appId":"/ubuntu2","id":"ubuntu2.57c93911-cca6-11e4-9cfc-080027d9edbf","host":"mesos-dev-f999999.lhotse.ov.otto.de","ports":[],"startedAt":"2015-03-17T13:05:55.629Z","stagedAt":"2015-03-17T13:05:53.741Z","version":"2015-03-17T13:05:39.559Z"}]}'
28
36
  http_version:
29
- recorded_at: Tue, 03 Mar 2015 18:08:30 GMT
37
+ recorded_at: Tue, 17 Mar 2015 13:06:09 GMT
30
38
  recorded_with: VCR 2.9.3
@@ -2,13 +2,16 @@
2
2
  # See https://mesosphere.github.io/marathon/docs/rest-api.html#deployments for full list of API's methods.
3
3
  class Marathon::Deployment < Marathon::Base
4
4
 
5
- ACCESSORS = %w[ id affectedApps steps currentActions version currentStep totalSteps ]
5
+ ACCESSORS = %w[ id affectedApps version currentStep totalSteps ]
6
+ attr_reader :steps, :currentActions
6
7
 
7
8
  # Create a new deployment object.
8
9
  # ++hash++: Hash including all attributes.
9
10
  # See https://mesosphere.github.io/marathon/docs/rest-api.html#get-/v2/deployments for full details.
10
11
  def initialize(hash)
11
12
  super(hash, ACCESSORS)
13
+ @currentActions = (info[:currentActions] || []).map { |e| Marathon::DeploymentAction.new(e) }
14
+ @steps = (info[:steps] || []).map { |e| Marathon::DeploymentStep.new(e) }
12
15
  end
13
16
 
14
17
  # Cancel the deployment.
@@ -47,4 +50,4 @@ class Marathon::Deployment < Marathon::Base
47
50
  alias :cancel :delete
48
51
  alias :remove :delete
49
52
  end
50
- end
53
+ end
@@ -0,0 +1,23 @@
1
+ # This class represents a Marathon Deployment action.
2
+ class Marathon::DeploymentAction < Marathon::Base
3
+
4
+ # Create a new deployment action object.
5
+ # ++hash++: Hash returned by API, including 'app' and 'type'
6
+ def initialize(hash)
7
+ super(hash, %w[app])
8
+ end
9
+
10
+ def type
11
+ info[:type] || info[:action]
12
+ end
13
+ alias :action :type
14
+
15
+ def to_pretty_s
16
+ "#{app}/#{type}"
17
+ end
18
+
19
+ def to_s
20
+ "Marathon::DeploymentAction { :app => #{app} :type => #{type} }"
21
+ end
22
+
23
+ end
@@ -1,7 +1,11 @@
1
+ require 'timeout'
2
+
1
3
  # This class represents a Marathon Deployment information.
2
4
  # It is returned by asynchronious deployment calls.
3
5
  class Marathon::DeploymentInfo < Marathon::Base
4
6
 
7
+ RECHECK_INTERVAL = 3
8
+
5
9
  # Create a new deployment info object.
6
10
  # ++hash++: Hash returned by API, including 'deploymentId' and 'version'
7
11
  def initialize(hash)
@@ -9,6 +13,18 @@ class Marathon::DeploymentInfo < Marathon::Base
9
13
  raise Marathon::Error::ArgumentError, 'version must not be nil' unless version
10
14
  end
11
15
 
16
+ # Wait for a deployment to finish.
17
+ # ++timeout++: Timeout in seconds.
18
+ def wait(timeout = 60)
19
+ Timeout::timeout(timeout) do
20
+ deployments = nil
21
+ while deployments.nil? or deployments.select{|e| e.id == deploymentId}.size > 0 do
22
+ sleep(RECHECK_INTERVAL) unless deployments.nil?
23
+ deployments = Marathon::Deployment.list
24
+ end
25
+ end
26
+ end
27
+
12
28
  def to_s
13
29
  if deploymentId
14
30
  "Marathon::DeploymentInfo { :version => #{version} :deploymentId => #{deploymentId} }"
@@ -17,4 +33,4 @@ class Marathon::DeploymentInfo < Marathon::Base
17
33
  end
18
34
  end
19
35
 
20
- end
36
+ end
@@ -0,0 +1,21 @@
1
+ # This class represents a Marathon Deployment step.
2
+ class Marathon::DeploymentStep < Marathon::Base
3
+
4
+ attr_reader :actions
5
+
6
+ # Create a new deployment step object.
7
+ # ++hash++: Hash returned by API, including 'actions'
8
+ def initialize(hash)
9
+ super(hash)
10
+ if hash.is_a?(Array)
11
+ @actions = info.map { |e| Marathon::DeploymentAction.new(e) }
12
+ else
13
+ @actions = (info[:actions] || []).map { |e| Marathon::DeploymentAction.new(e) }
14
+ end
15
+ end
16
+
17
+ def to_s
18
+ "Marathon::DeploymentStep { :actions => #{actions.map{|e| e.to_pretty_s}.join(',')} }"
19
+ end
20
+
21
+ end
@@ -65,4 +65,4 @@ module Marathon::Error
65
65
 
66
66
  module_function :error_class, :error_message, :from_response
67
67
 
68
- end
68
+ end
@@ -17,7 +17,8 @@ class Marathon::Group < Marathon::Base
17
17
  super(Marathon::Util.merge_keywordized_hash(DEFAULTS, hash), ACCESSORS)
18
18
  raise ArgumentError, 'Group must have an id' unless id
19
19
  refresh_attributes
20
- raise ArgumentError, 'Group can have either groups or apps, not both' if apps.size > 0 and groups.size > 0
20
+ raise ArgumentError, 'Group can have either groups or apps, not both' \
21
+ if apps.size > 0 and groups.size > 0 and id != '/'
21
22
  end
22
23
 
23
24
  # Reload attributes from marathon API.
@@ -54,7 +55,8 @@ class Marathon::Group < Marathon::Base
54
55
  # ++hash++: Hash of attributes to change.
55
56
  # ++force++: If the group is affected by a running deployment, then the update operation will fail.
56
57
  # The current deployment can be overridden by setting the `force` query parameter.
57
- def change!(hash, force = false)
58
+ # ++dry_run++: Get a preview of the deployment steps Marathon would run for a given group update.
59
+ def change!(hash, force = false, dry_run = false)
58
60
  Marathon::Util.keywordize_hash!(hash)
59
61
  if hash[:version] and hash.size > 1
60
62
  # remove :version if it's not the only key
@@ -62,7 +64,7 @@ class Marathon::Group < Marathon::Base
62
64
  else
63
65
  new_hash = hash
64
66
  end
65
- self.class.change(id, new_hash, force)
67
+ self.class.change(id, new_hash, force, dry_run)
66
68
  end
67
69
 
68
70
  # Create a new version with parameters of an old version.
@@ -159,11 +161,17 @@ Version: #{version}
159
161
  # ++hash++: Hash of attributes to change.
160
162
  # ++force++: If the group is affected by a running deployment, then the update operation will fail.
161
163
  # The current deployment can be overridden by setting the `force` query parameter.
162
- def change(id, hash, force = false)
164
+ # ++dry_run++: Get a preview of the deployment steps Marathon would run for a given group update.
165
+ def change(id, hash, force = false, dry_run = false)
163
166
  query = {}
164
167
  query[:force] = true if force
168
+ query[:dryRun] = true if dry_run
165
169
  json = Marathon.connection.put("/v2/groups/#{id}", query, :body => hash)
166
- Marathon::DeploymentInfo.new(json)
170
+ if dry_run
171
+ json['steps'].map { |e| Marathon::DeploymentStep.new(e) }
172
+ else
173
+ Marathon::DeploymentInfo.new(json)
174
+ end
167
175
  end
168
176
  end
169
177
  end
data/lib/marathon/task.rb CHANGED
@@ -14,8 +14,7 @@ class Marathon::Task < Marathon::Base
14
14
  # ++scale++: Scale the app down (i.e. decrement its instances setting by the number of tasks killed)
15
15
  # after killing the specified tasks.
16
16
  def delete!(scale = false)
17
- new_task = self.class.delete(appId, id, scale)
18
- @info = new_task.info
17
+ new_task = self.class.delete(id, scale)
19
18
  end
20
19
  alias :kill! :delete!
21
20
 
@@ -55,16 +54,15 @@ Version: #{version}
55
54
  json.map { |j| new(j) }
56
55
  end
57
56
 
58
- # Kill the task that belongs to the application appId.
59
- # ++appId++: Application's id
60
- # ++id++: Id of target task.
57
+ # Kill the given list of tasks and scale apps if requested.
58
+ # ++ids++: Id or list of ids with target tasks.
61
59
  # ++scale++: Scale the app down (i.e. decrement its instances setting by the number of tasks killed)
62
60
  # after killing the specified tasks.
63
- def delete(appId, id, scale = false)
61
+ def delete(ids, scale = false)
64
62
  query = {}
65
63
  query[:scale] = true if scale
66
- json = Marathon.connection.delete("/v2/apps/#{appId}/tasks/#{id}", query)
67
- new(json)
64
+ ids = [ids] if ids.is_a?(String)
65
+ Marathon.connection.post("/v2/tasks/delete", query, :body => {:ids => ids})
68
66
  end
69
67
  alias :remove :delete
70
68
  alias :kill :delete
@@ -85,4 +83,4 @@ Version: #{version}
85
83
  alias :kill_all :delete_all
86
84
  end
87
85
 
88
- end
86
+ end
@@ -1,3 +1,3 @@
1
1
  module Marathon
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
data/lib/marathon.rb CHANGED
@@ -21,6 +21,8 @@ module Marathon
21
21
  require 'marathon/container'
22
22
  require 'marathon/health_check'
23
23
  require 'marathon/deployment_info'
24
+ require 'marathon/deployment_action'
25
+ require 'marathon/deployment_step'
24
26
  require 'marathon/group'
25
27
  require 'marathon/app'
26
28
  require 'marathon/deployment'