Skip to content

Commit

Permalink
Merge pull request #575 from openedx/cag/fix-clickhouse-settings
Browse files Browse the repository at this point in the history
refactor: use patch for clickhouse settings
  • Loading branch information
Ian2012 authored Jan 29, 2024
2 parents 4b60828 + ad51310 commit af838b8
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 58 deletions.
34 changes: 34 additions & 0 deletions tutoraspects/patches/clickhouse-server-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
IMPORTANT: This patch is not applied to Clickhouse Cloud Providers.
make sure to contact your cloud provider support to apply this patch.

These are miscellaneous ClickHouse server settings, which get mounted to
/etc/clickhouse-server/config.d/docker_config.xml

See https://clickhouse.com/docs/en/operations/configuration-files for details.

These default settings allow connecting to Clickhouse when run as a
standalone docker container, instead of through docker-compose.
-->

<!--
Port for HTTP API. See also 'https_port' for secure connections.
This interface is also used by ODBC and JDBC drivers (DataGrip, Dbeaver, ...)
and by most of web interfaces (embedded UI, Grafana, Redash, ...).
-->
<http_port>{{CLICKHOUSE_INTERNAL_HTTP_PORT}}</http_port>

<!--
Port for interaction by native protocol with:
- clickhouse-client and other native ClickHouse tools (clickhouse-benchmark,
clickhouse-copier);
- clickhouse-server with other clickhouse-servers for distributed query processing;
- ClickHouse drivers and applications supporting native protocol
(this protocol is also informally called as "the TCP protocol");
See also 'tcp_port_secure' for secure connections.
-->
<tcp_port>{{CLICKHOUSE_INTERNAL_NATIVE_PORT}}</tcp_port>

<listen_host>::</listen_host>
<listen_host>0.0.0.0</listen_host>
<listen_try>1</listen_try>
21 changes: 21 additions & 0 deletions tutoraspects/patches/clickhouse-user-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--
IMPORTANT: This patch is not applied to Clickhouse Cloud Providers.
make sure to contact your cloud provider support to apply this patch.

Override configuration in users.xml. ClickHouse will read this from a mount on
/etc/clickhouse-server/users.d/ on startup.

The http settings revert back to the value from versions pre-23.6,
when the default was changed from 1Mb to 128Kb. This allows larger POSTs such
as the event sink sends from the LMS.

NOTE: Currently this patch does not impact Kubernetes deployments. ClickHouse
writes to the user directory that we want to override causing errors if we try
to mount this file there:
-->
<profiles>
<default>
<http_max_field_value_size>1048576</http_max_field_value_size>
<http_max_field_name_size>1048576</http_max_field_name_size>
</default>
</profiles>
15 changes: 11 additions & 4 deletions tutoraspects/patches/k8s-deployments
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,23 @@ spec:
volumeMounts:
- mountPath: /var/lib/clickhouse/
name: data
- mountPath: /etc/clickhouse-server/config.d/
name: settings
- mountPath: /etc/clickhouse-server/config.d/server_config.xml
name: server-settings
subPath: server_config.xml
- mountPath: /etc/clickhouse-server/users.d/user_config.xml
name: user-settings
subPath: user_config.xml
restartPolicy: Always
volumes:
- name: data
persistentVolumeClaim:
claimName: clickhouse
- name: settings
- name: user-settings
configMap:
name: clickhouse-settings
name: clickhouse-user-settings
- name: server-settings
configMap:
name: clickhouse-server-settings
{% endif %}

{% if RUN_RALPH %}
Expand Down
9 changes: 7 additions & 2 deletions tutoraspects/patches/kustomization-configmapgenerator
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@
app.kubernetes.io/name: aspects

{% if RUN_CLICKHOUSE %}
- name: clickhouse-settings
- name: clickhouse-user-settings
files:
- plugins/aspects/apps/clickhouse/config/docker_config.xml
- plugins/aspects/apps/clickhouse/users/user_config.xml
options:
labels:
app.kubernetes.io/name: clickhouse
- name: clickhouse-server-settings
files:
- plugins/aspects/apps/clickhouse/config/server_config.xml
options:
labels:
app.kubernetes.io/name: clickhouse
{% endif %}

{% if RUN_RALPH %}
Expand Down
47 changes: 0 additions & 47 deletions tutoraspects/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,53 +178,6 @@
"{% endif %}",
),
("CLICKHOUSE_K8S_VOLUME_SIZE", "10Gi"),
# This can be used to override some configuration values in
# via "docker_config.xml" file, which will be read from a
# mount on /etc/clickhouse-server/config.d/ on startup.
# See https://clickhouse.com/docs/en/operations/configuration-files
#
# This default allows connecting to Clickhouse when run as a
# standalone docker container, instead of through docker-compose.
(
"CLICKHOUSE_EXTRA_XML_CONFIG",
"""
<!-- Port for HTTP API. See also 'https_port' for secure connections.
This interface is also used by ODBC and JDBC drivers (DataGrip, Dbeaver, ...)
and by most of web interfaces (embedded UI, Grafana, Redash, ...).
-->
<http_port>{{CLICKHOUSE_INTERNAL_HTTP_PORT}}</http_port>
<!-- Port for interaction by native protocol with:
- clickhouse-client and other native ClickHouse tools (clickhouse-benchmark,
clickhouse-copier);
- clickhouse-server with other clickhouse-servers for distributed query processing;
- ClickHouse drivers and applications supporting native protocol
(this protocol is also informally called as "the TCP protocol");
See also 'tcp_port_secure' for secure connections.
-->
<tcp_port>{{CLICKHOUSE_INTERNAL_NATIVE_PORT}}</tcp_port>
<listen_host>::</listen_host>
<listen_host>0.0.0.0</listen_host>
<listen_try>1</listen_try>
""",
),
# Override configuration in users.xml. Similar to CLICKHOUSE_EXTRA_XML_CONFIG,
# this will be read from a mount on /etc/clickhouse-server/users.d/
# on startup
# The http settings revert back to the value from versions pre-23.6,
# when the default was changed from 1Mb to 128Kb
(
"CLICKHOUSE_EXTRA_USERS_XML_CONFIG",
"""
<profiles>
<default>
<http_max_field_value_size>1048576</http_max_field_value_size>
<http_max_field_name_size>1048576</http_max_field_name_size>
</default>
</profiles>
""",
),
(
"CLICKHOUSE_URL",
"{{CLICKHOUSE_HOST}}:{{CLICKHOUSE_INTERNAL_HTTP_PORT}}",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<clickhouse>
{{patch("clickhouse-server-config")}}
</clickhouse>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<clickhouse>
{{ CLICKHOUSE_EXTRA_USERS_XML_CONFIG }}
{{patch("clickhouse-user-config")}}
</clickhouse>
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ GRANT {{ ON_CLUSTER }} SELECT ON system.events TO '{{ ASPECTS_CLICKHOUSE_REPORT_
GRANT {{ ON_CLUSTER }} SELECT ON system.metrics TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}';
GRANT {{ ON_CLUSTER }} SELECT ON system.replication_queue TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}';
-- Patch from clickhouse-extra-sql follows...
{{ patch("clickhouse-extra-sql") }}
EOF

0 comments on commit af838b8

Please sign in to comment.