Class: Deployments::OlderDeploymentsDropService

Inherits:
Object
  • Object
show all
Defined in:
app/services/deployments/older_deployments_drop_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deployment_id) ⇒ OlderDeploymentsDropService

Returns a new instance of OlderDeploymentsDropService.


7
8
9
# File 'app/services/deployments/older_deployments_drop_service.rb', line 7

def initialize(deployment_id)
  @deployment = Deployment.find_by_id(deployment_id)
end

Instance Attribute Details

#deploymentObject (readonly)

Returns the value of attribute deployment


5
6
7
# File 'app/services/deployments/older_deployments_drop_service.rb', line 5

def deployment
  @deployment
end

Instance Method Details

#executeObject


11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/deployments/older_deployments_drop_service.rb', line 11

def execute
  return unless @deployment&.running?

  older_deployments.find_each do |older_deployment|
    Gitlab::OptimisticLocking.retry_lock(older_deployment.deployable) do |deployable|
      deployable.drop(:forward_deployment_failure)
    end
  rescue => e
    Gitlab::ErrorTracking.track_exception(e, subject_id: @deployment.id, deployment_id: older_deployment.id)
  end
end