Skip to content

Commit 1bb891c

Browse files
feat!: Add jvmArgumentOverrides as well as common code (#931)
* WIP: First draft of ProductSpecificCommonConfig * v2: Allow deletion of operator generated arguments * refactor!: Make field private * WIP: Try out add, remove and removeRegex * refactor * WIP * refactor!: Use Vec instead of BTreeSet * Remove missleading function * Link to docs * Revert "Remove missleading function" This reverts commit 08759f1. * Rename merged_product_specific_common_configs -> get_product_specific_common_configs * changelog * typo * Improve changelog * Add some CRD docs * Improve rustdoc * Add some rustdoc * changelog * refactor!: Dont use Merge, implement try_merge instead * clippy * Use serde_yaml for entire_role * simplyfy merge_java_common_config_keep_order test * Update crates/stackable-operator/src/role_utils.rs Co-authored-by: Sebastian Bernauer <sebastian.bernauer@stackable.de> --------- Co-authored-by: Malte Sander <malte.sander.it@gmail.com>
1 parent 6f1ef43 commit 1bb891c

File tree

3 files changed

+343
-32
lines changed

3 files changed

+343
-32
lines changed

crates/stackable-operator/CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ All notable changes to this project will be documented in this file.
99
- BREAKING: Aggregate emitted Kubernetes events on the CustomResources thanks to the new
1010
[kube feature](https://github.com/kube-rs/controller-rs/pull/116). Instead of reporting the same
1111
event multiple times it now uses `EventSeries` to aggregate these events to single entry with an
12-
age like `3s (x11 over 53s)` ([#867]):
12+
age like `3s (x11 over 53s)` ([#938]):
1313
- The `report_controller_error` function now needs to be async.
1414
- It now takes `Recorder` as a parameter instead of a `Client`.
1515
- The `Recorder` instance needs to be available across all `reconcile` invocations, to ensure
1616
aggregation works correctly.
1717
- The operator needs permission to `patch` events (previously only `create` was needed).
18+
- Add `ProductSpecificCommonConfig`, so that product operators can have custom fields within `commonConfig`.
19+
Also add a `JavaCommonConfig`, which can be used by JVM-based tools to offer `jvmArgumentOverrides` with this mechanism ([#931])
1820

1921
### Changed
2022

21-
- BREAKING: Bump Rust dependencies to enable Kubernetes 1.32 (via `kube` 0.98.0 and `k8s-openapi`
22-
0.23.0) ([#867]).
23+
- BREAKING: Bump Rust dependencies to enable Kubernetes 1.32 (via `kube` 0.98.0 and `k8s-openapi` 0.23.0) ([#938]).
2324
- BREAKING: Append a dot to the default cluster domain to make it a FQDN and allow FQDNs when validating a `DomainName` ([#939]).
2425

26+
[#931]: https://github.com/stackabletech/operator-rs/pull/931
27+
[#938]: https://github.com/stackabletech/operator-rs/pull/938
2528
[#939]: https://github.com/stackabletech/operator-rs/pull/939
2629

2730
## [0.83.0] - 2024-12-03

crates/stackable-operator/src/product_config_utils.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,21 @@ pub fn config_for_role_and_group<'a>(
167167
/// - `resource` - Not used directly. It's passed on to the `Configuration::compute_*` calls.
168168
/// - `roles` - A map keyed by role names. The value is a tuple of a vector of `PropertyNameKind`
169169
/// like (Cli, Env or Files) and [`crate::role_utils::Role`] with a boxed [`Configuration`].
170-
pub fn transform_all_roles_to_config<T, U>(
170+
#[allow(clippy::type_complexity)]
171+
pub fn transform_all_roles_to_config<T, U, ProductSpecificCommonConfig>(
171172
resource: &T::Configurable,
172-
roles: HashMap<String, (Vec<PropertyNameKind>, Role<T, U>)>,
173+
roles: HashMap<
174+
String,
175+
(
176+
Vec<PropertyNameKind>,
177+
Role<T, U, ProductSpecificCommonConfig>,
178+
),
179+
>,
173180
) -> Result<RoleConfigByPropertyKind>
174181
where
175182
T: Configuration,
176183
U: Default + JsonSchema + Serialize,
184+
ProductSpecificCommonConfig: Default + JsonSchema + Serialize,
177185
{
178186
let mut result = HashMap::new();
179187

@@ -359,15 +367,16 @@ fn process_validation_result(
359367
/// - `role_name` - The name of the role.
360368
/// - `role` - The role for which to transform the configuration parameters.
361369
/// - `property_kinds` - Used as "buckets" to partition the configuration properties by.
362-
fn transform_role_to_config<T, U>(
370+
fn transform_role_to_config<T, U, ProductSpecificCommonConfig>(
363371
resource: &T::Configurable,
364372
role_name: &str,
365-
role: &Role<T, U>,
373+
role: &Role<T, U, ProductSpecificCommonConfig>,
366374
property_kinds: &[PropertyNameKind],
367375
) -> Result<RoleGroupConfigByPropertyKind>
368376
where
369377
T: Configuration,
370378
U: Default + JsonSchema + Serialize,
379+
ProductSpecificCommonConfig: Default + JsonSchema + Serialize,
371380
{
372381
let mut result = HashMap::new();
373382

@@ -422,10 +431,10 @@ where
422431
/// - `role_name` - Not used directly but passed on to the `Configuration::compute_*` calls.
423432
/// - `config` - The configuration properties to partition.
424433
/// - `property_kinds` - The "buckets" used to partition the configuration properties.
425-
fn parse_role_config<T>(
434+
fn parse_role_config<T, ProductSpecificCommonConfig>(
426435
resource: &<T as Configuration>::Configurable,
427436
role_name: &str,
428-
config: &CommonConfiguration<T>,
437+
config: &CommonConfiguration<T, ProductSpecificCommonConfig>,
429438
property_kinds: &[PropertyNameKind],
430439
) -> Result<HashMap<PropertyNameKind, BTreeMap<String, Option<String>>>>
431440
where
@@ -452,8 +461,8 @@ where
452461
Ok(result)
453462
}
454463

455-
fn parse_role_overrides<T>(
456-
config: &CommonConfiguration<T>,
464+
fn parse_role_overrides<T, ProductSpecificCommonConfig>(
465+
config: &CommonConfiguration<T, ProductSpecificCommonConfig>,
457466
property_kinds: &[PropertyNameKind],
458467
) -> Result<HashMap<PropertyNameKind, BTreeMap<String, Option<String>>>>
459468
where
@@ -489,8 +498,8 @@ where
489498
Ok(result)
490499
}
491500

492-
fn parse_file_overrides<T>(
493-
config: &CommonConfiguration<T>,
501+
fn parse_file_overrides<T, ProductSpecificCommonConfig>(
502+
config: &CommonConfiguration<T, ProductSpecificCommonConfig>,
494503
file: &str,
495504
) -> Result<BTreeMap<String, Option<String>>>
496505
where
@@ -522,7 +531,7 @@ mod tests {
522531
}
523532

524533
use super::*;
525-
use crate::role_utils::{Role, RoleGroup};
534+
use crate::role_utils::{GenericProductSpecificCommonConfig, Role, RoleGroup};
526535
use k8s_openapi::api::core::v1::PodTemplateSpec;
527536
use rstest::*;
528537
use std::collections::HashMap;
@@ -610,13 +619,14 @@ mod tests {
610619
config_overrides: Option<HashMap<String, HashMap<String, String>>>,
611620
env_overrides: Option<HashMap<String, String>>,
612621
cli_overrides: Option<BTreeMap<String, String>>,
613-
) -> CommonConfiguration<Box<TestConfig>> {
622+
) -> CommonConfiguration<Box<TestConfig>, GenericProductSpecificCommonConfig> {
614623
CommonConfiguration {
615624
config: test_config.unwrap_or_default(),
616625
config_overrides: config_overrides.unwrap_or_default(),
617626
env_overrides: env_overrides.unwrap_or_default(),
618627
cli_overrides: cli_overrides.unwrap_or_default(),
619628
pod_overrides: PodTemplateSpec::default(),
629+
product_specific_common_config: GenericProductSpecificCommonConfig::default(),
620630
}
621631
}
622632

0 commit comments

Comments
 (0)