Skip to content

Commit e6bcd60

Browse files
committed
fix: remove optional EnvVarSet, fix comments
1 parent c521305 commit e6bcd60

3 files changed

Lines changed: 21 additions & 27 deletions

File tree

rust/operator-binary/src/container.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl ContainerConfig {
219219
rolegroup_ref: &RoleGroupRef<v1alpha1::HdfsCluster>,
220220
resolved_product_image: &ResolvedProductImage,
221221
merged_config: &AnyNodeConfig,
222-
env_overrides: Option<&EnvVarSet>,
222+
env_overrides: &EnvVarSet,
223223
zk_config_map_name: &str,
224224
namenode_podrefs: &[HdfsPodRef],
225225
labels: &Labels,
@@ -473,7 +473,7 @@ impl ContainerConfig {
473473
rolegroup_ref: &RoleGroupRef<v1alpha1::HdfsCluster>,
474474
resolved_product_image: &ResolvedProductImage,
475475
zookeeper_config_map_name: &str,
476-
env_overrides: Option<&EnvVarSet>,
476+
env_overrides: &EnvVarSet,
477477
merged_config: &AnyNodeConfig,
478478
labels: &Labels,
479479
) -> Result<Container, Error> {
@@ -535,7 +535,7 @@ impl ContainerConfig {
535535
role_group: &str,
536536
resolved_product_image: &ResolvedProductImage,
537537
zookeeper_config_map_name: &str,
538-
env_overrides: Option<&EnvVarSet>,
538+
env_overrides: &EnvVarSet,
539539
namenode_podrefs: &[HdfsPodRef],
540540
merged_config: &AnyNodeConfig,
541541
labels: &Labels,
@@ -875,7 +875,7 @@ impl ContainerConfig {
875875
role: &HdfsNodeRole,
876876
role_group: &str,
877877
zookeeper_config_map_name: &str,
878-
env_overrides: Option<&EnvVarSet>,
878+
env_overrides: &EnvVarSet,
879879
resources: Option<&ResourceRequirements>,
880880
) -> Result<Vec<EnvVar>, Error> {
881881
// Maps env var name to env var object. This allows env_overrides to work
@@ -971,8 +971,7 @@ impl ContainerConfig {
971971

972972
// Overrides need to come last
973973
let mut env_override_vars: BTreeMap<String, EnvVar> = env_overrides
974-
.cloned()
975-
.unwrap_or_default()
974+
.clone()
976975
.into_iter()
977976
.map(|env_var| (env_var.name.clone(), env_var))
978977
.collect();

rust/operator-binary/src/controller/mod.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ pub mod build;
2222
pub mod dereference;
2323
pub mod validate;
2424

25+
/// The local-`framework` [`RoleGroupConfig`](crate::framework::role_utils::RoleGroupConfig)
26+
/// specialised for HDFS: the validated config is the per-role [`AnyNodeConfig`],
27+
/// the product-specific common config is [`JavaCommonConfig`] (whose JVM-argument
28+
/// merge is fallible, hence the vendored framework variant), and the config
29+
/// overrides are [`v1alpha1::HdfsConfigOverrides`].
30+
pub type ValidatedRoleGroupConfig = crate::framework::role_utils::RoleGroupConfig<
31+
AnyNodeConfig,
32+
stackable_operator::role_utils::JavaCommonConfig,
33+
v1alpha1::HdfsConfigOverrides,
34+
>;
35+
2536
/// The validated cluster: proves that config merging and validation succeeded
2637
/// for every role and role group before any resources are created. Placed in the
2738
/// controller so that subsequent steps that reference this struct only depend on
@@ -175,12 +186,13 @@ impl Resource for ValidatedCluster {
175186
/// longer need the raw `HdfsCluster` to render config.
176187
#[derive(Clone, Debug)]
177188
pub struct ValidatedClusterConfig {
178-
pub dfs_replication: u8,
179189
/// The authentication config, if configured. Its presence enables both Kerberos
180190
/// and HTTPS; it also carries the TLS and Kerberos secret class names.
181191
pub authentication: Option<AuthenticationConfig>,
182192
/// The resolved OPA authorization config, if authorization is configured.
183193
pub authorization: Option<HdfsOpaConfig>,
194+
/// The replication factor.
195+
pub dfs_replication: u8,
184196
pub rack_awareness: Option<String>,
185197
}
186198

@@ -190,9 +202,9 @@ impl ValidatedClusterConfig {
190202
authorization: Option<HdfsOpaConfig>,
191203
) -> ValidatedClusterConfig {
192204
ValidatedClusterConfig {
193-
dfs_replication: hdfs.spec.cluster_config.dfs_replication,
194205
authentication: hdfs.authentication_config().cloned(),
195206
authorization,
207+
dfs_replication: hdfs.spec.cluster_config.dfs_replication,
196208
rack_awareness: hdfs.rackawareness_config(),
197209
}
198210
}
@@ -203,20 +215,3 @@ impl ValidatedClusterConfig {
203215
pub struct ValidatedRoleConfig {
204216
pub pdb: stackable_operator::commons::pdb::PdbConfig,
205217
}
206-
207-
/// Per-rolegroup configuration: the merged CRD config plus the merged
208-
/// (role <- role group) `configOverrides`, `envOverrides`, `cliOverrides` and
209-
/// `podOverrides`.
210-
///
211-
/// This is the local-`framework` [`RoleGroupConfig`](crate::framework::role_utils::RoleGroupConfig)
212-
/// specialised for HDFS: the validated config is the per-role [`AnyNodeConfig`],
213-
/// the product-specific common config is [`JavaCommonConfig`] (whose JVM-argument
214-
/// merge is fallible, hence the vendored framework variant), and the config
215-
/// overrides are [`v1alpha1::HdfsConfigOverrides`]. The `replicas` field is used
216-
/// to derive the per-pod [`HdfsPodRef`]s via [`ValidatedCluster::pod_refs`] and
217-
/// `env_overrides` is the typed [`EnvVarSet`](stackable_operator::v2::builder::pod::container::EnvVarSet).
218-
pub type ValidatedRoleGroupConfig = crate::framework::role_utils::RoleGroupConfig<
219-
AnyNodeConfig,
220-
stackable_operator::role_utils::JavaCommonConfig,
221-
v1alpha1::HdfsConfigOverrides,
222-
>;

rust/operator-binary/src/hdfs_controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ fn rolegroup_statefulset(
455455

456456
let image = &validated.image;
457457
let merged_config = &rolegroup_config.config;
458-
let env_overrides = Some(&rolegroup_config.env_overrides);
458+
let env_overrides = &rolegroup_config.env_overrides;
459459

460460
// Pod references for all namenodes across all role groups, needed to wire up the
461461
// init containers of this role group.
@@ -627,7 +627,7 @@ spec:
627627
&rolegroup_ref,
628628
resolved_product_image,
629629
merged_config,
630-
Some(env_overrides),
630+
env_overrides,
631631
&hdfs.spec.cluster_config.zookeeper_config_map_name,
632632
&[],
633633
&Labels::new(),

0 commit comments

Comments
 (0)