-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
This is a duplicate post of #1291 — which was never fixed. The core problem after investigation is that the protocol
in the ports declaration of side-cars isn't compared in a way that counts protocol: null
=== protocol: TCP
despite TCP being the default if protocol in the Go k8s struct is nil.
This is a good first issue:
- Create a unit test that validates the bug (by failing) when comparing the protocol property of a ports array (of a side-car or otherwise)
- Special-case the defaults: this could potentially include other defaults if they exist for this record
Or alternatively; semantic comparison with defaults is probably already implemented in the k8s go SDK: call this SDK's comparison function instead.
After getting advice, this is a cross post with zalando/spilo#536 — it would seem the fault is with the operator and not Spilo.
- Which image of the operator are you using?
registry.opensource.zalan.do/acid/postgres-operator:v1.6.0
- Where do you run it - cloud or metal? Kubernetes or OpenShift? GCP
- Are you running Postgres Operator in production? yes
- Type of issue? bug report
For me it's enough to define a sidecar like this, to trigger the behaviour:
sidecars:
- name: exporter
image: wrouesnel/postgres_exporter
env:
- name: "DATA_SOURCE_URI"
value: app-analytics-db/analytics?sslmode=require
- name: "DATA_SOURCE_USER"
valueFrom:
secretKeyRef:
name: postgres.app-analytics-db.credentials
key: username
- name: "DATA_SOURCE_PASS"
valueFrom:
secretKeyRef:
name: postgres.app-analytics-db.credentials
key: password
- name: PG_EXPORTER_WEB_LISTEN_ADDRESS
value: ":9114"
- name: PG_EXPORTER_CONSTANT_LABELS
value: app=analytics-db,component=postgres
ports:
- name: http-prom
containerPort: 9114
resources:
limits:
cpu: 500m
memory: 256M
requests:
cpu: 100m
memory: 200M
Causes it to fail over every thirty minutes:
Some logs:
time="2021-01-06T17:24:36Z" level=debug msg="metadata.annotation are different" cluster-name=app/app-analytics-db pkg=cluster worker=1
time="2021-01-06T17:24:36Z" level=debug msg="- zalando-postgres-operator-rolling-update-required: false" cluster-name=app/app-analytics-db pkg=cluster worker=1
time="2021-01-06T17:24:36Z" level=debug msg="+ zalando-postgres-operator-rolling-update-required: true" cluster-name=app/app-analytics-db pkg=cluster worker=1
time="2021-01-06T17:24:36Z" level=info msg="reason: new statefulset containers's exporter (index 1) ports do not match the current one" cluster-name=app/app-analytics-db pkg=cluster worker=1
time="2021-01-06T17:24:36Z" level=debug msg="updating statefulset" cluster-name=app/app-analytics-db pkg=cluster worker=1
time="2021-01-06T17:24:36Z" level=debug msg="patching statefulset annotations" cluster-name=app/app-analytics-db pkg=cluster worker=1
time="2021-01-06T17:24:37Z" level=debug msg="patching statefulset annotations" cluster-name=app/app-analytics-db pkg=cluster worker=1
time="2021-01-06T17:24:37Z" level=debug msg="calling Patroni API on a pod app/app-analytics-db-0 to set the following Postgres options: map[wal_level:logical]" cluster-name=app/app-analytics-db pkg=cluster worker=1
time="2021-01-06T17:24:37Z" level=debug msg="making PATCH http request: http://10.4.7.76:8008/config" cluster-name=app/app-analytics-db pkg=cluster worker=1
jouve