manageiq-postgres_ha_admin 3.2.0 → 3.2.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c6e01b8391b55a231ec81a0e050a97b2ccd02cc1fb576dc9272021f2130e593
|
4
|
+
data.tar.gz: d0b27f3b48ab6e843175d740e98bc6758d3facb9815c97dfa1de3147072f2fe2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dad10a7c85d3d5a30ced79733e407a84584fc3cd32ff6c0c77350cf3f84cfa3f43206ad2e806499ba8f28f6804296f8c7c4d45fe6ccb4fc09899ce62ca388540
|
7
|
+
data.tar.gz: 8b80044d67bf6f6215f59f3e21a9c88b9b32fb8d8eb402881e582a7c869eb25d81409076d4dde8def21778e831b391bd43704384a0ee317c5b9f16caa549f3af
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [3.2.1] - 2023-03-22
|
9
|
+
### Changed
|
10
|
+
- Improve failover logging [#39](https://github.com/ManageIQ/manageiq-postgres_ha_admin/pull/39)
|
11
|
+
|
8
12
|
## [3.2.0] - 2022-09-26
|
9
13
|
### Added
|
10
14
|
- Add simple prefix to all log lines [#38](https://github.com/ManageIQ/manageiq-postgres_ha_admin/pull/38)
|
@@ -61,7 +65,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
61
65
|
### Changed
|
62
66
|
- Make changes for upgrading repmgr to version 4 [#4](https://github.com/ManageIQ/manageiq-postgres_ha_admin/pull/4)
|
63
67
|
|
64
|
-
[Unreleased]: https://github.com/ManageIQ/manageiq-postgres_ha_admin/compare/v3.2.
|
68
|
+
[Unreleased]: https://github.com/ManageIQ/manageiq-postgres_ha_admin/compare/v3.2.1...master
|
69
|
+
[3.2.1]: https://github.com/ManageIQ/manageiq-postgres_ha_admin/compare/v3.2.0...v3.2.1
|
65
70
|
[3.2.0]: https://github.com/ManageIQ/manageiq-postgres_ha_admin/compare/v3.1.4...v3.2.0
|
66
71
|
[3.1.4]: https://github.com/ManageIQ/manageiq-postgres_ha_admin/compare/v3.1.3...v3.1.4
|
67
72
|
[3.1.3]: https://github.com/ManageIQ/manageiq-postgres_ha_admin/compare/v3.1.2...v3.1.3
|
@@ -26,23 +26,20 @@ module PostgresHaAdmin
|
|
26
26
|
begin
|
27
27
|
connection = pg_connection(handler.read)
|
28
28
|
if connection
|
29
|
-
server_store.update_servers(connection)
|
29
|
+
server_store.update_servers(connection, handler.name)
|
30
30
|
connection.finish
|
31
31
|
next
|
32
32
|
end
|
33
33
|
|
34
|
+
log_settings
|
35
|
+
server_store.log_current_server_store(handler.name)
|
34
36
|
logger.error("#{log_prefix(__callee__)} Primary Database is not available for #{handler.name}. Starting to execute failover...")
|
35
37
|
handler.do_before_failover
|
36
38
|
|
37
39
|
new_conn_info = execute_failover(handler, server_store)
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
handler.do_after_failover(new_conn_info)
|
42
|
-
else
|
43
|
-
# Add failover_failed hook if we have a use case in the future
|
44
|
-
logger.error("#{log_prefix(__callee__)} Failover failed")
|
45
|
-
end
|
41
|
+
# Upon success, we pass a connection hash
|
42
|
+
handler.do_after_failover(new_conn_info) if new_conn_info
|
46
43
|
rescue => e
|
47
44
|
logger.error("#{log_prefix(__callee__)} Received #{e.class} error while monitoring #{handler.name}: #{e.message}")
|
48
45
|
logger.error(e.backtrace)
|
@@ -70,6 +67,10 @@ module PostgresHaAdmin
|
|
70
67
|
|
71
68
|
private
|
72
69
|
|
70
|
+
def log_settings
|
71
|
+
logger.info("#{log_prefix(__callee__)} Current HA settings: FAILOVER_ATTEMPTS=#{@failover_attempts} DB_CHECK_FREQUENCY=#{@db_check_frequency} FAILOVER_CHECK_FREQUENCY=#{@failover_check_frequency}")
|
72
|
+
end
|
73
|
+
|
73
74
|
def initialize_settings(ha_admin_yml_file)
|
74
75
|
ha_admin_yml = {}
|
75
76
|
begin
|
@@ -81,7 +82,7 @@ module PostgresHaAdmin
|
|
81
82
|
@failover_attempts = ha_admin_yml['failover_attempts'] || FAILOVER_ATTEMPTS
|
82
83
|
@db_check_frequency = ha_admin_yml['db_check_frequency'] || DB_CHECK_FREQUENCY
|
83
84
|
@failover_check_frequency = ha_admin_yml['failover_check_frequency'] || FAILOVER_CHECK_FREQUENCY
|
84
|
-
|
85
|
+
log_settings
|
85
86
|
end
|
86
87
|
|
87
88
|
def any_known_standby?(handler, server_store)
|
@@ -97,7 +98,7 @@ module PostgresHaAdmin
|
|
97
98
|
# "Standby in recovery"
|
98
99
|
# "Exhausted all failover retry attempts" exceptions
|
99
100
|
unless any_known_standby?(handler, server_store)
|
100
|
-
logger.error("#{log_prefix(__callee__)} Cannot attempt failover without a known active standby. Please verify the database.yml and ensure the database is started.")
|
101
|
+
logger.error("#{log_prefix(__callee__)} Cannot attempt failover without a known active standby for #{handler.name}. Please verify the database.yml and ensure the database is started.")
|
101
102
|
return false
|
102
103
|
end
|
103
104
|
|
@@ -105,18 +106,20 @@ module PostgresHaAdmin
|
|
105
106
|
with_each_standby_connection(handler, server_store) do |connection, params|
|
106
107
|
next if database_in_recovery?(connection)
|
107
108
|
next unless server_store.host_is_primary?(params[:host], connection)
|
108
|
-
logger.info("#{log_prefix(__callee__)} Failing over to server using conninfo: #{params
|
109
|
-
server_store.update_servers(connection)
|
109
|
+
logger.info("#{log_prefix(__callee__)} Failing over for #{handler.name} to server using conninfo: #{server_store.sanitized_connection_parameters(params)}")
|
110
|
+
server_store.update_servers(connection, handler.name)
|
110
111
|
handler.write(params)
|
111
112
|
return params
|
112
113
|
end
|
113
114
|
sleep(failover_check_frequency)
|
114
115
|
end
|
116
|
+
logger.error("#{log_prefix(__callee__)} Failover failed for #{handler.name}")
|
115
117
|
false
|
116
118
|
end
|
117
119
|
|
118
120
|
def with_each_standby_connection(handler, server_store)
|
119
121
|
active_servers_conninfo(handler, server_store).each do |params|
|
122
|
+
logger.info("#{log_prefix(__callee__)} Checking active server for #{handler.name} using conninfo: #{server_store.sanitized_connection_parameters(params)}")
|
120
123
|
connection = pg_connection(params)
|
121
124
|
next if connection.nil?
|
122
125
|
begin
|
@@ -22,10 +22,11 @@ module PostgresHaAdmin
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def update_servers(connection)
|
25
|
+
def update_servers(connection, handler_name = "unspecified handler")
|
26
26
|
new_servers = query_repmgr(connection)
|
27
27
|
if servers_changed?(new_servers)
|
28
|
-
|
28
|
+
log_current_server_store(handler_name)
|
29
|
+
logger.info("#{log_prefix(__callee__)} Updating servers cache to #{sanitized_servers_array(new_servers)} for #{handler_name}")
|
29
30
|
@servers = new_servers
|
30
31
|
end
|
31
32
|
rescue IOError => err
|
@@ -42,6 +43,18 @@ module PostgresHaAdmin
|
|
42
43
|
false
|
43
44
|
end
|
44
45
|
|
46
|
+
def log_current_server_store(handler_name)
|
47
|
+
logger.info("#{log_prefix(__callee__)} Current servers cache: #{sanitized_servers_array(@servers)} for #{handler_name}")
|
48
|
+
end
|
49
|
+
|
50
|
+
def sanitized_servers_array(server_array)
|
51
|
+
server_array.collect { |p| sanitized_connection_parameters(p) }
|
52
|
+
end
|
53
|
+
|
54
|
+
def sanitized_connection_parameters(params)
|
55
|
+
params.reject { |k, _v| k.to_s == "password" }
|
56
|
+
end
|
57
|
+
|
45
58
|
private
|
46
59
|
|
47
60
|
def servers_changed?(new_servers)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manageiq-postgres_ha_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ManageIQ Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
209
|
- !ruby/object:Gem::Version
|
210
210
|
version: '0'
|
211
211
|
requirements: []
|
212
|
-
rubygems_version: 3.
|
212
|
+
rubygems_version: 3.2.33
|
213
213
|
signing_key:
|
214
214
|
specification_version: 4
|
215
215
|
summary: ManageIQ Postgres H.A. Admin
|