smart_proxy_container_gateway 3.4.1 → 3.5.0

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: 18efc25667d7b93246b04af0253ff987efa2baca6d20f6b1ca7ee65f3e94dbe5
4
- data.tar.gz: a080fe48ebe31b22c4e16df541b42f3799dbd9f555b10bdff6a5254fd7f303b0
3
+ metadata.gz: 715c97cadccbfc6c3c06c9aeb85e2b17115d10f045ee042d73eb8c236e669b43
4
+ data.tar.gz: d3b12b7ba4bb3c32afe6fe11926cc749b721f0cbcbe1f1b587ef6bfaf5222c03
5
5
  SHA512:
6
- metadata.gz: d574b549219ebe60652ae47f6af6438cb0727fb61d6063cca939295fea68d598f83f50c5d70996d8a1c208ccdec77251bdb2aac68768dd81e62def245fe884be
7
- data.tar.gz: c9daa667b3af3337bdea2cfb7fcba4042fd8f0d8a2eb7351d71194b12e05f546f331e113ba289d8b3e0c1ab8537eb5efcf4bb59b3a2e5c44e35c7ae3d0ec27a9
6
+ metadata.gz: 6b3a173a1d5bacb8962effdd385b2513abea50c367f6b69f316a3e2b6a52d9f251319b6046c2cc7d3499a04abe9114229c537320b1bbb384a852d0cafc66966f
7
+ data.tar.gz: 13c04e0b4e0cc47af5fc53e9321bba2e3ae55cf681194e50bc4a08b8a0495a495985be5081843aed823a383a82d0a29dc8f8cbf46ade1a01d2d4acbd248076b8
@@ -7,7 +7,9 @@ module Proxy
7
7
 
8
8
  default_settings :pulp_endpoint => "https://#{`hostname`.strip}",
9
9
  :katello_registry_path => '/v2/',
10
- :sqlite_timeout => 30_000
10
+ :sqlite_timeout => 30_000,
11
+ :db_max_connections => 30,
12
+ :db_pool_timeout => 30
11
13
 
12
14
  # Load defaults that copy values from SETTINGS. This is done as
13
15
  # programmable settings since SETTINGS isn't initialized during plugin
@@ -36,7 +38,10 @@ module Proxy
36
38
  "sqlite://#{settings[:sqlite_db_path]}?timeout=#{settings[:sqlite_timeout]}"
37
39
  end
38
40
 
39
- Proxy::ContainerGateway::Database.new(connection_string, settings[:sqlite_db_path])
41
+ Proxy::ContainerGateway::Database.new(connection_string,
42
+ settings[:db_max_connections],
43
+ settings[:db_pool_timeout],
44
+ settings[:sqlite_db_path])
40
45
  end)
41
46
  container_instance.singleton_dependency :container_gateway_main_impl, (lambda do
42
47
  Proxy::ContainerGateway::ContainerGatewayMain.new(
@@ -262,7 +262,8 @@ module Proxy
262
262
  database.connection.transaction(isolation: :serializable, retry_on: [Sequel::SerializationFailure]) do
263
263
  hosts_table = database.connection[:hosts]
264
264
  hosts_table.delete
265
- hosts_table.import(%i[uuid], hosts.map { |host| [host['uuid']] })
265
+ valid_hosts = hosts.filter_map { |host| [host['uuid']] if host['uuid'].present? }
266
+ hosts_table.import(%i[uuid], valid_hosts) unless valid_hosts.empty?
266
267
  end
267
268
  {}
268
269
  end
@@ -277,6 +278,8 @@ module Proxy
277
278
  do_authorize_any
278
279
  params['hosts'].flat_map do |host_map|
279
280
  host_map.filter_map do |host_uuid, repos|
281
+ next if host_uuid.nil? || host_uuid.to_s.strip.empty?
282
+
280
283
  if repos.nil? || repos.empty?
281
284
  repo_names = []
282
285
  else
@@ -214,6 +214,8 @@ module Proxy
214
214
  end
215
215
 
216
216
  def build_host_entries(hosts, repositories, host_uuid, repos)
217
+ return if host_uuid.nil? || host_uuid.to_s.strip.empty?
218
+
217
219
  host = hosts[{ uuid: host_uuid }]
218
220
  return unless host
219
221
  return if repos.nil? || repos.empty?
@@ -232,7 +234,11 @@ module Proxy
232
234
  end
233
235
 
234
236
  def update_host_repositories(uuid, repositories)
237
+ return if uuid.nil? || uuid.to_s.strip.empty?
238
+
235
239
  host = find_or_create_host(uuid)
240
+ return unless host
241
+
236
242
  hosts_repositories = database.connection[:hosts_repositories]
237
243
  database.connection.transaction(isolation: :serializable,
238
244
  retry_on: [Sequel::SerializationFailure],
@@ -4,9 +4,9 @@ module Proxy
4
4
  class Database
5
5
  attr_reader :connection
6
6
 
7
- def initialize(connection_string, prior_sqlite_db_path = nil)
7
+ def initialize(connection_string, db_max_connections, db_pool_timeout, prior_sqlite_db_path = nil)
8
8
  Sequel.default_timezone = :local
9
- @connection = Sequel.connect(connection_string)
9
+ @connection = Sequel.connect(connection_string, max_connections: db_max_connections, pool_timeout: db_pool_timeout)
10
10
  if connection_string.start_with?('sqlite://')
11
11
  @connection.run("PRAGMA foreign_keys = ON;")
12
12
  @connection.run("PRAGMA journal_mode = wal;")
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module ContainerGateway
3
- VERSION = '3.4.1'.freeze
3
+ VERSION = '3.5.0'.freeze
4
4
  end
5
5
  end
@@ -9,6 +9,8 @@
9
9
  #:katello_registry_path: '/v2/'
10
10
 
11
11
  #:db_connection_string: postgresql:///container_gateway
12
+ #:db_max_connections: 30
13
+ #:db_pool_timeout: 30
12
14
 
13
15
  # Legacy options
14
16
  #:sqlite_db_path: '/var/lib/foreman-proxy/smart_proxy_container_gateway.db'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_container_gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Ballou
@@ -109,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
- version: '2.7'
112
+ version: '3.0'
113
113
  required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="