uffizzi_core 2.0.14 → 2.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3f418bff9703cbe59f1ee9a69e52f14aa1ad2824a4118ad4b6d97c703347243
4
- data.tar.gz: e9d6492698a43db8833b1175c10b95054d2b2c4230ade5aeee0d7ca49640ba1e
3
+ metadata.gz: 725cca20ca80112e168ba374f53dc0fa5cb48ed92339996405610fad6d37e931
4
+ data.tar.gz: 44034045e9b25197d558202fb336ff7faab8b9f7ac02cea97bbbcbb5cfac711c
5
5
  SHA512:
6
- metadata.gz: 981763aac83a419775db0130ac7b984e896fc36a11170c69c9f28d2045e5fd4024f74c3fafc538fa88a955b964377976845a0793b8e373e409ab6e3acc7e0bbd
7
- data.tar.gz: 16a2fe83f500ab8e56ce259a978ea6a6318d1de83027edb71f06205156eb8d98fb24b27ab758262b06c2fb7696199e4c40a91da87b71405df94ad37a469430cf
6
+ metadata.gz: 2c417dc4df5d3842a73941775b4f6267bfd41ed19f29db0a5b58496346ef77237a134d3eaf515f6f6cef975c29f0b962cbba82d1e293af36625ccb0e1a02fdda
7
+ data.tar.gz: 254aff6198f4136c367fcc1e64a58fdcc920bf009d3a3f842ceddf5d42b362eebf9f993c5d261649e60e3d3c6c0394f29e2a2bee0dfc4c2787eba4009dea1409
@@ -31,6 +31,12 @@ module UffizziCore::DependencyInjectionConcern
31
31
  module_class(:ingress_parser)
32
32
  end
33
33
 
34
+ def notification_module
35
+ return unless module_exists?(:notification_module)
36
+
37
+ module_class(:notification_module)
38
+ end
39
+
34
40
  private
35
41
 
36
42
  def module_exists?(module_name)
@@ -8,6 +8,13 @@ class UffizziCore::ConfigFile::ApplyJob < UffizziCore::ApplicationJob
8
8
  when UffizziCore::DeploymentNotFoundError
9
9
  Rails.logger.info("DEPLOYMENT_PROCESS ApplyJob retry deployment_id=#{exception.deployment_id} count=#{count}")
10
10
  Settings.controller.resource_create_retry_time
11
+ else
12
+ if [Settings.default_job_retry_count, Settings.controller.resource_create_retry_count].include?(count)
13
+ Sentry.capture_exception(exception)
14
+ :kill
15
+ else
16
+ Settings.controller.resource_create_retry_time
17
+ end
11
18
  end
12
19
  end
13
20
 
@@ -8,6 +8,13 @@ class UffizziCore::Deployment::CreateCredentialJob < UffizziCore::ApplicationJob
8
8
  when UffizziCore::DeploymentNotFoundError
9
9
  Rails.logger.info("DEPLOYMENT_PROCESS CreateCredentialJob retry deployment_id=#{exception.deployment_id} count=#{count}")
10
10
  Settings.controller.resource_create_retry_time
11
+ else
12
+ if [Settings.default_job_retry_count, Settings.controller.resource_create_retry_count].include?(count)
13
+ Sentry.capture_exception(exception)
14
+ :kill
15
+ else
16
+ Settings.controller.resource_create_retry_time
17
+ end
11
18
  end
12
19
  end
13
20
 
@@ -8,6 +8,13 @@ class UffizziCore::Deployment::DeployContainersJob < UffizziCore::ApplicationJob
8
8
  when UffizziCore::DeploymentNotFoundError
9
9
  Rails.logger.info("DEPLOYMENT_PROCESS DeployContainersJob retry deployment_id=#{exception.deployment_id} count=#{count}")
10
10
  Settings.controller.resource_create_retry_time
11
+ else
12
+ if [Settings.default_job_retry_count, Settings.controller.resource_create_retry_count].include?(count)
13
+ Sentry.capture_exception(exception)
14
+ :kill
15
+ else
16
+ Settings.controller.resource_create_retry_time
17
+ end
11
18
  end
12
19
  end
13
20
 
@@ -1,13 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class UffizziCore::Deployment::ManageDeployActivityItemJob < UffizziCore::ApplicationJob
4
- sidekiq_options queue: :deployments, retry: 3
4
+ sidekiq_options queue: :deployments, retry: Settings.default_job_retry_count
5
5
 
6
6
  sidekiq_retry_in do |count, exception|
7
7
  case exception
8
8
  when UffizziCore::Deployment::ImagePullError
9
9
  Rails.logger.info("DEPLOYMENT_PROCESS ManageDeployActivityItemJob retry deployment_id=#{exception.deployment_id} count=#{count}")
10
- 15.seconds
10
+ Settings.controller.resource_create_retry_time
11
+ when ActiveRecord::RecordNotFound
12
+ :kill if exception.model.constantize == UffizziCore::ActivityItem
13
+ else
14
+ if count == Settings.default_job_retry_count
15
+ Sentry.capture_exception(exception)
16
+ :kill
17
+ else
18
+ Settings.controller.resource_create_retry_time
19
+ end
11
20
  end
12
21
  end
13
22
 
@@ -8,6 +8,13 @@ class UffizziCore::Deployment::UpdateCredentialJob < UffizziCore::ApplicationJob
8
8
  when UffizziCore::DeploymentNotFoundError
9
9
  Rails.logger.info("DEPLOYMENT_PROCESS UpdateCredentialJob retry deployment_id=#{exception.deployment_id} count=#{count}")
10
10
  Settings.controller.resource_update_retry_time
11
+ else
12
+ if [Settings.default_job_retry_count, Settings.controller.resource_update_retry_count].include?(count)
13
+ Sentry.capture_exception(exception)
14
+ :kill
15
+ else
16
+ Settings.controller.resource_create_retry_time
17
+ end
11
18
  end
12
19
  end
13
20
 
@@ -47,7 +47,7 @@ module UffizziCore::Concerns::Models::Deployment
47
47
  transitions from: [:disabled], to: :active
48
48
  end
49
49
 
50
- event :fail, after: :after_fail do
50
+ event :fail do
51
51
  transitions from: [:active], to: :failed
52
52
  end
53
53
 
@@ -61,10 +61,6 @@ module UffizziCore::Concerns::Models::Deployment
61
61
  update!(disabled_at: Time.now)
62
62
  end
63
63
 
64
- def after_fail
65
- active_containers.each(&:disable!)
66
- end
67
-
68
64
  def clean
69
65
  active_containers.each(&:disable!)
70
66
  UffizziCore::Deployment::DeleteJob.perform_async(id)
@@ -4,6 +4,8 @@ class UffizziCore::ActivityItemService
4
4
  COMPLETED_STATES = ['deployed', 'failed', 'cancelled'].freeze
5
5
 
6
6
  class << self
7
+ include UffizziCore::DependencyInjectionConcern
8
+
7
9
  def create_docker_item!(repo, container)
8
10
  activity_item_attributes = {
9
11
  namespace: repo.namespace,
@@ -27,8 +29,9 @@ class UffizziCore::ActivityItemService
27
29
 
28
30
  def fail_deployment!(activity_item)
29
31
  deployment = activity_item.container.deployment
32
+ last_event = activity_item.events.order_by_id.last
30
33
 
31
- activity_item.events.create(state: UffizziCore::Event.state.failed)
34
+ activity_item.events.create(state: UffizziCore::Event.state.failed) unless last_event&.failed?
32
35
 
33
36
  UffizziCore::DeploymentService.fail!(deployment)
34
37
  end
@@ -55,6 +58,11 @@ class UffizziCore::ActivityItemService
55
58
 
56
59
  activity_item.events.create(state: status) if last_event&.state != status
57
60
 
61
+ if failed?(status)
62
+ UffizziCore::ActivityItemService.fail_deployment!(activity_item)
63
+ notification_module.notify_about_failed_deployment(deployment) if notification_module.present?
64
+ end
65
+
58
66
  return unless [UffizziCore::Event.state.building, UffizziCore::Event.state.deploying].include?(status)
59
67
 
60
68
  UffizziCore::Deployment::ManageDeployActivityItemJob.perform_in(5.seconds, activity_item.id)
@@ -75,5 +83,9 @@ class UffizziCore::ActivityItemService
75
83
  last_event = activity_item.events.last
76
84
  COMPLETED_STATES.include?(last_event.state)
77
85
  end
86
+
87
+ def failed?(status)
88
+ status == UffizziCore::Event.state.failed
89
+ end
78
90
  end
79
91
  end
@@ -135,7 +135,7 @@ class UffizziCore::DeploymentService
135
135
  end
136
136
 
137
137
  def build_deployment_url(deployment)
138
- "#{Settings.app.managed_dns_zone}/projects/#{deployment.project_id}/deployments"
138
+ "#{Settings.app.host}/projects/#{deployment.project_id}/deployments"
139
139
  end
140
140
 
141
141
  def all_containers_have_unique_ports?(containers)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore
4
- VERSION = '2.0.14'
4
+ VERSION = '2.0.16'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uffizzi_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.14
4
+ version: 2.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Thurman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-12-01 00:00:00.000000000 Z
12
+ date: 2022-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aasm