Skip to content

Commit 923dbf7

Browse files
author
bot
committed
Revert "do not stage if staging or staged"
We are in a weird state right now in Azure. Once we are in a 'clean' state with no staged image we will put this check in. This reverts commit 8e95fa4.
1 parent 5caad32 commit 923dbf7

File tree

2 files changed

+7
-44
lines changed

2 files changed

+7
-44
lines changed

lib/stemcell/publisher/azure.rb

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def finalize
2929

3030
def publish
3131
status = poll_status('staging')
32-
puts "staging status: #{status}"
3332
if status == 'Staged'
3433
post(base_url+'list', '')
3534
else
@@ -38,14 +37,6 @@ def publish
3837
end
3938

4039
def stage
41-
if(is_staging)
42-
raise "an offer is staging"
43-
end
44-
45-
if(is_staged)
46-
raise "an offer is staged"
47-
end
48-
4940
response = get(base_url)
5041
unless response.kind_of? Net::HTTPSuccess
5142
raise "could not obtain offer data. expected 200 but got '#{response.code}'"
@@ -70,7 +61,13 @@ def base_url
7061
def poll_status(mode)
7162
status = ''
7263
while true
73-
status = get_status(mode)
64+
response = get(base_url+'progress')
65+
unless response.kind_of? Net::HTTPSuccess
66+
raise "could not obtain progress data. expected 200 but got '#{response.code}'"
67+
end
68+
response_body = JSON.parse(response.body)
69+
status = response_body[mode]['State']
70+
puts "#{mode} status: #{status}"
7471
break if status != 'InProgress'
7572
puts "#{Time.now} Starting to sleep for an hour"
7673
sleep 60 * 60
@@ -79,25 +76,6 @@ def poll_status(mode)
7976
return status
8077
end
8178

82-
def get_status(mode)
83-
response = get(base_url+'progress')
84-
unless response.kind_of? Net::HTTPSuccess
85-
raise "could not obtain progress data. expected 200 but got '#{response.code}'"
86-
end
87-
response_body = JSON.parse(response.body)
88-
response_body[mode]['State']
89-
end
90-
91-
def is_staged()
92-
status = get_status('staging')
93-
status == 'Staged'
94-
end
95-
96-
def is_staging()
97-
status = get_status('staging')
98-
status == 'InProgress'
99-
end
100-
10179
def json(response_string)
10280
response_json = JSON.parse(response_string)
10381
json = response_json['Offer']

spec/stemcell/publisher/azure_spec.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,6 @@
280280
stub_request(:get, @publisher.base_url).to_return(status: 200, body: response)
281281
stub_request(:post, @publisher.base_url+'update').to_return(status: 200)
282282
stub_request(:post, @publisher.base_url+'stage').to_return(status: 202)
283-
stub_request(:get, @publisher.base_url+'progress').to_return(status: 200, body: '{"staging":{"State":"whatever the state of an unstaged thing is"}}')
284-
end
285-
286-
it 'does not try to stage if an offer is already staged' do
287-
staged_response = '{"staging":{"State":"Staged"}}'
288-
stub_request(:get, @publisher.base_url+'progress').to_return(status: 200, body: staged_response)
289-
290-
expect{@publisher.stage}.to raise_error('an offer is staged')
291-
end
292-
293-
it 'does not try to stage if an offer is staging' do
294-
staged_response = '{"staging":{"State":"InProgress"}}'
295-
stub_request(:get, @publisher.base_url+'progress').to_return(status: 200, body: staged_response)
296-
297-
expect{@publisher.stage}.to raise_error('an offer is staging')
298283
end
299284

300285
it 'does not print the API key to stdout or stderr' do

0 commit comments

Comments
 (0)