Skip to content

Commit b2464ff

Browse files
iaftab-alamjohha
authored andcommitted
make use of utc time zone and appease linters
1 parent 801bfa2 commit b2464ff

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/diego/client.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,18 @@ def actual_lrps_by_process_guid(process_guid)
164164
def with_request_error_handling
165165
delay = 0.25
166166
max_delay = 5
167-
retry_until = Time.now + 60 # retry for 1 minute from now
167+
retry_until = Time.now.utc + 60 # retry for 1 minute from now
168168
factor = 2
169169

170170
begin
171171
yield
172172
rescue StandardError => e
173-
if Time.now > retry_until
173+
if Time.now.utc > retry_until
174174
@logger.error('Unable to establish a connection to diego backend, no more retries, raising an exception.')
175175
raise RequestError.new(e.message)
176176
else
177177
sleep_time = [delay, max_delay].min
178-
@logger.info("Attempting to connect to the diego backend. Total #{(retry_until - Time.now).round(2)} seconds remaining. Next retry after #{sleep_time} seconds delay.")
178+
@logger.info("Attempting to connect to the diego backend. Total #{(retry_until - Time.now.utc).round(2)} seconds remaining. Next retry after #{sleep_time} seconds.")
179179
sleep(sleep_time)
180180
delay *= factor
181181
retry

spec/diego/client_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ module Diego
806806
expect do
807807
subject.with_request_error_handling do
808808
attempts += 1
809-
Timecop.travel(Time.now + 50)
809+
Timecop.travel(Time.now.utc + 50)
810810
raise 'Error!'
811811
end
812812
end.to raise_error(RequestError, 'Error!')
@@ -818,7 +818,7 @@ module Diego
818818
end
819819

820820
it 'stops retrying after 60 seconds and raises an exception' do
821-
start_time = Time.now
821+
start_time = Time.now.utc
822822
Timecop.freeze do
823823
expect do
824824
subject.with_request_error_handling do
@@ -861,14 +861,14 @@ module Diego
861861

862862
it 'raises an error after 17 attempts in approximately 1 minute when each yield call immediately' do
863863
attempts = 0
864-
start_time = Time.now
864+
start_time = Time.now.utc
865865
expect do
866866
subject.with_request_error_handling do
867867
attempts += 1
868868
raise RequestError
869869
end
870870
end.to raise_error(RequestError)
871-
end_time = Time.now
871+
end_time = Time.now.utc
872872
duration = end_time.to_f - start_time.to_f
873873

874874
expect(attempts).to be_within(1).of(17)

0 commit comments

Comments
 (0)