gitlab-org--gitlab-foss/app/services/clusters/gcp/fetch_operation_service.rb

32 lines
803 B
Ruby
Raw Normal View History

# frozen_string_literal: true
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,
provider.operation_id)
yield(operation) if block_given?
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
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}")
end
private
def logger
@logger ||= Gitlab::Kubernetes::Logger.build
end
end
end
end