Skip to content

Commit 365b24a

Browse files
author
yb
committed
resolve main and V3.0.0 conflicts
2 parents 68dbb06 + 01a4a14 commit 365b24a

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

platforms/kubernetes/postgres-operator/deploy/postgresql.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ spec:
4646
- enable_seqscan=on
4747
podspec:
4848
terminationGracePeriodSeconds: 60
49+
# priorityClassName: high-priority
4950
containers:
5051
- image: radondb-postgresql:15.0-v1.1.0
5152
imagePullPolicy: IfNotPresent

platforms/kubernetes/postgres-operator/postgres/constants.py

+5
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@
123123
SPEC_ANTIAFFINITY_PODANTIAFFINITYTERM = "podAntiAffinityTerm"
124124
SPEC_ANTIAFFINITY_TOPOLOGYKEY = "topologyKey"
125125

126+
# pod PriorityClass
127+
SPEC_POD_PRIORITY_CLASS = "priorityClassName"
128+
SPEC_POD_PRIORITY_CLASS_SCOPE_NODE = "system-node-critical"
129+
SPEC_POD_PRIORITY_CLASS_SCOPE_CLUSTER = "system-cluster-critical"
130+
126131
# time
127132
SECONDS = 1
128133
MINUTES = SECONDS * 60

platforms/kubernetes/postgres-operator/postgres/handle.py

+36
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
HOURS,
140140
DAYS,
141141
UPDATE_TOLERATION,
142+
SPEC_POD_PRIORITY_CLASS,
143+
SPEC_POD_PRIORITY_CLASS_SCOPE_NODE,
144+
SPEC_POD_PRIORITY_CLASS_SCOPE_CLUSTER,
142145
)
143146

144147
PGLOG_DIR = "log"
@@ -680,6 +683,8 @@ def create_statefulset(
680683
"serviceName"] = statefulset_name_get_service_name(name)
681684
podspec = podspec_need_copy.copy()
682685
podspec["restartPolicy"] = "Always"
686+
podspec.setdefault(SPEC_POD_PRIORITY_CLASS,
687+
SPEC_POD_PRIORITY_CLASS_SCOPE_CLUSTER)
683688
antiaffinity = antiaffinity_need_copy.copy()
684689
is_required = antiaffinity[
685690
SPEC_ANTIAFFINITY_POLICY] == SPEC_ANTIAFFINITY_REQUIRED
@@ -3011,6 +3016,37 @@ def update_number_sync_standbys(
30113016
break
30123017
autofailover_conns.free_conns()
30133018

3019+
def update_number_sync_standbys(
3020+
meta: kopf.Meta,
3021+
spec: kopf.Spec,
3022+
patch: kopf.Patch,
3023+
status: kopf.Status,
3024+
logger: logging.Logger,
3025+
) -> None:
3026+
mode, autofailover_replicas, readwrite_replicas, readonly_replicas = get_replicas(
3027+
spec)
3028+
3029+
pg_nodes = readwrite_replicas + readonly_replicas
3030+
number_sync = readwrite_replicas + readonly_replicas if spec[POSTGRESQL][READONLYINSTANCE][STREAMING] == STREAMING_SYNC else readwrite_replicas
3031+
expect_number = number_sync - 2
3032+
if expect_number < 0:
3033+
expect_number = 0
3034+
3035+
if pg_nodes >= 2:
3036+
autofailover_conns = connections(spec, meta, patch,
3037+
get_field(AUTOFAILOVER), False,
3038+
None, logger, None, status, False)
3039+
cmd = [
3040+
"pgtools", "-S",
3041+
"' formation number-sync-standbys " + str(expect_number) + PRIMARY_FORMATION + "'"
3042+
]
3043+
logger.info(f"set number-sync-standbys with cmd {cmd}")
3044+
output = exec_command(autofailover_conns.get_conns()[0], cmd, logger, interrupt=False)
3045+
if output.find(SUCCESS) == -1:
3046+
logger.error(
3047+
f"set number-sync-standbys failed {cmd} {output}")
3048+
autofailover_conns.free_conns()
3049+
30143050

30153051
def update_streaming(
30163052
meta: kopf.Meta,

0 commit comments

Comments
 (0)