Skip to content

Commit c14808e

Browse files
authored
Merge branch 'main' into develop-AntiAffinity
2 parents eb0c222 + bacf4cb commit c14808e

File tree

6 files changed

+24
-22
lines changed

6 files changed

+24
-22
lines changed

image/postgres-operator/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COPY postgres /src
1010
RUN python -m pip install --trusted-host mirrors.aliyun.com --upgrade pip \
1111
-i http://mirrors.aliyun.com/pypi/simple/
1212
RUN python -m pip install --trusted-host mirrors.aliyun.com --no-cache-dir \
13-
Kubernetes kopf wrapt paramiko \
13+
Kubernetes==21.7.0 kopf==1.35.5 wrapt paramiko \
1414
-i http://mirrors.aliyun.com/pypi/simple/
1515

1616
ENTRYPOINT ["kopf", "run", "--standalone", "-A"]

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

Lines changed: 6 additions & 0 deletions
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/postgres-operator.yaml.template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ spec:
176176
properties:
177177
image:
178178
type: string
179+
name:
180+
type: string
179181
resources:
180182
type: object
181183
x-kubernetes-preserve-unknown-fields: true
@@ -237,6 +239,8 @@ spec:
237239
properties:
238240
image:
239241
type: string
242+
name:
243+
type: string
240244
resources:
241245
type: object
242246
x-kubernetes-preserve-unknown-fields: true
@@ -279,6 +283,8 @@ spec:
279283
properties:
280284
image:
281285
type: string
286+
name:
287+
type: string
282288
resources:
283289
type: object
284290
x-kubernetes-preserve-unknown-fields: true

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ spec:
4242
- name: data # can't change the name
4343
mountPath: /var/lib/postgresql/data
4444
resources:
45-
requests:
46-
memory: "200Mi"
47-
cpu: "0.2"
4845
limits:
4946
memory: "200Mi"
5047
cpu: "0.2"
@@ -61,8 +58,6 @@ spec:
6158
admin:
6259
- name: root
6360
password: root
64-
- name: root1
65-
password: root1
6661
normal:
6762
- name: lzzhang
6863
password: lzzhang
@@ -85,12 +80,9 @@ spec:
8580
- name: data # can't change the name
8681
mountPath: /var/lib/postgresql/data
8782
resources:
88-
requests:
89-
memory: "200Mi"
90-
cpu: "0.3"
9183
limits:
9284
memory: "200Mi"
93-
cpu: "0.3"
85+
cpu: "0.2"
9486
volumeClaimTemplates:
9587
- metadata:
9688
name: data
@@ -112,12 +104,9 @@ spec:
112104
- name: data # can't change the name
113105
mountPath: /var/lib/postgresql/data
114106
resources:
115-
requests:
116-
memory: "200Mi"
117-
cpu: "0.3"
118107
limits:
119108
memory: "200Mi"
120-
cpu: "0.3"
109+
cpu: "0.2"
121110
volumeClaimTemplates:
122111
- metadata:
123112
name: data

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
SPEC,
3131
CONTAINERS,
3232
CONTAINER_NAME,
33-
POSTGRESQL_CONTAINER,
33+
PODSPEC_CONTAINERS_POSTGRESQL_CONTAINER,
3434
PRIME_SERVICE_PORT_NAME,
3535
HBAS,
3636
CONFIGS,
@@ -578,7 +578,6 @@ def create_statefulset(
578578
vct: TypedDict,
579579
antiaffinity_need_copy: TypedDict,
580580
env: TypedDict,
581-
logger: logging.Logger,
582581
) -> None:
583582

584583
apps_v1_api = client.AppsV1Api()
@@ -602,7 +601,7 @@ def create_statefulset(
602601
podspec.setdefault("affinity", {}).setdefault("podAntiAffinity", {})[spec_antiaffinity] = \
603602
antiaffinity
604603
for container in podspec[CONTAINERS]:
605-
if container[CONTAINER_NAME] == POSTGRESQL_CONTAINER:
604+
if container[CONTAINER_NAME] == PODSPEC_CONTAINERS_POSTGRESQL_CONTAINER:
606605
container["args"] = ["auto_failover"]
607606
container["env"] = env
608607
container["readinessProbe"] = {
@@ -761,7 +760,7 @@ def create_postgresql(
761760
machine_data_path = operator_config.DATA_PATH_POSTGRESQL
762761

763762
for container in localspec[PODSPEC][CONTAINERS]:
764-
if container[CONTAINER_NAME] == POSTGRESQL_CONTAINER:
763+
if container[CONTAINER_NAME] == PODSPEC_CONTAINERS_POSTGRESQL_CONTAINER:
765764
postgresql_image = container[IMAGE]
766765

767766
if mode == MACHINE_MODE:
@@ -787,12 +786,14 @@ def create_postgresql(
787786
for config in configs:
788787
name = config.split("=")[0].strip()
789788
value = config[config.find("=") + 1:].strip()
790-
config = name + "=" + value
789+
791790
if name in PG_CONFIG_IGNORE:
792791
continue
792+
793793
if field == get_field(AUTOFAILOVER) and name == 'port':
794-
continue
794+
value = str(AUTO_FAILOVER_PORT)
795795

796+
config = name + "=" + value
796797
if mode == MACHINE_MODE:
797798
machine_env += PG_CONFIG_PREFIX + config + "\n"
798799
else:
@@ -2437,7 +2438,7 @@ def correct_user_password(
24372438
PASSWORD_FAILED_MESSAGEd = "password authentication failed for user"
24382439

24392440
if get_conn_role(conn) == AUTOFAILOVER:
2440-
port = 55555
2441+
port = AUTO_FAILOVER_PORT
24412442
user = AUTOCTL_NODE
24422443
password = patch.status.get(AUTOCTL_NODE)
24432444
if password == None:

0 commit comments

Comments
 (0)