2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
class ClusterProvisionWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 11:08:30 -05:00
|
|
|
include ApplicationWorker
|
2021-04-30 14:10:09 -04:00
|
|
|
|
2021-07-21 08:09:35 -04:00
|
|
|
data_consistency :always
|
|
|
|
|
2021-04-30 14:10:09 -04:00
|
|
|
sidekiq_options retry: 3
|
2017-10-03 13:33:37 -04:00
|
|
|
include ClusterQueue
|
2017-09-30 11:54:22 -04:00
|
|
|
|
2019-10-30 11:14:17 -04:00
|
|
|
worker_has_external_dependencies!
|
|
|
|
|
2017-09-30 11:54:22 -04:00
|
|
|
def perform(cluster_id)
|
2017-10-13 13:21:23 -04:00
|
|
|
Clusters::Cluster.find_by_id(cluster_id).try do |cluster|
|
2017-10-30 11:18:15 -04:00
|
|
|
cluster.provider.try do |provider|
|
2019-10-31 23:06:26 -04:00
|
|
|
if cluster.gcp?
|
|
|
|
Clusters::Gcp::ProvisionService.new.execute(provider)
|
|
|
|
elsif cluster.aws?
|
|
|
|
Clusters::Aws::ProvisionService.new.execute(provider)
|
|
|
|
end
|
2017-10-13 13:21:23 -04:00
|
|
|
end
|
2017-09-30 11:54:22 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|