marathon_deploy 0.1.49 → 0.1.50

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af24963806cfffb04b82861400c985fca4c9cfaa
4
- data.tar.gz: e4dbe7a9e5d3acb2499ee78d905bc1feb0036fbb
3
+ metadata.gz: f756c9936eefbd912e30c63e7d6f92ced9cbd878
4
+ data.tar.gz: 9850ae0570fa9cd09334bf443ecf1ac2aac5f39a
5
5
  SHA512:
6
- metadata.gz: cf2fe646b04ceb3bc049a2a68afda61c630412ec37974bbaa99796978da30b3c04b42e0da0ce302ecd1fd34a52b0bfae1a1e6d0e1b110293c2fa7df35d6a7794
7
- data.tar.gz: 99d2747a8644b75ea057ca580bdfab2be430501f485b81db6a392c9af42b6c285306443f3a50979d2ae391926e86a9e94874c40eeb8e3fb5e8f97d93358cdfbf
6
+ metadata.gz: 45284e7b60f096f5de4ee4cd7c50717fa7f4080766cba750914033998458642e0451b7968c1f9dee4e82fc08b07ad941327d20473b5f7b392645a4a32bd3e225
7
+ data.tar.gz: 4b19afdcd201eca3d20926532098b2c595d95572c102cd9fe569eb324c2984c821bd97b514974d2c412124bb60c1228c27da75da52cb61297171abd9fd8bb84e
@@ -6,6 +6,7 @@ require 'timeout'
6
6
  module MarathonDeploy
7
7
  class Deployment
8
8
 
9
+ WAIT_FOR_DEPLOYMENT_TIMEOUT = MarathonDefaults::WAIT_FOR_DEPLOYMENT_TIMEOUT
9
10
  DEPLOYMENT_RECHECK_INTERVAL = MarathonDefaults::DEPLOYMENT_RECHECK_INTERVAL
10
11
  DEPLOYMENT_TIMEOUT = MarathonDefaults::DEPLOYMENT_TIMEOUT
11
12
  HEALTHY_WAIT_TIMEOUT = MarathonDefaults::HEALTHY_WAIT_TIMEOUT
@@ -38,16 +39,21 @@ module MarathonDeploy
38
39
  end
39
40
  end
40
41
 
42
+ def wait_for_deployment()
43
+ startTime = Time.now
44
+ Timeout::timeout(WAIT_FOR_DEPLOYMENT_TIMEOUT) do
45
+ while !deployment_running?
46
+ sleep(DEPLOYMENT_RECHECK_INTERVAL)
47
+ $LOG.info("Waiting for Marathon to start deployment")
48
+ end
49
+ end
50
+ end
51
+
41
52
  def wait_for_deployment_id(message = "Deployment with deploymentId #{@deploymentId} in progress")
42
53
  startTime = Time.now
43
54
  deployment_seen = false
44
55
  Timeout::timeout(DEPLOYMENT_TIMEOUT) do
45
- while !deployment_running?
46
- sleep(DEPLOYMENT_RECHECK_INTERVAL)
47
- $LOG.info("Waiting for Marathon to start deployment")
48
- end
49
56
  while running_for_deployment_id?
50
-
51
57
  deployment_seen = true
52
58
  #response = list_all
53
59
  #STDOUT.print "." if ( $LOG.level == 1 )
@@ -137,11 +143,9 @@ module MarathonDeploy
137
143
  return response
138
144
  end
139
145
 
140
- def update_app(force=false)
141
- url = @url + MarathonDefaults::MARATHON_APPS_REST_PATH + @application.id
142
- url += force ? '?force=true' : ''
146
+ def update_app
143
147
  $LOG.debug("Updating app #{@application.id} #{url}")
144
- response = HttpUtil.put(url,@application.json)
148
+ response = Utils.putJSON(@url,@application)
145
149
  begin
146
150
  @deploymentId = Utils.response_body(response)[:deploymentId]
147
151
  rescue Exception=>e
@@ -58,7 +58,14 @@ module MarathonDeploy
58
58
 
59
59
  # wait for deployment to finish, according to marathon deployment API call
60
60
  begin
61
- deployment.wait_for_deployment_id
61
+ deployment.wait_for_deployment
62
+ rescue Timeout::Error => e
63
+ $LOG.warn("Timed out after waiting for deployment to start")
64
+ $LOG.warn("Deployment did not start at all")
65
+ $LOG.warn("Possible reason: deploying the same plan already (use option -f to ensure that plans are unique)")
66
+ end
67
+ begin
68
+ deployment.wait_for_deployment_id
62
69
  rescue Timeout::Error => e
63
70
  $LOG.error("Timed out waiting for deployment of #{application.id} to complete. Canceling deploymentId #{deployment.deploymentId} and rolling back!")
64
71
  deployment.cancel(deployment.deploymentId)
@@ -9,6 +9,7 @@ module MarathonDeploy
9
9
  attr_accessor :marathon_username, :marathon_password
10
10
  end
11
11
 
12
+ WAIT_FOR_DEPLOYMENT_TIMEOUT = 7
12
13
  DEPLOYMENT_RECHECK_INTERVAL = 3
13
14
  DEPLOYMENT_TIMEOUT = 300
14
15
  HEALTHY_WAIT_TIMEOUT = 300
@@ -60,6 +60,18 @@ module MarathonDeploy
60
60
  value
61
61
  end
62
62
 
63
+ def self.putJSON(url,application)
64
+ response = nil
65
+ 5.times { |i|
66
+ i+=1
67
+ response = HttpUtil.put(url + MarathonDefaults::MARATHON_APPS_REST_PATH + application.id,application.json)
68
+ break if (!response.nil?)
69
+ $LOG.info "Did not receive anything from Marathon. Waiting #{i} seconds then retrying ..."
70
+ sleep i
71
+ }
72
+ return response
73
+ end
74
+
63
75
  def self.lookup(model, key, *rest)
64
76
  v = model[key]
65
77
  return v if rest.empty?
@@ -1,3 +1,3 @@
1
1
  module MarathonDeploy
2
- VERSION = "0.1.49"
2
+ VERSION = "0.1.50"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marathon_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.49
4
+ version: 0.1.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Colby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-10 00:00:00.000000000 Z
11
+ date: 2016-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger