Skip to content

Commit

Permalink
Add a new parameter to control pod xlog updates
Browse files Browse the repository at this point in the history
Add prevent_xlog_position_only_pod_updates K8s parameter.
  • Loading branch information
alexeyklyukin committed May 23, 2024
1 parent 8bb173d commit d2d53c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions patroni/dcs/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from ..exceptions import DCSError
from ..postgresql.mpp import AbstractMPP
from ..utils import deep_compare, iter_response_objects, keepalive_socket_options, \
Retry, RetryFailedError, tzutc, uri, USER_AGENT
parse_bool, Retry, RetryFailedError, tzutc, uri, USER_AGENT
if TYPE_CHECKING: # pragma: no cover
from ..config import Config

Expand Down Expand Up @@ -758,6 +758,8 @@ def __init__(self, config: Dict[str, Any], mpp: AbstractMPP) -> None:
self._standby_leader_label_value = config.get('standby_leader_label_value', 'master')
self._tmp_role_label = config.get('tmp_role_label')
self._ca_certs = os.environ.get('PATRONI_KUBERNETES_CACERT', config.get('cacert')) or SERVICE_CERT_FILENAME
self._prevent_xlog_position_only_pod_updates = bool(
parse_bool(config.get('prevent_xlog_position_only_pod_updates')))
super(Kubernetes, self).__init__({**config, 'namespace': ''}, mpp)
if self._mpp.is_enabled():
self._labels[self._mpp.k8s_group_label] = str(self._mpp.group)
Expand Down Expand Up @@ -1323,7 +1325,7 @@ def touch_member(self, data: Dict[str, Any]) -> bool:
pod_labels = member and member.data.pop('pod_labels', None)
# XXX: add a parameter here
saved_xlog_location = data.get('xlog_location')
if saved_xlog_location is not None and True:
if self._prevent_xlog_position_only_pod_updates and saved_xlog_location is not None:
# avoid updating if the only change is the xlog location
if member.data.get('xlog_location') is not None:

Check failure on line 1330 in patroni/dcs/kubernetes.py

View workflow job for this annotation

GitHub Actions / pyright

"data" is not a known member of "None" (reportOptionalMemberAccess)
data['xlog_location'] = member.data['xlog_location']

Check failure on line 1331 in patroni/dcs/kubernetes.py

View workflow job for this annotation

GitHub Actions / pyright

"data" is not a known member of "None" (reportOptionalMemberAccess)
Expand Down
1 change: 1 addition & 0 deletions patroni/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,7 @@ def validate_watchdog_mode(value: Any) -> None:
Optional("ports"): [{"name": str, "port": IntValidator(max=65535, expected_type=int, raise_assert=True)}],
Optional("cacert"): str,
Optional("retriable_http_codes"): Or(int, [int]),
Optional('prevent_xlog_position_only_pod_updates'): bool
},
}),
Optional("citus"): {
Expand Down

0 comments on commit d2d53c0

Please sign in to comment.