Skip to content

Commit 737e11c

Browse files
committed
mix update.
1 parent 434dd8d commit 737e11c

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ spec:
159159
properties:
160160
image:
161161
type: string
162+
name:
163+
type: string
162164
resources:
163165
type: object
164166
x-kubernetes-preserve-unknown-fields: true
@@ -220,6 +222,8 @@ spec:
220222
properties:
221223
image:
222224
type: string
225+
name:
226+
type: string
223227
resources:
224228
type: object
225229
x-kubernetes-preserve-unknown-fields: true
@@ -262,6 +266,8 @@ spec:
262266
properties:
263267
image:
264268
type: string
269+
name:
270+
type: string
265271
resources:
266272
type: object
267273
x-kubernetes-preserve-unknown-fields: true

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

+5-16
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ spec:
3131
podspec:
3232
terminationGracePeriodSeconds: 60
3333
containers:
34-
- image: radondb-postgresql:12.9-v1.0.0
34+
- image: docker.io/library/radondb-postgresql:14.5-v1.0.0
3535
imagePullPolicy: IfNotPresent
3636
name: postgresql #can't change the name
3737
volumeMounts:
3838
- name: data # can't change the name
3939
mountPath: /var/lib/postgresql/data
4040
resources:
41-
requests:
42-
memory: "200Mi"
43-
cpu: "0.2"
4441
limits:
4542
memory: "200Mi"
4643
cpu: "0.2"
@@ -57,8 +54,6 @@ spec:
5754
admin:
5855
- name: root
5956
password: root
60-
- name: root1
61-
password: root1
6257
normal:
6358
- name: lzzhang
6459
password: lzzhang
@@ -74,19 +69,16 @@ spec:
7469
podspec:
7570
terminationGracePeriodSeconds: 60
7671
containers:
77-
- image: radondb-postgresql:12.9-v1.0.0
72+
- image: docker.io/library/radondb-postgresql:14.5-v1.0.0
7873
imagePullPolicy: IfNotPresent
7974
name: postgresql #can't change the name
8075
volumeMounts:
8176
- name: data # can't change the name
8277
mountPath: /var/lib/postgresql/data
8378
resources:
84-
requests:
85-
memory: "200Mi"
86-
cpu: "0.3"
8779
limits:
8880
memory: "200Mi"
89-
cpu: "0.3"
81+
cpu: "0.2"
9082
volumeClaimTemplates:
9183
- metadata:
9284
name: data
@@ -101,19 +93,16 @@ spec:
10193
podspec:
10294
terminationGracePeriodSeconds: 60
10395
containers:
104-
- image: radondb-postgresql:12.9-v1.0.0
96+
- image: docker.io/library/radondb-postgresql:14.5-v1.0.0
10597
imagePullPolicy: IfNotPresent
10698
name: postgresql #can't change the name
10799
volumeMounts:
108100
- name: data # can't change the name
109101
mountPath: /var/lib/postgresql/data
110102
resources:
111-
requests:
112-
memory: "200Mi"
113-
cpu: "0.3"
114103
limits:
115104
memory: "200Mi"
116-
cpu: "0.3"
105+
cpu: "0.2"
117106
volumeClaimTemplates:
118107
- metadata:
119108
name: data

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
SPEC = "spec"
1919
CONTAINERS = "containers"
2020
CONTAINER_NAME = "name"
21-
POSTGRESQL_CONTAINER = "postgresql"
21+
PODSPEC_CONTAINERS_POSTGRESQL_CONTAINER = "postgresql"
2222
PRIME_SERVICE_PORT_NAME = "prime"
2323
HBAS = "hbas"
2424
CONFIGS = "configs"

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

+16-10
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
SPEC,
3030
CONTAINERS,
3131
CONTAINER_NAME,
32-
POSTGRESQL_CONTAINER,
32+
PODSPEC_CONTAINERS_POSTGRESQL_CONTAINER,
3333
PRIME_SERVICE_PORT_NAME,
3434
HBAS,
3535
CONFIGS,
@@ -527,13 +527,17 @@ def waiting_instance_ready(conns: InstanceConnections, logger: logging.Logger):
527527

528528

529529
def create_statefulset(
530+
meta: kopf.Meta,
531+
spec: kopf.Spec,
532+
patch: kopf.Patch,
533+
status: kopf.Status,
534+
logger: logging.Logger,
530535
name: str,
531536
namespace: str,
532537
labels: LabelType,
533538
podspec_need_copy: TypedDict,
534539
vct: TypedDict,
535540
env: TypedDict,
536-
logger: logging.Logger,
537541
) -> None:
538542

539543
apps_v1_api = client.AppsV1Api()
@@ -550,7 +554,7 @@ def create_statefulset(
550554
podspec = podspec_need_copy.copy()
551555
podspec["restartPolicy"] = "Always"
552556
for container in podspec[CONTAINERS]:
553-
if container[CONTAINER_NAME] == POSTGRESQL_CONTAINER:
557+
if container[CONTAINER_NAME] == PODSPEC_CONTAINERS_POSTGRESQL_CONTAINER:
554558
container["args"] = ["auto_failover"]
555559
container["env"] = env
556560
container["readinessProbe"] = {
@@ -655,7 +659,7 @@ def create_postgresql(
655659
machine_data_path = operator_config.DATA_PATH_POSTGRESQL
656660

657661
for container in localspec[PODSPEC][CONTAINERS]:
658-
if container[CONTAINER_NAME] == POSTGRESQL_CONTAINER:
662+
if container[CONTAINER_NAME] == PODSPEC_CONTAINERS_POSTGRESQL_CONTAINER:
659663
postgresql_image = container[IMAGE]
660664

661665
if mode == MACHINE_MODE:
@@ -681,12 +685,14 @@ def create_postgresql(
681685
for config in configs:
682686
name = config.split("=")[0].strip()
683687
value = config[config.find("=") + 1:].strip()
684-
config = name + "=" + value
688+
685689
if name in PG_CONFIG_IGNORE:
686690
continue
691+
687692
if field == get_field(AUTOFAILOVER) and name == 'port':
688-
continue
693+
value = str(AUTO_FAILOVER_PORT)
689694

695+
config = name + "=" + value
690696
if mode == MACHINE_MODE:
691697
machine_env += PG_CONFIG_PREFIX + config + "\n"
692698
else:
@@ -896,9 +902,9 @@ def create_postgresql(
896902
statefulset_name_get_service_name(name),
897903
statefulset_name_get_external_service_name(name), namespace,
898904
labels, logger, meta)
899-
create_statefulset(name, namespace, labels, localspec[PODSPEC],
900-
localspec[VOLUMECLAIMTEMPLATES], k8s_env,
901-
logger)
905+
create_statefulset(meta, spec, patch, status, logger,
906+
name, namespace, labels, localspec[PODSPEC],
907+
localspec[VOLUMECLAIMTEMPLATES], k8s_env)
902908

903909
# wait primary node create finish
904910
if wait_primary == True and field == get_field(
@@ -2279,7 +2285,7 @@ def correct_user_password(
22792285
PASSWORD_FAILED_MESSAGEd = "password authentication failed for user"
22802286

22812287
if get_conn_role(conn) == AUTOFAILOVER:
2282-
port = 55555
2288+
port = AUTO_FAILOVER_PORT
22832289
user = AUTOCTL_NODE
22842290
password = patch.status.get(AUTOCTL_NODE)
22852291
if password == None:

0 commit comments

Comments
 (0)