2018-07-16 12:31:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-13 13:21:23 -04:00
|
|
|
module Clusters
|
|
|
|
module Gcp
|
|
|
|
class FetchOperationService
|
|
|
|
def execute(provider)
|
|
|
|
operation = provider.api_client.projects_zones_operations(
|
2017-10-23 04:36:35 -04:00
|
|
|
provider.gcp_project_id,
|
|
|
|
provider.zone,
|
2017-10-13 13:21:23 -04:00
|
|
|
provider.operation_id)
|
|
|
|
|
|
|
|
yield(operation) if block_given?
|
|
|
|
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
|
2018-12-10 17:52:38 -05:00
|
|
|
logger.error(
|
|
|
|
exception: e.class.name,
|
|
|
|
service: self.class.name,
|
|
|
|
provider_id: provider.id,
|
|
|
|
message: e.message
|
|
|
|
)
|
|
|
|
|
2017-10-23 04:36:35 -04:00
|
|
|
provider.make_errored!("Failed to request to CloudPlatform; #{e.message}")
|
2017-10-13 13:21:23 -04:00
|
|
|
end
|
2018-12-10 10:20:07 -05:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def logger
|
|
|
|
@logger ||= Gitlab::Kubernetes::Logger.build
|
|
|
|
end
|
2017-10-13 13:21:23 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|