Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/online_kitchen/labmanager4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class LabManager4
class DeployError < StandardError
end

class ReleaseError < StandardError
end

class << self
def create(opts = {})
new.provision_machine(opts)
Expand All @@ -37,6 +40,8 @@ def release_machine(name, opts = {})
response = http.request request # Net::HTTPResponse object
OnlineKitchen.logger.debug(response.body)
JSON.parse(response.body)['responses'][0]['request_id']
rescue Net::OpenTimeout
raise ReleaseError
end

wait_for_request_completion(config, request_id)
Expand Down
2 changes: 2 additions & 0 deletions lib/online_kitchen/workers/lab_manager_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def release(machine_id)
configuration = machine.configuration
machine.destroy!
configuration.schedule_destroy if configuration.machines.count.zero?
rescue OnlineKitchen::LabManager4::ReleaseError
self.class.perform_in(rand(5..9).seconds, machine_id)
end
OnlineKitchen.logger.info "Machine id:#{machine_id} destroyed in #{time.round(2)} seconds."
Metriks.timer('online_kitchen.worker.release').update(time)
Expand Down