fix(clickhouseexporter): respect TLS configuration when cert_file/key_file are missing and add test case (#43911)#44093
Conversation
…_file are missing and add test case (open-telemetry#43911)
|
Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib. Important reminders:
A maintainer will review your pull request soon. Thank you for helping make OpenTelemetry better! |
SpencerTorres
left a comment
There was a problem hiding this comment.
As long as this doesn't break default configs, should be good. Also add changelog. Thanks!
Added changelog entry as requested. |
|
Thanks for the PR @harshit-jindal02 - don't edit the changelog directly, add the change using chloggen, follow the instructions at https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/a1bbdc152908d8822a0989a5bde4e44a798bd11d/CONTRIBUTING.md#changelog |
|
The tests are going to fail due to the changelog, but I'm approving the workflows to run so we get a run of the new test. |
Thanks @pjanotti, I’ve updated and validated the changelog entry as suggested. |
|
Fixed linting issues (os.CreateTemp usage and whitespace). |
|
Hi @pjanotti, The remaining CI failures are coming from: |
|
@harshit-jindal02 we need to cleanup CI before merging, so I'm going to update the branch so it runs against the latest. Let's check the status after that. |
this is not related to this PR, I will get back to it once the space issue is fixed. |
|
Thank you for your contribution @harshit-jindal02! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help. |
…or/otel to 141 + Remove deprecated components + Bump k8s min version to 1.21 (#4111) The clickhouse exporter supports TLS settings similar to otlp: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/945e5a71ef31793ff3280b28c1425086ea5332b6/exporter/clickhouseexporter/README.md#tls Some users need this to connect to clickhouse, adding them as options in the destination here This adds: * `insecure_skip_verify` * `ca_file` (using the k8sconfig interface to mount the secret as a file, similar to how the GCP exporter supports application default credentials) The direct string fields (such as CAPem, CertPem, KeyPem) aren't yet supported in the clickhouse exporter, so it has to be a mounted file. See open-telemetry/opentelemetry-collector-contrib#43911 (comment) --- To do this, it required bumping the collector/otel deps to 136 when TLS config support was added to clickhouse. This required the following changes: This actually needs collector v0.136.0 for these settings from open-telemetry/opentelemetry-collector-contrib#42581 (open-telemetry/opentelemetry-collector-contrib@d9769f7) Also needs to remove loki exporter (removed in 131) for 136 🙃 open-telemetry/opentelemetry-collector-contrib#41413, see https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.130.0/exporter/lokiexporter#deprecation-notice it's replaced with just otlp. The only destination that actually looks like it's using the loki exporter is OpsVerse As well as the opencensus exporter, removed in 133 upstream by open-telemetry/opentelemetry-collector-contrib#42239 Also routing processor open-telemetry/opentelemetry-collector-contrib#36616 See previous attempt #3669 (reverted in #3734) --- Then, it turns out that 136 was bugged and did not have full support for TLS settings like `insecure_skip_verify`. This was fixed in 141, which required the following extra changes: Actually needs collector v141 due to this bug in clickhouse not handling all tls settings: open-telemetry/opentelemetry-collector-contrib#43911 fixed in open-telemetry/opentelemetry-collector-contrib#44093 Remove deprecated carbon exporter support (unmaintained upstream) open-telemetry/opentelemetry-collector-contrib#44532 another upstream breaking change giving go mod trouble open-telemetry/opentelemetry-collector#13948 configgrpc update: open-telemetry/opentelemetry-collector#13996 and now metadata.yaml metrics require stablity levels open-telemetry/opentelemetry-collector#13756 ``` Error: failed loading /app/collector/receivers/odigosebpfreceiver/metadata.yaml: decoding failed due to the following error(s): 'telemetry.metrics[ebpf_memory_pressure_wait_time_total]' missing required field: `stability` 'telemetry.metrics[ebpf_total_bytes_read]' missing required field: `stability` 'telemetry.metrics[ebpf_lost_samples]' missing required field: `stability` Error: failed loading /app/collector/receivers/odigosebpfreceiver/metadata.yaml: decoding failed due to the following error(s): 'telemetry.metrics[ebpf_memory_pressure_wait_time_total]' missing required field: `stability` 'telemetry.metrics[ebpf_total_bytes_read]' missing required field: `stability` 'telemetry.metrics[ebpf_lost_samples]' missing required field: `stability` Error: metadata.yaml ordering check failed: [telemetry metrics] keys are not sorted: [odigos_log_data_size odigos_metric_data_size odigos_trace_data_size odigos_accepted_spans odigos_accepted_metric_points odigos_accepted_log_records] Error: metadata.yaml ordering check failed: [telemetry metrics] keys are not sorted: [odigos_log_data_size odigos_metric_data_size odigos_trace_data_size odigos_accepted_spans odigos_accepted_metric_points odigos_accepted_log_records] ``` This bump also required adding the `endpointslices` permission to the odiglet service account for the data-collection collector --- Finally, endpointslices was not GA in k8s 1.20. This PR bumps our minimum supported k8s version to 1.21. Enterprise update in odigos-io/odigos-enterprise#2117
Summary
This PR fixes a bug in the ClickHouse exporter where the TLS configuration was ignored
if neither
cert_filenorkey_filewere set — even when a validca_filewas provided.As a result, server-side TLS verification setups (CA-only) failed unexpectedly.
Root Cause
In the previous logic inside
buildClickHouseOptions(), TLS initialization was conditionedon both
cert_fileandkey_filebeing provided.However, for many ClickHouse deployments, only a
ca_fileis necessary to validatethe server certificate without using client-side authentication.
This caused the exporter to skip TLS setup entirely when only
ca_filewas specified.Fix Implemented
Updated
buildClickHouseOptions()to initialize TLS even when only aca_fileis set.Ensured server-side TLS verification is correctly configured.
Added a new regression test to prevent future regressions:
TestBuildClickHouseOptions_WithCAFileOnlyThis test verifies:
Test Plan
Run locally:
Expected output:
Behavior Before
Behavior After
Affected Files
Related Issue
Fixes: #43911
Additional Notes
This improvement ensures the ClickHouse exporter correctly handles standard TLS verification
scenarios where a root CA file is provided but no client certificates are required.
It brings the exporter in line with expected ClickHouse server security behavior and adds
a regression test to safeguard future changes.