uffizzi_core 2.2.2 → 2.2.4

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: dbe95387d820ac425ad0e22777c819f16d4585bc68447303acdea82e035211f0
4
- data.tar.gz: be6df718ea508614af3f8ec13b91ed676e7efb1497ba0c86c24be29582f56d5f
3
+ metadata.gz: d9a737645810c1744fe73cfbfb2e0d249d0895d75105065dcec75e7f4dea0844
4
+ data.tar.gz: a303130b01e8538a78dd5d891c2d8b9a51224c50d25b0ef5cdb830a7de55de2d
5
5
  SHA512:
6
- metadata.gz: a56c2b2e674534c8774706192ff2f279ee9b755694f92bebed476a8717f4b7f976e267e563aa0189a4ecf9f6c56f4dd0b70f75279ccec7b7a13db614c20dc231
7
- data.tar.gz: a9e490414365f05c52147fc17d322c2e52257d20a2a955c9f1a61c159e2fe112a69eb6741c846f772ead653a03dd5689aa1d722f6de957ac50c0754a20f032b3
6
+ metadata.gz: '043837408678dd986b192992cd149f9ca67c1490b7cc07a49cbbc464302fb717ca27ddbcd1819093e92ea7cc7c095930e349caed34bed2593dac4fc01e00c41f'
7
+ data.tar.gz: 62e606f4b9e4ef2ccbcdb0f7f73a6acf91970e1697a00f87a03675ce63fc18f84c835e165e45ab47a7b5797db9b278e83654de02e381631832d37e98c6d6de37
@@ -5,5 +5,5 @@ module UffizziCore::Api::Cli::V1::Projects::ClustersControllerModule
5
5
 
6
6
  def update_show_trial_quota_exceeded_warning; end
7
7
 
8
- def stop_if_deployment_forbidden; end
8
+ def check_account_quota; end
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module UffizziCore::Api::Cli::V1::Projects::DeploymentsControllerModule
4
4
  private
5
5
 
6
- def stop_if_deployment_forbidden; end
6
+ def check_account_quota; end
7
7
 
8
8
  def update_show_trial_quota_exceeded_warning; end
9
9
  end
@@ -7,6 +7,10 @@ module UffizziCore::DependencyInjectionConcern
7
7
  def include_module_if_exists(module_name)
8
8
  include(Object.const_get(module_name)) if Object.const_defined?(module_name)
9
9
  end
10
+
11
+ def prepend_module_if_exists(module_name)
12
+ prepend(Object.const_get(module_name)) if Object.const_defined?(module_name)
13
+ end
10
14
  end
11
15
 
12
16
  def user_access_module
@@ -4,7 +4,7 @@ class UffizziCore::Api::Cli::V1::Projects::ClustersController < UffizziCore::Api
4
4
  include UffizziCore::Api::Cli::V1::Projects::ClustersControllerModule
5
5
 
6
6
  before_action :authorize_uffizzi_core_api_cli_v1_projects_clusters
7
- before_action :stop_if_deployment_forbidden, only: [:create]
7
+ before_action :check_account_quota, only: [:create]
8
8
  after_action :update_show_trial_quota_exceeded_warning, only: [:create, :destroy]
9
9
 
10
10
  def index
@@ -6,7 +6,7 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsController < UffizziCore::
6
6
  include UffizziCore::Api::Cli::V1::Projects::DeploymentsControllerModule
7
7
 
8
8
  before_action :authorize_uffizzi_core_api_cli_v1_projects_deployments
9
- before_action :stop_if_deployment_forbidden, only: :create
9
+ before_action :check_account_quota, only: :create
10
10
  after_action :update_show_trial_quota_exceeded_warning, only: :destroy
11
11
 
12
12
  # Get a list of active deployements for a project
@@ -133,6 +133,7 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsController < UffizziCore::
133
133
  # @response 401 Not authorized
134
134
  def destroy
135
135
  UffizziCore::DeploymentService.disable!(deployment)
136
+ deployment.deployment_events.create!(deployment_state: deployment.state, message: 'Destroyed by CLI')
136
137
 
137
138
  head :no_content
138
139
  end
@@ -22,6 +22,7 @@ module UffizziCore::Concerns::Models::Deployment
22
22
  has_many :credentials, through: :project
23
23
  has_many :containers, dependent: :destroy, index_errors: true
24
24
  has_many :activity_items, dependent: :destroy
25
+ has_many :deployment_events, dependent: :destroy
25
26
 
26
27
  has_one :ingress_container, -> { where(receive_incoming_requests: true) }, class_name: UffizziCore::Container.name
27
28
  validates :kind, presence: true
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UffizziCore::Concerns::Models::DeploymentEvent
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ self.table_name = UffizziCore.table_names[:deployment_events]
8
+
9
+ belongs_to :deployment
10
+ end
11
+ end
@@ -51,6 +51,7 @@ module UffizziCore::Concerns::Models::Project
51
51
  def disable_deployments
52
52
  active_deployments.each do |deployment|
53
53
  UffizziCore::DeploymentService.disable!(deployment)
54
+ deployment.deployment_events.create!(deployment_state: deployment.state, message: 'Disabled after project was disabled')
54
55
  end
55
56
  end
56
57
 
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UffizziCore::DeploymentEvent < UffizziCore::ApplicationRecord
4
+ include UffizziCore::Concerns::Models::DeploymentEvent
5
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  class UffizziCore::Api::Cli::V1::ShortProjectSerializer < UffizziCore::BaseSerializer
4
4
  type :project
5
+ belongs_to :account, serializer: UffizziCore::Api::Cli::V1::ProjectSerializer::AccountSerializer
5
6
 
7
+ # account_id supports CLI versions < 2.0.5
6
8
  attributes :name, :slug, :account_id
7
9
  end
@@ -54,7 +54,10 @@ class UffizziCore::ActivityItemService
54
54
  return handle_failed_status(activity_item, deployment) if failed?(status)
55
55
 
56
56
  if deployed?(status) && UffizziCore::ContainerService.ingress_container?(container)
57
- return deployment.update(last_deploy_at: last_event.created_at)
57
+ deployment.update!(last_deploy_at: last_event.created_at)
58
+ deployment.deployment_events.create!(deployment_state: status)
59
+
60
+ return
58
61
  end
59
62
 
60
63
  return unless [UffizziCore::Event.state.building, UffizziCore::Event.state.deploying].include?(status)
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class UffizziCore::DeploymentService
4
+ include UffizziCore::DependencyInjectionConcern
5
+ prepend_module_if_exists('UffizziCore::DeploymentServiceModule')
6
+
4
7
  MIN_TARGET_PORT_RANGE = 37_000
5
8
  MAX_TARGET_PORT_RANGE = 39_999
6
9
 
@@ -39,12 +42,8 @@ class UffizziCore::DeploymentService
39
42
  deployment.containers.destroy_all
40
43
  deployment.compose_file.destroy! if deployment.compose_file&.kind&.temporary?
41
44
  deployment.activate unless deployment.active?
42
- params = {
43
- containers: deployment_form.containers,
44
- compose_file_id: compose_file.id,
45
- metadata: deployment_form.metadata,
46
- }
47
- deployment.update!(params)
45
+ new_params = params_for_update_deployment(deployment_form, compose_file)
46
+ deployment.update!(new_params)
48
47
  end
49
48
 
50
49
  deployment
@@ -56,10 +55,15 @@ class UffizziCore::DeploymentService
56
55
  update_controller_container_names(deployment)
57
56
  end
58
57
 
59
- case deployment_process_status(deployment)
58
+ status = deployment_process_status(deployment)
59
+
60
+ case status
60
61
  when DEPLOYMENT_PROCESS_STATUSES[:building]
61
62
  Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment.id} repeat deploy_containers")
62
63
  UffizziCore::Deployment::DeployContainersJob.perform_in(1.minute, deployment.id, true)
64
+ unless repeated
65
+ deployment.deployment_events.create!(deployment_state: status)
66
+ end
63
67
  when DEPLOYMENT_PROCESS_STATUSES[:deploying]
64
68
  Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment.id} start deploying into controller")
65
69
 
@@ -67,6 +71,7 @@ class UffizziCore::DeploymentService
67
71
  containers_with_variables = add_default_deployment_variables!(containers, deployment)
68
72
 
69
73
  UffizziCore::ControllerService.deploy_containers(deployment, containers_with_variables)
74
+ deployment.deployment_events.create!(deployment_state: status)
70
75
  else
71
76
  Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment.id} deployment has builds errors, stopping")
72
77
  end
@@ -84,6 +89,7 @@ class UffizziCore::DeploymentService
84
89
  return if deployment.failed?
85
90
 
86
91
  deployment.fail!
92
+ deployment.deployment_events.create!(deployment_state: deployment.state)
87
93
  compose_file = deployment.compose_file || deployment.template&.compose_file
88
94
  return unless compose_file&.kind&.temporary?
89
95
 
@@ -230,5 +236,13 @@ class UffizziCore::DeploymentService
230
236
  container.variables.push(*envs)
231
237
  end
232
238
  end
239
+
240
+ def params_for_update_deployment(deployment_form, compose_file)
241
+ {
242
+ containers: deployment_form.containers,
243
+ compose_file_id: compose_file.id,
244
+ metadata: deployment_form.metadata,
245
+ }
246
+ end
233
247
  end
234
248
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDeploymentEvents < ActiveRecord::Migration[6.1]
4
+ def change
5
+ create_table :uffizzi_core_deployment_events do |t|
6
+ t.string :deployment_state
7
+ t.string :message
8
+ t.timestamps
9
+ t.references :deployment, null: false,
10
+ index: { name: :uf_core_dep_events_on_dep },
11
+ foreign_key: { to_table: :uffizzi_core_deployments }
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore
4
- VERSION = '2.2.2'
4
+ VERSION = '2.2.4'
5
5
  end
data/lib/uffizzi_core.rb CHANGED
@@ -61,6 +61,7 @@ module UffizziCore
61
61
  users_roles: :uffizzi_core_users_roles,
62
62
  host_volume_files: :uffizzi_core_host_volume_files,
63
63
  container_host_volume_files: :uffizzi_core_container_host_volume_files,
64
+ deployment_events: :uffizzi_core_deployment_events,
64
65
  }
65
66
  mattr_accessor :user_creation_sources, default: [:system, :online_registration, :google, :sso]
66
67
  mattr_accessor :user_project_roles, default: [:admin, :developer, :viewer]
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.2.2
4
+ version: 2.2.4
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: 2023-07-07 00:00:00.000000000 Z
12
+ date: 2023-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aasm
@@ -847,6 +847,7 @@ files:
847
847
  - app/lib/uffizzi_core/concerns/models/coupon.rb
848
848
  - app/lib/uffizzi_core/concerns/models/credential.rb
849
849
  - app/lib/uffizzi_core/concerns/models/deployment.rb
850
+ - app/lib/uffizzi_core/concerns/models/deployment_event.rb
850
851
  - app/lib/uffizzi_core/concerns/models/event.rb
851
852
  - app/lib/uffizzi_core/concerns/models/host_volume_file.rb
852
853
  - app/lib/uffizzi_core/concerns/models/membership.rb
@@ -890,6 +891,7 @@ files:
890
891
  - app/models/uffizzi_core/database.rb
891
892
  - app/models/uffizzi_core/database_offering.rb
892
893
  - app/models/uffizzi_core/deployment.rb
894
+ - app/models/uffizzi_core/deployment_event.rb
893
895
  - app/models/uffizzi_core/event.rb
894
896
  - app/models/uffizzi_core/host_volume_file.rb
895
897
  - app/models/uffizzi_core/membership.rb
@@ -1059,6 +1061,7 @@ files:
1059
1061
  - db/migrate/20230111000000_add_state_to_memberships.rb
1060
1062
  - db/migrate/20230306142513_add_last_deploy_at_to_deployments.rb
1061
1063
  - db/migrate/20230406154451_add_full_image_name_to_container.rb
1064
+ - db/migrate/20230531135739_create_deployment_events.rb
1062
1065
  - db/migrate/20230613101901_create_clusters.rb
1063
1066
  - db/seeds.rb
1064
1067
  - lib/tasks/uffizzi_core_tasks.rake