Skip to content

Commit

Permalink
Release 9.3.1
Browse files Browse the repository at this point in the history
* Resolves a potential issue during container destruction.
* Resolves an issue searching for large domains.
* include node_id in metadata service
* Updates to Monarx API.
  • Loading branch information
kwatson committed May 15, 2024
1 parent febee48 commit 6171b1d
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 40 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
# Change Log

## v9.3.1

- [CHANGE] Include `node_id` in metadata service.
- [FIX] Fix global search for long url's.
- [FIX] Resolve issues with monarx API.

***

## v9.3.0

- [FEATURE] Introducing Callbacks for the API. This allows you to receive a webhook from ComputeStacks when a api request is completed by a background worker.
- [FEATURE] Move acme validation IP to a database field on the region. This allows different IPs for different regions.

***

## v9.2.2

- [FEATURE] Added volume and backups api.

***

## v9.2.1

- [FEATURE] `on_latest_image` Boolean field added to container and bastion api calls. If false, there is a new image on the node and a rebuild will use the new image.

## v9.2.0

***

**YJIT and JEMALLOC for ComputeStacks Production Environments**

Please add the following to your `/etc/default/computestacks` file:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.3.0
9.3.1
2 changes: 1 addition & 1 deletion app/controllers/admin/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def create
elsif uuid_regex.match?(@q)
sparams[:volumes] = Volume.where(name: @q)
sparams[:deployments] = Deployment.where(token: @q)
elsif @q.split('.').count == 4 # IP!
elsif @q =~ Resolv::IPv4::Regex # IP Address
sparams[:cidr] = Network::Cidr.where(cidr: @q) + Node.where( Arel.sql(%Q(primary_ip = '#{@q}' OR public_ip = '#{@q}')) )
elsif q_filter == 'user'
sparams[:users] = User.search_by @q
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create
if uuid_regex.match?(@q)
sparams[:volumes] = Volume.find_all_for(current_user).where(name: @q)
sparams[:deployments] = Deployment.find_all_for(current_user).where(token: @q)
elsif @q.split('.').count == 4 # IP!
elsif @q =~ Resolv::IPv4::Regex # IP Address
sparams[:cidr] = Network::Cidr.where(cidr: @q)
else
sparams[:deployments] = Deployment.find_all_for(current_user).where Arel.sql %Q(lower(deployments.name) ~ '#{@q}')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,22 @@ def monarx_agent_id

result = HTTP.timeout(30)
.headers(container_image_plugin.monarx_api_headers)
.get "#{container_image_plugin.monarx_enterprise_url}/agent", params: { filter: "tags==#{container_service.name}" }
.get "#{container_image_plugin.monarx_enterprise_url}/agent", params: { filter: "all_tags==#{container_service.name}" }

if result.status.success?
begin
response = Oj.load result.body.to_s
rescue
return nil
end
return nil if response.dig("_embedded", "items").nil?
return nil if response["_embedded"]["items"].empty?
active_container_names = containers.pluck(:name)
mid = nil
response["_embedded"]["items"].each do |i|
if active_container_names.include?(i['host_id'])
mid = i['id']
break
end
end
mid
else
nil
return nil unless result.status.success?

begin
response = Oj.load result.body.to_s
rescue
return nil
end
return nil if response.dig("_embedded", "items").nil?
return nil if response["_embedded"]["items"].empty?

monarx_service = response["_embedded"]["items"].select { |i| container_service.name == i['host_id']}.first
return nil if monarx_service.nil?

monarx_service["id"]
end
end

Expand All @@ -85,19 +79,20 @@ def monarx_stats
return nil if monarx_agent_id.nil?
result = HTTP.timeout(30)
.headers(container_image_plugin.monarx_api_headers)
.get "#{container_image_plugin.monarx_enterprise_url}/agent-file/metrics/agent-file-agent-classification", params: { filter: "agent_id==#{monarx_agent_id}"}
if result.status.success?
begin
response = Oj.load result.body.to_s
rescue
return nil
end
return nil if response.empty?
return nil if response[0]['counts'].nil?
response[0]
else
nil
.get "#{container_image_plugin.monarx_enterprise_url}/agent-file/metrics/agent-file-agent-classification", params: { filter: "all_tags==#{container_service.name}" }

return nil unless result.status.success?

begin
response = Oj.load result.body.to_s
rescue
return nil
end

return nil if response.empty?
return nil if response[0]['counts'].nil?

response[0]
end
end

Expand Down
2 changes: 2 additions & 0 deletions app/models/concerns/containers/container_metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def metric_mem_perc
return 0.0 if m.nil?
usage = (m[:memory] / Numeric::MEGABYTE) / memory
(usage * 100).round(2)
rescue
0.0
end

def metric_mem_throttled(start_time, end_time)
Expand Down
8 changes: 4 additions & 4 deletions app/services/project_services/store_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def overview_services
s = []
deployment.services.each do |i|
containers = i.containers.map do |c|
{ id: c.id, name: c.name, ip: c.ip_address&.ipaddr }
{ id: c.id, name: c.name, ip: c.ip_address&.ipaddr, node_id: c.node.id }
end
ingress_rules = i.ingress_rules.map do |c|
{
Expand Down Expand Up @@ -77,10 +77,10 @@ def overview_services
category: i.container_image.category,
tags: i.container_image.tags
},
containers: containers,
ingress_rules: ingress_rules,
containers:,
ingress_rules:,
package: package_data,
settings: settings
settings:
}
end
s
Expand Down
8 changes: 8 additions & 0 deletions db/migrate/20240509174702_update_project_metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class UpdateProjectMetadata < ActiveRecord::Migration[7.1]
def change
Deployment.all.each do |i|
ProjectServices::StoreMetadata.new(i).perform
sleep 0.5 # Lets not flood consul too quickly.
end
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_04_19_153846) do
ActiveRecord::Schema[7.1].define(version: 2024_05_09_174702) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "uuid-ossp"
Expand Down

0 comments on commit 6171b1d

Please sign in to comment.