Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make postgres server configurable #1320

Closed
yanmxa opened this issue Jan 9, 2025 · 1 comment · Fixed by #1327
Closed

make postgres server configurable #1320

yanmxa opened this issue Jan 9, 2025 · 1 comment · Fixed by #1327

Comments

@yanmxa
Copy link
Member

yanmxa commented Jan 9, 2025

default value

hoh=# SHOW wal_level;
 wal_level
-----------
 replica
(1 row)

hoh=# SHOW max_wal_size;
 max_wal_size
--------------
 1GB
(1 row)

refer: https://issues.redhat.com/browse/ACM-16887

@yanmxa
Copy link
Member Author

yanmxa commented Jan 13, 2025

Add the indent in the render template

Encountered the following error when merging the default and customized configuration:

❯ oc get cm multicluster-global-hub-postgresql-config -oyaml
apiVersion: v1
data:
  postgresql.conf: |
    ssl = on
    ssl_cert_file = '/opt/app-root/src/certs/tls.crt' # server certificate
    ssl_key_file =  '/opt/app-root/src/certs/tls.key' # server private key
    ssl_min_protocol_version = TLSv1.3
    shared_preload_libraries = 'pg_stat_statements'
    pg_stat_statements.max = 10000
    pg_stat_statements.track = all
kind: ConfigMap
metadata:
  creationTimestamp: "2025-01-08T11:04:23Z"
  labels:
    global-hub.open-cluster-management.io/managed-by: global-hub-operator
  name: multicluster-global-hub-postgresql-config
  namespace: multicluster-global-hub
  ownerReferences:
  - apiVersion: operator.open-cluster-management.io/v1alpha4
    blockOwnerDeletion: true
    controller: true
    kind: MulticlusterGlobalHub
    name: multiclusterglobalhub
    uid: 1522175f-8e05-46cd-b8b5-17c65a72e20b
  resourceVersion: "41537893"
  uid: c496c5aa-37e5-4d82-8a6c-45a570ecbfdb
❯ cat <<EOF | oc apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
  name: multicluster-global-hub-custom-postgresql-config
  namespace: multicluster-global-hub
data:
  postgresql.conf: |
    wal_level = logical
    max_wal_size = 2GB
EOF
configmap/multicluster-global-hub-custom-postgresql-config created
2025-01-13T07:02:23.125Z        ERROR   controller/controller.go:316    Reconciler error        {"controller": "storageController", "controllerGroup": "operator.open-cluster-management.io", "controllerKind": "MulticlusterGlobalHub", "MulticlusterGlobalHub": {"name":"multicluster-global-hub-custom-postgresql-config","namespace":"multicluster-global-hub"}, "namespace": "multicluster-global-hub", "name": "multicluster-global-hub-custom-postgresql-config", "reconcileID": "43f769a7-ab90-4577-8362-1cc43a817e1d", "error": "storage not ready, Error: failed to render postgres manifests: yaml: line 17: could not find expected ':'"}
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler
        /go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:316
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem
        /go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:263
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2
        /go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:224
  • Fix the above error
   {{- if .EnablePostgresMetrics }}
    shared_preload_libraries = 'pg_stat_statements'
    pg_stat_statements.max = 10000
    pg_stat_statements.track = all
    {{- end }}
    {{- .PostgresCustomizedConfig | indent 4}}
❯ oc get cm multicluster-global-hub-postgresql-config -oyaml
apiVersion: v1
data:
  postgresql.conf: |
    ssl = on
    ssl_cert_file = '/opt/app-root/src/certs/tls.crt' # server certificate
    ssl_key_file =  '/opt/app-root/src/certs/tls.key' # server private key
    ssl_min_protocol_version = TLSv1.3
    shared_preload_libraries = 'pg_stat_statements'
    pg_stat_statements.max = 10000
    pg_stat_statements.track = allwal_level = logical
    max_wal_size = 2GB
kind: ConfigMap
metadata:
  creationTimestamp: "2025-01-08T11:04:23Z"
  labels:
    global-hub.open-cluster-management.io/managed-by: global-hub-operator
  name: multicluster-global-hub-postgresql-config
  namespace: multicluster-global-hub
apiVersion: v1
data:
  postgresql.conf: |
    ssl = on
    ssl_cert_file = '/opt/app-root/src/certs/tls.crt' # server certificate
    ssl_key_file =  '/opt/app-root/src/certs/tls.key' # server private key
    ssl_min_protocol_version = TLSv1.3
    shared_preload_libraries = 'pg_stat_statements'
    pg_stat_statements.max = 10000
    pg_stat_statements.track = all
    wal_level = logical
    max_wal_size = 2GB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant