Class: Environments::CanaryIngress::UpdateService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/environments/canary_ingress/update_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#execute(environment) ⇒ Object

This method actually executes the PATCH request to Kubernetes, that is used by internal processes i.e. sidekiq worker. You should always use ‘execute_async` to properly validate user’s requests.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/services/environments/canary_ingress/update_service.rb', line 19

def execute(environment)
  canary_ingress = environment.ingresses&.find(&:canary?)

  unless canary_ingress.present?
    return error(_('Canary Ingress does not exist in the environment.'))
  end

  if environment.patch_ingress(canary_ingress, patch_data)
    environment.clear_all_caches
    success
  else
    error(_('Failed to update the Canary Ingress.'), :bad_request)
  end
end

#execute_async(environment) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'app/services/environments/canary_ingress/update_service.rb', line 6

def execute_async(environment)
  result = validate(environment)

  return result unless result[:status] == :success

  Environments::CanaryIngress::UpdateWorker.perform_async(environment.id, params)

  success
end