Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow arbitrary python code #530

Merged
merged 17 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

## [Unreleased]

### Added

- Allowing arbitrary python code as EXPERIMENTAL_FILE_HEADER and EXPERIMENTAL_FILE_FOOTER in superset_config.py ([#530])

### Changed

- Reduce CRD size from `472KB` to `45KB` by accepting arbitrary YAML input instead of the underlying schema for the following fields ([#528]):
- `podOverrides`
- `affinity`
- Bumping stackable-operator from 0.73.0 to 0.74.0 ([#530])
Maleware marked this conversation as resolved.
Show resolved Hide resolved

[#528]: https://github.com/stackabletech/superset-operator/pull/528
[#530]: https://github.com/stackabletech/superset-operator/pull/530

## [24.7.0] - 2024-07-24

Expand Down
7 changes: 3 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9"
snafu = "0.8"
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.73.0" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.74.0" }
strum = { version = "0.26", features = ["derive"] }
tokio = { version = "1.39", features = ["full"] }
tracing = "0.1"
Expand Down
3 changes: 2 additions & 1 deletion rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ impl SupersetConfig {
logging: product_logging::spec::default_logging(),
affinity: get_affinity(cluster_name, role),
graceful_shutdown_timeout: Some(DEFAULT_NODE_GRACEFUL_SHUTDOWN_TIMEOUT),
..Default::default()
row_limit: None,
webserver_timeout: None,
}
}
}
Expand Down
22 changes: 21 additions & 1 deletion rust/operator-binary/src/superset_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::{
borrow::Cow,
collections::{BTreeMap, BTreeSet, HashMap},
io::Write,
sync::Arc,
};

Expand Down Expand Up @@ -39,7 +40,10 @@ use stackable_operator::{
kube::{runtime::controller::Action, Resource, ResourceExt},
kvp::{Label, Labels},
logging::controller::ReconcilerError,
product_config_utils::{transform_all_roles_to_config, validate_all_roles_and_groups_config},
product_config_utils::{
transform_all_roles_to_config, validate_all_roles_and_groups_config,
CONFIG_OVERRIDE_FILE_FOOTER_KEY, CONFIG_OVERRIDE_FILE_HEADER_KEY,
},
product_logging::{
self,
framework::{create_vector_shutdown_file_command, remove_vector_shutdown_file_command},
Expand Down Expand Up @@ -250,6 +254,11 @@ pub enum Error {
AddTlsVolumesAndVolumeMounts {
source: stackable_operator::commons::authentication::tls::TlsClientDetailsError,
},

#[snafu(display(
"failed to write to String (Vec<u8> to be precise) containing superset config"
))]
WriteToConfigFileString { source: std::io::Error },
}

type Result<T, E = Error> = std::result::Result<T, E>;
Expand Down Expand Up @@ -523,6 +532,13 @@ fn build_rolegroup_config_map(
);

let mut config_file = Vec::new();

Maleware marked this conversation as resolved.
Show resolved Hide resolved
if let Some(header) = config_properties.remove(CONFIG_OVERRIDE_FILE_HEADER_KEY) {
writeln!(config_file, "{}", header).context(WriteToConfigFileStringSnafu)?;
}
// removing key from `config_properties` to avoid key value match. Append it later.
Maleware marked this conversation as resolved.
Show resolved Hide resolved
let temp_file_footer = config_properties.remove(CONFIG_OVERRIDE_FILE_FOOTER_KEY);

flask_app_config_writer::write::<SupersetConfigOptions, _, _>(
&mut config_file,
config_properties.iter(),
Expand All @@ -532,6 +548,10 @@ fn build_rolegroup_config_map(
rolegroup: rolegroup.clone(),
})?;

if let Some(footer) = temp_file_footer {
writeln!(config_file, "{}", footer).context(WriteToConfigFileStringSnafu)?;
}

let mut cm_builder = ConfigMapBuilder::new();

cm_builder
Expand Down
Loading