Skip to content

Commit 931a8be

Browse files
feat: Support removing properties from catalogs (#713)
* feat: Support removing properties from catalogs * changelog * Add docs * Improve docs * fix merge conflicts * Apply suggestions from code review Co-authored-by: Malte Sander <[email protected]> * charts --------- Co-authored-by: Malte Sander <[email protected]>
1 parent a6e644a commit 931a8be

File tree

5 files changed

+57
-4
lines changed

5 files changed

+57
-4
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ All notable changes to this project will be documented in this file.
1212
- Support configuring JVM arguments ([#677]).
1313
- Aggregate emitted Kubernetes events on the CustomResources ([#677]).
1414
- Support for Trino 470 ([#705]).
15+
- Support removing properties from catalogs.
16+
This is helpful, because Trino fails to start in case you have any unused config properties ([#713]).
1517
- Support `access-control.properties` in configOverrides ([#721]).
1618

1719
### Changed
@@ -38,6 +40,7 @@ All notable changes to this project will be documented in this file.
3840
[#694]: https://github.com/stackabletech/trino-operator/pull/694
3941
[#695]: https://github.com/stackabletech/trino-operator/pull/695
4042
[#705]: https://github.com/stackabletech/trino-operator/pull/705
43+
[#713]: https://github.com/stackabletech/trino-operator/pull/713
4144
[#715]: https://github.com/stackabletech/trino-operator/pull/715
4245
[#717]: https://github.com/stackabletech/trino-operator/pull/717
4346
[#721]: https://github.com/stackabletech/trino-operator/pull/721

deploy/helm/trino-operator/crds/crds.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -2027,6 +2027,17 @@ spec:
20272027
description: A [TPC-H](https://docs.stackable.tech/home/nightly/trino/usage-guide/catalogs/tpch) connector.
20282028
type: object
20292029
type: object
2030+
experimentalConfigRemovals:
2031+
default: []
2032+
description: |-
2033+
List of config properties which should be removed.
2034+
2035+
This is helpful, because Trino fails to start in case you have any unused config properties. The removals are executed after the `configOverrides`.
2036+
2037+
This field is experimental, and might be replaced by a more generic mechanism to edit config properties
2038+
items:
2039+
type: string
2040+
type: array
20302041
required:
20312042
- connector
20322043
type: object

docs/modules/trino/pages/usage-guide/catalogs/index.adoc

+23-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ spec:
3131
accessStyle: Path
3232
credentials:
3333
secretClass: minio-credentials
34-
# We can use configOverrides to add arbitrary properties to the Trino catalog configuration
35-
configOverrides:
36-
hive.metastore.username: trino
3734
---
3835
apiVersion: trino.stackable.tech/v1alpha1
3936
kind: TrinoCatalog
@@ -60,6 +57,29 @@ The `metadata.labels` are used by TrinoCluster to determine the link between Tri
6057
The `spec.connector.<connector>` determines which connector is used.
6158
Each connector supports a different set of attributes.
6259

60+
=== Config overrides and config removals
61+
62+
You can use `.spec.configOverrides` to set arbitrary additional properties, which will be added to the catalog.
63+
64+
There is also `.spec.experimentalConfigRemovals` to remove any properties the operator might set, but are not used by Trino.
65+
This causes Trino to refuse to startup with an error message such as `Error: Configuration property 'hive.s3.aws-access-key' was not used`.
66+
By removing the unneeded properties you can get Trino to start again.
67+
68+
This example illustrates how to use config overrides and config removals
69+
70+
[source,yaml]
71+
----
72+
apiVersion: trino.stackable.tech/v1alpha1
73+
kind: TrinoCatalog
74+
spec:
75+
# Add some properties
76+
configOverrides:
77+
hive.metastore.username: trino
78+
# Remove some properties
79+
experimentalConfigRemovals:
80+
- hive.s3.aws-access-key
81+
----
82+
6383
=== Add a catalog to a Trino cluster
6484

6585
It is necessary to specify within the TrinoCluster which catalogs it should use.

rust/operator-binary/src/catalog/config.rs

+10
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ impl CatalogConfig {
161161
.properties
162162
.extend(catalog.spec.config_overrides.clone());
163163

164+
for removal in &catalog.spec.config_removals {
165+
if catalog_config.properties.remove(removal).is_none() {
166+
tracing::warn!(
167+
catalog.name = catalog_name,
168+
property = removal,
169+
"You asked to remove a non-existing config property from a catalog"
170+
);
171+
}
172+
}
173+
164174
Ok(catalog_config)
165175
}
166176
}

rust/operator-binary/src/crd/catalog/mod.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,19 @@ pub mod versioned {
4949
/// The `connector` defines which connector is used.
5050
pub connector: TrinoCatalogConnector,
5151

52-
#[serde(default)]
5352
/// The `configOverrides` allow overriding arbitrary Trino settings.
5453
/// For example, for Hive you could add `hive.metastore.username: trino`.
54+
#[serde(default)]
5555
pub config_overrides: HashMap<String, String>,
56+
57+
/// List of config properties which should be removed.
58+
///
59+
/// This is helpful, because Trino fails to start in case you have any unused config
60+
/// properties. The removals are executed after the `configOverrides`.
61+
///
62+
/// This field is experimental, and might be replaced by a more generic mechanism to edit config properties
63+
#[serde(default, rename = "experimentalConfigRemovals")]
64+
pub config_removals: Vec<String>,
5665
}
5766
}
5867

0 commit comments

Comments
 (0)