diff --git a/db/migrate/20250121104357_add_regcode_to_systems.rb b/db/migrate/20250121104357_add_regcode_to_systems.rb new file mode 100644 index 000000000..8461bbe51 --- /dev/null +++ b/db/migrate/20250121104357_add_regcode_to_systems.rb @@ -0,0 +1,10 @@ +class AddRegcodeToSystems < ActiveRecord::Migration[6.1] + def up + add_column :systems, :pubcloud_reg_code, :string + change_column_default :systems, :pubcloud_reg_code, nil + end + + def down + remove_column :systems, :pubcloud_reg_code + end +end diff --git a/engines/instance_verification/config/environments/production.rb b/engines/instance_verification/config/environments/production.rb index f71e6354f..fc8e30494 100644 --- a/engines/instance_verification/config/environments/production.rb +++ b/engines/instance_verification/config/environments/production.rb @@ -2,13 +2,24 @@ module InstanceVerification class Application < Rails::Application config.cache_config_file = '/var/lib/rmt/rmt-cache-trim.sh' - config.repo_cache_dir = Rails.root.join('tmp/cache/repository') + repo_cache_base_dir = 'tmp/cache/repository' + config.repo_payg_cache_dir = Rails.root.join("#{repo_cache_base_dir}/payg") + config.repo_byos_cache_dir = Rails.root.join("#{repo_cache_base_dir}/byos") + config.repo_hybrid_cache_dir = Rails.root.join("#{repo_cache_base_dir}/hybrid") config.registry_cache_dir = Rails.root.join('tmp/cache/registry') + config.expire_repo_payg_cache = 20 + config.expire_repo_byos_cache = 1440 # 24h in minutes + config.expire_repo_hybrid_cache = 1440 # 24h in minutes + config.expire_registry_cache = 840 # 8h in minutes cache_config_content = [ - "REPOSITORY_CLIENT_CACHE_DIRECTORY=#{config.repo_cache_dir}", - 'REPOSITORY_CACHE_EXPIRY_MINUTES=20', + "REPOSITORY_CLIENT_PAYG_CACHE_DIRECTORY=#{config.repo_payg_cache_dir}", + "REPOSITORY_PAYG_CACHE_EXPIRY_MINUTES=#{config.expire_repo_payg_cache}", + "REPOSITORY_CLIENT_BYOS_CACHE_DIRECTORY=#{config.repo_byos_cache_dir}", + "REPOSITORY_BYOS_CACHE_EXPIRY_MINUTES=#{config.expire_repo_byos_cache}", + "REPOSITORY_CLIENT_HYBRID_CACHE_DIRECTORY=#{config.repo_hybrid_cache_dir}", + "REPOSITORY_HYBRID_CACHE_EXPIRY_MINUTES=#{config.expire_repo_hybrid_cache}", "REGISTRY_CLIENT_CACHE_DIRECTORY=#{config.registry_cache_dir}", - "REGISTRY_CACHE_EXPIRY_MINUTES=#{Settings[:registry].try(:token_expiration) || 480}" # 480: 8 hours in minutes + "REGISTRY_CACHE_EXPIRY_MINUTES=#{Settings[:registry].try(:token_expiration) || config.expire_registry_cache}" # 480: 8 hours in minutes ].join("\n") File.write(config.cache_config_file, cache_config_content) end diff --git a/engines/registration_sharing/app/controllers/registration_sharing/rmt_to_rmt_controller.rb b/engines/registration_sharing/app/controllers/registration_sharing/rmt_to_rmt_controller.rb index 66cb118d2..a77c1b424 100644 --- a/engines/registration_sharing/app/controllers/registration_sharing/rmt_to_rmt_controller.rb +++ b/engines/registration_sharing/app/controllers/registration_sharing/rmt_to_rmt_controller.rb @@ -7,7 +7,11 @@ class RmtToRmtController < ApplicationController def create System.transaction do - system = System.find_or_create_by(login: params[:login]) + system = System.find_or_create_by( + login: params[:login], + password: params[:password], + system_token: params[:system_token] + ) system.update(system_params) # TODO: remove this block when proxy_byos column gets dropped diff --git a/engines/registration_sharing/package/rmt-server-trim-cache.service b/engines/registration_sharing/package/rmt-server-trim-cache.service index 82b898e12..9b9a13a4d 100644 --- a/engines/registration_sharing/package/rmt-server-trim-cache.service +++ b/engines/registration_sharing/package/rmt-server-trim-cache.service @@ -8,7 +8,9 @@ Type=oneshot Restart=no Environment="LOG_TO_JOURNALD=1" "LANG=en" EnvironmentFile=/var/lib/rmt/rmt-cache-trim.sh -ExecStart=find ${REPOSITORY_CLIENT_CACHE_DIRECTORY} -mmin +${REPOSITORY_CACHE_EXPIRY_MINUTES} -type f -delete +ExecStart=find ${REPOSITORY_CLIENT_PAYG_CACHE_DIRECTORY} -mmin +${REPOSITORY_PAYG_CACHE_EXPIRY_MINUTES} -type f -delete +ExecStart=find ${REPOSITORY_CLIENT_BYOS_CACHE_DIRECTORY} -mmin +${REPOSITORY_BYOS_CACHE_EXPIRY_MINUTES} -type f -delete +ExecStart=find ${REPOSITORY_CLIENT_HYBRID_CACHE_DIRECTORY} -mmin +${REPOSITORY_HYBRID_CACHE_EXPIRY_MINUTES} -type f -delete ExecStart=find ${REGISTRY_CLIENT_CACHE_DIRECTORY} -mmin +${REGISTRY_CACHE_EXPIRY_MINUTES} -type f -delete [Install] diff --git a/engines/registration_sharing/spec/requests/registration_sharing/rmt_to_rmt_controller_spec.rb b/engines/registration_sharing/spec/requests/registration_sharing/rmt_to_rmt_controller_spec.rb index d08c3a722..202482dfe 100644 --- a/engines/registration_sharing/spec/requests/registration_sharing/rmt_to_rmt_controller_spec.rb +++ b/engines/registration_sharing/spec/requests/registration_sharing/rmt_to_rmt_controller_spec.rb @@ -22,6 +22,10 @@ module RegistrationSharing describe '#create byos' do before do + allow(System).to receive(:find_or_create_by).with( + login: login_byos, password: password, system_token: nil + ).and_call_original + post( '/api/regsharing', params: { diff --git a/engines/scc_proxy/lib/scc_proxy/engine.rb b/engines/scc_proxy/lib/scc_proxy/engine.rb index e728fa98f..1169ff942 100644 --- a/engines/scc_proxy/lib/scc_proxy/engine.rb +++ b/engines/scc_proxy/lib/scc_proxy/engine.rb @@ -380,8 +380,7 @@ def scc_upgrade logger.info "Upgrading system to product #{@product.product_string} to SCC" auth = nil auth = request.headers['HTTP_AUTHORIZATION'] if request.headers.include?('HTTP_AUTHORIZATION') - mode = 'byos' if @system.byos? - SccProxy.scc_upgrade(auth, @product, @system.login, mode, logger) + SccProxy.scc_upgrade(auth, @product, @system.login, @system.proxy_byos_mode, logger) logger.info "System #{@system.login} successfully upgraded with SCC" end diff --git a/package/obs/rmt-server.changes b/package/obs/rmt-server.changes index 9c23f3f1d..e8e5a5b06 100644 --- a/package/obs/rmt-server.changes +++ b/package/obs/rmt-server.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Jan 21 10:49:54 UTC 2025 - Jesús Bermúdez Velázquez + +- Version 2.22 + * rmt-server-pubcloud: + * Add pubcloud_reg_code column to systems table + * Add cache directories and their expiration times to the scrubber + ------------------------------------------------------------------- Fri Jan 03 10:44:00 UTC 2025 - Luís Caparroz