uffizzi_core 2.2.4 → 2.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/uffizzi_core/dependency_injection_concern.rb +18 -0
- data/app/forms/uffizzi_core/api/cli/v1/deployment/create_form.rb +0 -14
- data/app/forms/uffizzi_core/api/cli/v1/deployment/update_form.rb +0 -14
- data/app/forms/uffizzi_core/api/cli/v1/template/create_form.rb +0 -16
- data/app/lib/uffizzi_core/concerns/models/cluster.rb +1 -1
- data/app/lib/uffizzi_core/concerns/models/template.rb +0 -16
- data/app/models/uffizzi_core/deployment.rb +10 -0
- data/app/models/uffizzi_core/template.rb +10 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/cluster_serializer.rb +1 -1
- data/app/services/uffizzi_core/cluster_service.rb +1 -0
- data/app/services/uffizzi_core/container_service.rb +0 -16
- data/app/services/uffizzi_core/controller_service.rb +1 -1
- data/app/services/uffizzi_core/controller_settings_service.rb +9 -0
- data/app/services/uffizzi_core/deployment/memory_service.rb +11 -0
- data/app/services/uffizzi_core/deployment_service.rb +0 -16
- data/app/services/uffizzi_core/template/memory_service.rb +11 -0
- data/config/locales/en.activerecord.yml +1 -2
- data/db/migrate/20230711101901_add_host_to_clusters.rb +7 -0
- data/lib/uffizzi_core/version.rb +1 -1
- data/lib/uffizzi_core.rb +3 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a34bc3da603108f8c6b1638f14d4e5025f3cc255062fff2f32fb849a6eb7206
|
4
|
+
data.tar.gz: 510bc658ead7b29c8bfe04e980fd47f6b4a5c5121d33048d7042a49a41d9d70f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a17109e4ace94f959f562d6b60be739faf9b07ef9b7712ac6f09bb005f060b0a1fc9e9acc37dec369540ae394c2aa53a934ab6084fcf1474349cc0ab02226d3
|
7
|
+
data.tar.gz: 83882b00eadefad47f00ef89aab8e07be1e15e8e4193b06b1608c0b92c7e0562677c0b2ca7ef8c5fb5fee76bd770465f7353fed35bb044cdb5f2e7620fbd5a4f
|
@@ -55,6 +55,24 @@ module UffizziCore::DependencyInjectionConcern
|
|
55
55
|
module_class(:domain_module)
|
56
56
|
end
|
57
57
|
|
58
|
+
def deployment_memory_module
|
59
|
+
return unless module_exists?(:deployment_memory_module)
|
60
|
+
|
61
|
+
module_class(:deployment_memory_module)
|
62
|
+
end
|
63
|
+
|
64
|
+
def template_memory_module
|
65
|
+
return unless module_exists?(:template_memory_module)
|
66
|
+
|
67
|
+
module_class(:template_memory_module)
|
68
|
+
end
|
69
|
+
|
70
|
+
def controller_settings_service
|
71
|
+
return unless module_exists?(:controller_settings)
|
72
|
+
|
73
|
+
module_class(:controller_settings)
|
74
|
+
end
|
75
|
+
|
58
76
|
private
|
59
77
|
|
60
78
|
def module_exists?(module_name)
|
@@ -55,8 +55,6 @@ class UffizziCore::Api::Cli::V1::Deployment::CreateForm < UffizziCore::Deploymen
|
|
55
55
|
|
56
56
|
validate :check_all_containers_have_unique_ports
|
57
57
|
validate :check_exists_ingress_container
|
58
|
-
validate :check_max_memory_limit
|
59
|
-
validate :check_max_memory_request
|
60
58
|
validate :check_secrets_exist_in_database
|
61
59
|
|
62
60
|
def assign_dependences!(project, user)
|
@@ -87,18 +85,6 @@ class UffizziCore::Api::Cli::V1::Deployment::CreateForm < UffizziCore::Deploymen
|
|
87
85
|
errors.add(:containers, :incorrect_ingress_container) unless UffizziCore::DeploymentService.ingress_container?(active_containers)
|
88
86
|
end
|
89
87
|
|
90
|
-
def check_max_memory_limit
|
91
|
-
return if UffizziCore::DeploymentService.valid_containers_memory_limit?(self)
|
92
|
-
|
93
|
-
errors.add(:containers, :max_memory_limit_error, max: project.account.container_memory_limit)
|
94
|
-
end
|
95
|
-
|
96
|
-
def check_max_memory_request
|
97
|
-
return if UffizziCore::DeploymentService.valid_containers_memory_request?(self)
|
98
|
-
|
99
|
-
errors.add(:containers, :max_memory_request_error, max: project.account.container_memory_limit)
|
100
|
-
end
|
101
|
-
|
102
88
|
def check_secrets_exist_in_database
|
103
89
|
return if compose_file.nil?
|
104
90
|
|
@@ -54,8 +54,6 @@ class UffizziCore::Api::Cli::V1::Deployment::UpdateForm < UffizziCore::Deploymen
|
|
54
54
|
|
55
55
|
validate :check_all_containers_have_unique_ports
|
56
56
|
validate :check_exists_ingress_container
|
57
|
-
validate :check_max_memory_limit
|
58
|
-
validate :check_max_memory_request
|
59
57
|
|
60
58
|
def assign_dependences!(project, user)
|
61
59
|
self.project = project
|
@@ -84,16 +82,4 @@ class UffizziCore::Api::Cli::V1::Deployment::UpdateForm < UffizziCore::Deploymen
|
|
84
82
|
|
85
83
|
errors.add(:containers, :incorrect_ingress_container) unless UffizziCore::DeploymentService.ingress_container?(active_containers)
|
86
84
|
end
|
87
|
-
|
88
|
-
def check_max_memory_limit
|
89
|
-
return if UffizziCore::DeploymentService.valid_containers_memory_limit?(self)
|
90
|
-
|
91
|
-
errors.add(:containers, :max_memory_limit_error, max: project.account.container_memory_limit)
|
92
|
-
end
|
93
|
-
|
94
|
-
def check_max_memory_request
|
95
|
-
return if UffizziCore::DeploymentService.valid_containers_memory_request?(self)
|
96
|
-
|
97
|
-
errors.add(:containers, :max_memory_request_error, max: project.account.container_memory_limit)
|
98
|
-
end
|
99
85
|
end
|
@@ -1,20 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class UffizziCore::Api::Cli::V1::Template::CreateForm < UffizziCore::Template
|
4
|
-
validate :check_max_memory_limit
|
5
|
-
validate :check_max_memory_request
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def check_max_memory_limit
|
10
|
-
return if valid_containers_memory_limit?
|
11
|
-
|
12
|
-
errors.add(:payload, :max_memory_limit_error, max: project.account.container_memory_limit)
|
13
|
-
end
|
14
|
-
|
15
|
-
def check_max_memory_request
|
16
|
-
return if valid_containers_memory_request?
|
17
|
-
|
18
|
-
errors.add(:payload, :max_memory_request_error, max: project.account.container_memory_limit)
|
19
|
-
end
|
20
4
|
end
|
@@ -41,7 +41,7 @@ module UffizziCore::Concerns::Models::Cluster
|
|
41
41
|
end
|
42
42
|
|
43
43
|
event :disable, after: :after_disable do
|
44
|
-
transitions from: [:failed_deploy_namespace, :deploying, :deployed, :failed], to: :disabled
|
44
|
+
transitions from: [:deploying_namespace, :failed_deploy_namespace, :deploying, :deployed, :failed], to: :disabled
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -18,21 +18,5 @@ module UffizziCore::Concerns::Models::Template
|
|
18
18
|
enumerize :creation_source, in: [:manual, :compose_file, :system], predicates: true, scope: true
|
19
19
|
|
20
20
|
validates :name, presence: true
|
21
|
-
|
22
|
-
def valid_containers_memory_limit?
|
23
|
-
containers_attributes = payload['containers_attributes']
|
24
|
-
container_memory_limit = project.account.container_memory_limit
|
25
|
-
return true if container_memory_limit.nil?
|
26
|
-
|
27
|
-
containers_attributes.all? { |container| container['memory_limit'].to_i <= container_memory_limit }
|
28
|
-
end
|
29
|
-
|
30
|
-
def valid_containers_memory_request?
|
31
|
-
containers_attributes = payload['containers_attributes']
|
32
|
-
container_memory_limit = project.account.container_memory_limit
|
33
|
-
return true if container_memory_limit.nil?
|
34
|
-
|
35
|
-
containers_attributes.all? { |container| container['memory_request'].to_i <= container_memory_limit }
|
36
|
-
end
|
37
21
|
end
|
38
22
|
end
|
@@ -21,4 +21,14 @@
|
|
21
21
|
|
22
22
|
class UffizziCore::Deployment < UffizziCore::ApplicationRecord
|
23
23
|
include UffizziCore::Concerns::Models::Deployment
|
24
|
+
include UffizziCore::DependencyInjectionConcern
|
25
|
+
|
26
|
+
validate :check_max_memory_limit
|
27
|
+
|
28
|
+
def check_max_memory_limit
|
29
|
+
return if deployment_memory_module.valid_memory_limit?(self)
|
30
|
+
|
31
|
+
deployment_memory_module.memory_limit_error_message(self)
|
32
|
+
errors.add(:containers, message)
|
33
|
+
end
|
24
34
|
end
|
@@ -2,4 +2,14 @@
|
|
2
2
|
|
3
3
|
class UffizziCore::Template < UffizziCore::ApplicationRecord
|
4
4
|
include UffizziCore::Concerns::Models::Template
|
5
|
+
include UffizziCore::DependencyInjectionConcern
|
6
|
+
|
7
|
+
validate :check_max_memory_limit
|
8
|
+
|
9
|
+
def check_max_memory_limit
|
10
|
+
return if template_memory_module.valid_memory_limit?(self)
|
11
|
+
|
12
|
+
message = template_memory_module.memory_limit_error_message(self)
|
13
|
+
errors.add(:payload, message)
|
14
|
+
end
|
5
15
|
end
|
@@ -33,6 +33,7 @@ class UffizziCore::ClusterService
|
|
33
33
|
if deployed_cluster.status.ready && deployed_cluster.status.kube_config.present?
|
34
34
|
cluster.finish_deploy
|
35
35
|
cluster.kubeconfig = deployed_cluster.status.kube_config
|
36
|
+
cluster.host = deployed_cluster.status.host
|
36
37
|
cluster.save!
|
37
38
|
|
38
39
|
return
|
@@ -23,22 +23,6 @@ class UffizziCore::ContainerService
|
|
23
23
|
container.aasm(:continuously_deploy).current_state == UffizziCore::Container::STATE_CD_ENABLED
|
24
24
|
end
|
25
25
|
|
26
|
-
def valid_memory_limit?(container)
|
27
|
-
max_memory_limit = container.deployment.project.account.container_memory_limit
|
28
|
-
container_memory_limit = container.memory_limit
|
29
|
-
return true if max_memory_limit.nil? || container_memory_limit.nil?
|
30
|
-
|
31
|
-
container_memory_limit <= max_memory_limit
|
32
|
-
end
|
33
|
-
|
34
|
-
def valid_memory_request?(container)
|
35
|
-
max_memory_limit = container.deployment.project.account.container_memory_limit
|
36
|
-
container_memory_request = container.memory_request
|
37
|
-
return true if max_memory_limit.nil? || container_memory_request.nil?
|
38
|
-
|
39
|
-
container_memory_request <= max_memory_limit
|
40
|
-
end
|
41
|
-
|
42
26
|
def last_state(container)
|
43
27
|
pods = pods_by_container(container)
|
44
28
|
container_status = container_status(container, pods)
|
@@ -109,7 +109,7 @@ class UffizziCore::ControllerService
|
|
109
109
|
when UffizziCore::Deployment
|
110
110
|
Settings.controller
|
111
111
|
when UffizziCore::Cluster
|
112
|
-
|
112
|
+
controller_settings_service.vcluster(deployable)
|
113
113
|
else
|
114
114
|
raise StandardError, "Deployable #{deployable.class.name} undefined"
|
115
115
|
end
|
@@ -101,22 +101,6 @@ class UffizziCore::DeploymentService
|
|
101
101
|
containers.empty? || ports.size == ports.uniq.size
|
102
102
|
end
|
103
103
|
|
104
|
-
def valid_containers_memory_limit?(deployment)
|
105
|
-
containers = deployment.containers
|
106
|
-
container_memory_limit = deployment.project.account.container_memory_limit
|
107
|
-
return true if container_memory_limit.nil?
|
108
|
-
|
109
|
-
containers.all? { |container| container.memory_limit <= container_memory_limit }
|
110
|
-
end
|
111
|
-
|
112
|
-
def valid_containers_memory_request?(deployment)
|
113
|
-
containers = deployment.containers
|
114
|
-
container_memory_limit = deployment.project.account.container_memory_limit
|
115
|
-
return true if container_memory_limit.nil?
|
116
|
-
|
117
|
-
containers.all? { |container| container.memory_request <= container_memory_limit }
|
118
|
-
end
|
119
|
-
|
120
104
|
def ingress_container?(containers)
|
121
105
|
containers.empty? || containers.map(&:receive_incoming_requests).count(true) == 1
|
122
106
|
end
|
@@ -19,8 +19,7 @@ en:
|
|
19
19
|
uffizzi_core/deployment:
|
20
20
|
attributes:
|
21
21
|
containers:
|
22
|
-
max_memory_limit_error: "
|
23
|
-
max_memory_request_error: "Memory request of containers must be less than %{max}"
|
22
|
+
max_memory_limit_error: "Total memory limit of containers must be less than %{max}"
|
24
23
|
uffizzi_core/user:
|
25
24
|
attributes:
|
26
25
|
email:
|
data/lib/uffizzi_core/version.rb
CHANGED
data/lib/uffizzi_core.rb
CHANGED
@@ -30,6 +30,9 @@ require 'faraday/follow_redirects'
|
|
30
30
|
module UffizziCore
|
31
31
|
mattr_accessor :dependencies, default: {
|
32
32
|
rbac: 'UffizziCore::Rbac::UserAccessService',
|
33
|
+
deployment_memory_module: 'UffizziCore::Deployment::MemoryService',
|
34
|
+
template_memory_module: 'UffizziCore::Template::MemoryService',
|
35
|
+
controller_settings: 'UffizziCore::ControllerSettingsService',
|
33
36
|
}
|
34
37
|
mattr_accessor :table_names, default: {
|
35
38
|
accounts: :uffizzi_core_accounts,
|
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.
|
4
|
+
version: 2.2.5
|
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-
|
12
|
+
date: 2023-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aasm
|
@@ -1023,13 +1023,16 @@ files:
|
|
1023
1023
|
- app/services/uffizzi_core/container_registry_service.rb
|
1024
1024
|
- app/services/uffizzi_core/container_service.rb
|
1025
1025
|
- app/services/uffizzi_core/controller_service.rb
|
1026
|
+
- app/services/uffizzi_core/controller_settings_service.rb
|
1026
1027
|
- app/services/uffizzi_core/deployment/domain_service.rb
|
1028
|
+
- app/services/uffizzi_core/deployment/memory_service.rb
|
1027
1029
|
- app/services/uffizzi_core/deployment_service.rb
|
1028
1030
|
- app/services/uffizzi_core/logs_service.rb
|
1029
1031
|
- app/services/uffizzi_core/manage_activity_items_service.rb
|
1030
1032
|
- app/services/uffizzi_core/project_service.rb
|
1031
1033
|
- app/services/uffizzi_core/repo_service.rb
|
1032
1034
|
- app/services/uffizzi_core/response_service.rb
|
1035
|
+
- app/services/uffizzi_core/template/memory_service.rb
|
1033
1036
|
- app/services/uffizzi_core/token_service.rb
|
1034
1037
|
- app/services/uffizzi_core/user_access_service.rb
|
1035
1038
|
- app/services/uffizzi_core/user_generator_service.rb
|
@@ -1063,6 +1066,7 @@ files:
|
|
1063
1066
|
- db/migrate/20230406154451_add_full_image_name_to_container.rb
|
1064
1067
|
- db/migrate/20230531135739_create_deployment_events.rb
|
1065
1068
|
- db/migrate/20230613101901_create_clusters.rb
|
1069
|
+
- db/migrate/20230711101901_add_host_to_clusters.rb
|
1066
1070
|
- db/seeds.rb
|
1067
1071
|
- lib/tasks/uffizzi_core_tasks.rake
|
1068
1072
|
- lib/uffizzi_core.rb
|