Skip to content

Commit

Permalink
feat!: Add jvmArgumentOverrides as well as common code (#931)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Malte Sander <[email protected]>
  • Loading branch information
sbernauer and maltesander authored Jan 16, 2025
1 parent 6f1ef43 commit 1bb891c
Show file tree
Hide file tree
Showing 3 changed files with 343 additions and 32 deletions.
9 changes: 6 additions & 3 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ All notable changes to this project will be documented in this file.
- BREAKING: Aggregate emitted Kubernetes events on the CustomResources thanks to the new
[kube feature](https://github.com/kube-rs/controller-rs/pull/116). Instead of reporting the same
event multiple times it now uses `EventSeries` to aggregate these events to single entry with an
age like `3s (x11 over 53s)` ([#867]):
age like `3s (x11 over 53s)` ([#938]):
- The `report_controller_error` function now needs to be async.
- It now takes `Recorder` as a parameter instead of a `Client`.
- The `Recorder` instance needs to be available across all `reconcile` invocations, to ensure
aggregation works correctly.
- The operator needs permission to `patch` events (previously only `create` was needed).
- Add `ProductSpecificCommonConfig`, so that product operators can have custom fields within `commonConfig`.
Also add a `JavaCommonConfig`, which can be used by JVM-based tools to offer `jvmArgumentOverrides` with this mechanism ([#931])

### Changed

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

[#931]: https://github.com/stackabletech/operator-rs/pull/931
[#938]: https://github.com/stackabletech/operator-rs/pull/938
[#939]: https://github.com/stackabletech/operator-rs/pull/939

## [0.83.0] - 2024-12-03
Expand Down
34 changes: 22 additions & 12 deletions crates/stackable-operator/src/product_config_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,21 @@ pub fn config_for_role_and_group<'a>(
/// - `resource` - Not used directly. It's passed on to the `Configuration::compute_*` calls.
/// - `roles` - A map keyed by role names. The value is a tuple of a vector of `PropertyNameKind`
/// like (Cli, Env or Files) and [`crate::role_utils::Role`] with a boxed [`Configuration`].
pub fn transform_all_roles_to_config<T, U>(
#[allow(clippy::type_complexity)]
pub fn transform_all_roles_to_config<T, U, ProductSpecificCommonConfig>(
resource: &T::Configurable,
roles: HashMap<String, (Vec<PropertyNameKind>, Role<T, U>)>,
roles: HashMap<
String,
(
Vec<PropertyNameKind>,
Role<T, U, ProductSpecificCommonConfig>,
),
>,
) -> Result<RoleConfigByPropertyKind>
where
T: Configuration,
U: Default + JsonSchema + Serialize,
ProductSpecificCommonConfig: Default + JsonSchema + Serialize,
{
let mut result = HashMap::new();

Expand Down Expand Up @@ -359,15 +367,16 @@ fn process_validation_result(
/// - `role_name` - The name of the role.
/// - `role` - The role for which to transform the configuration parameters.
/// - `property_kinds` - Used as "buckets" to partition the configuration properties by.
fn transform_role_to_config<T, U>(
fn transform_role_to_config<T, U, ProductSpecificCommonConfig>(
resource: &T::Configurable,
role_name: &str,
role: &Role<T, U>,
role: &Role<T, U, ProductSpecificCommonConfig>,
property_kinds: &[PropertyNameKind],
) -> Result<RoleGroupConfigByPropertyKind>
where
T: Configuration,
U: Default + JsonSchema + Serialize,
ProductSpecificCommonConfig: Default + JsonSchema + Serialize,
{
let mut result = HashMap::new();

Expand Down Expand Up @@ -422,10 +431,10 @@ where
/// - `role_name` - Not used directly but passed on to the `Configuration::compute_*` calls.
/// - `config` - The configuration properties to partition.
/// - `property_kinds` - The "buckets" used to partition the configuration properties.
fn parse_role_config<T>(
fn parse_role_config<T, ProductSpecificCommonConfig>(
resource: &<T as Configuration>::Configurable,
role_name: &str,
config: &CommonConfiguration<T>,
config: &CommonConfiguration<T, ProductSpecificCommonConfig>,
property_kinds: &[PropertyNameKind],
) -> Result<HashMap<PropertyNameKind, BTreeMap<String, Option<String>>>>
where
Expand All @@ -452,8 +461,8 @@ where
Ok(result)
}

fn parse_role_overrides<T>(
config: &CommonConfiguration<T>,
fn parse_role_overrides<T, ProductSpecificCommonConfig>(
config: &CommonConfiguration<T, ProductSpecificCommonConfig>,
property_kinds: &[PropertyNameKind],
) -> Result<HashMap<PropertyNameKind, BTreeMap<String, Option<String>>>>
where
Expand Down Expand Up @@ -489,8 +498,8 @@ where
Ok(result)
}

fn parse_file_overrides<T>(
config: &CommonConfiguration<T>,
fn parse_file_overrides<T, ProductSpecificCommonConfig>(
config: &CommonConfiguration<T, ProductSpecificCommonConfig>,
file: &str,
) -> Result<BTreeMap<String, Option<String>>>
where
Expand Down Expand Up @@ -522,7 +531,7 @@ mod tests {
}

use super::*;
use crate::role_utils::{Role, RoleGroup};
use crate::role_utils::{GenericProductSpecificCommonConfig, Role, RoleGroup};
use k8s_openapi::api::core::v1::PodTemplateSpec;
use rstest::*;
use std::collections::HashMap;
Expand Down Expand Up @@ -610,13 +619,14 @@ mod tests {
config_overrides: Option<HashMap<String, HashMap<String, String>>>,
env_overrides: Option<HashMap<String, String>>,
cli_overrides: Option<BTreeMap<String, String>>,
) -> CommonConfiguration<Box<TestConfig>> {
) -> CommonConfiguration<Box<TestConfig>, GenericProductSpecificCommonConfig> {
CommonConfiguration {
config: test_config.unwrap_or_default(),
config_overrides: config_overrides.unwrap_or_default(),
env_overrides: env_overrides.unwrap_or_default(),
cli_overrides: cli_overrides.unwrap_or_default(),
pod_overrides: PodTemplateSpec::default(),
product_specific_common_config: GenericProductSpecificCommonConfig::default(),
}
}

Expand Down
Loading

0 comments on commit 1bb891c

Please sign in to comment.