debian-mirror-gitlab/app/services/clusters/gcp/fetch_operation_service.rb

32 lines
803 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module Clusters
module Gcp
class FetchOperationService
def execute(provider)
operation = provider.api_client.projects_zones_operations(
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
2019-02-15 15:39:39 +05:30
logger.error(
exception: e.class.name,
service: self.class.name,
provider_id: provider.id,
message: e.message
)
2018-03-17 18:26:18 +05:30
provider.make_errored!("Failed to request to CloudPlatform; #{e.message}")
end
2019-02-15 15:39:39 +05:30
private
def logger
@logger ||= Gitlab::Kubernetes::Logger.build
end
2018-03-17 18:26:18 +05:30
end
end
end