Skip to content

Commit 38320b0

Browse files
committed
Actually merge stuff
1 parent 87a4772 commit 38320b0

File tree

5 files changed

+257
-24
lines changed

5 files changed

+257
-24
lines changed

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

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,32 @@ spec:
373373
default: {}
374374
description: '`envOverrides` configure environment variables to be set in the Pods. It is a map from strings to strings - environment variables and the value to set. Read the [environment variable overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#env-overrides) for more information and consult the operator specific usage guide to find out about the product specific environment variables that are available.'
375375
type: object
376+
jvmArgumentOverrides:
377+
default:
378+
add: []
379+
remove: []
380+
removeRegex: []
381+
description: Allows overriding JVM arguments. Please read on the [JVM argument overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#jvm-argument-overrides) for details on the usage.
382+
properties:
383+
add:
384+
default: []
385+
description: JVM arguments to be added
386+
items:
387+
type: string
388+
type: array
389+
remove:
390+
default: []
391+
description: JVM arguments to be removed by exact match
392+
items:
393+
type: string
394+
type: array
395+
removeRegex:
396+
default: []
397+
description: JVM arguments matching any of this regexes will be removed
398+
items:
399+
type: string
400+
type: array
401+
type: object
376402
podOverrides:
377403
default: {}
378404
description: In the `podOverrides` property you can define a [PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core) to override any property that can be set on a Kubernetes Pod. Read the [Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides) for more information.
@@ -654,6 +680,32 @@ spec:
654680
default: {}
655681
description: '`envOverrides` configure environment variables to be set in the Pods. It is a map from strings to strings - environment variables and the value to set. Read the [environment variable overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#env-overrides) for more information and consult the operator specific usage guide to find out about the product specific environment variables that are available.'
656682
type: object
683+
jvmArgumentOverrides:
684+
default:
685+
add: []
686+
remove: []
687+
removeRegex: []
688+
description: Allows overriding JVM arguments. Please read on the [JVM argument overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#jvm-argument-overrides) for details on the usage.
689+
properties:
690+
add:
691+
default: []
692+
description: JVM arguments to be added
693+
items:
694+
type: string
695+
type: array
696+
remove:
697+
default: []
698+
description: JVM arguments to be removed by exact match
699+
items:
700+
type: string
701+
type: array
702+
removeRegex:
703+
default: []
704+
description: JVM arguments matching any of this regexes will be removed
705+
items:
706+
type: string
707+
type: array
708+
type: object
657709
podOverrides:
658710
default: {}
659711
description: In the `podOverrides` property you can define a [PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core) to override any property that can be set on a Kubernetes Pod. Read the [Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides) for more information.
@@ -951,6 +1003,32 @@ spec:
9511003
default: {}
9521004
description: '`envOverrides` configure environment variables to be set in the Pods. It is a map from strings to strings - environment variables and the value to set. Read the [environment variable overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#env-overrides) for more information and consult the operator specific usage guide to find out about the product specific environment variables that are available.'
9531005
type: object
1006+
jvmArgumentOverrides:
1007+
default:
1008+
add: []
1009+
remove: []
1010+
removeRegex: []
1011+
description: Allows overriding JVM arguments. Please read on the [JVM argument overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#jvm-argument-overrides) for details on the usage.
1012+
properties:
1013+
add:
1014+
default: []
1015+
description: JVM arguments to be added
1016+
items:
1017+
type: string
1018+
type: array
1019+
remove:
1020+
default: []
1021+
description: JVM arguments to be removed by exact match
1022+
items:
1023+
type: string
1024+
type: array
1025+
removeRegex:
1026+
default: []
1027+
description: JVM arguments matching any of this regexes will be removed
1028+
items:
1029+
type: string
1030+
type: array
1031+
type: object
9541032
podOverrides:
9551033
default: {}
9561034
description: In the `podOverrides` property you can define a [PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core) to override any property that can be set on a Kubernetes Pod. Read the [Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides) for more information.
@@ -1219,6 +1297,32 @@ spec:
12191297
default: {}
12201298
description: '`envOverrides` configure environment variables to be set in the Pods. It is a map from strings to strings - environment variables and the value to set. Read the [environment variable overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#env-overrides) for more information and consult the operator specific usage guide to find out about the product specific environment variables that are available.'
12211299
type: object
1300+
jvmArgumentOverrides:
1301+
default:
1302+
add: []
1303+
remove: []
1304+
removeRegex: []
1305+
description: Allows overriding JVM arguments. Please read on the [JVM argument overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#jvm-argument-overrides) for details on the usage.
1306+
properties:
1307+
add:
1308+
default: []
1309+
description: JVM arguments to be added
1310+
items:
1311+
type: string
1312+
type: array
1313+
remove:
1314+
default: []
1315+
description: JVM arguments to be removed by exact match
1316+
items:
1317+
type: string
1318+
type: array
1319+
removeRegex:
1320+
default: []
1321+
description: JVM arguments matching any of this regexes will be removed
1322+
items:
1323+
type: string
1324+
type: array
1325+
type: object
12221326
podOverrides:
12231327
default: {}
12241328
description: In the `podOverrides` property you can define a [PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core) to override any property that can be set on a Kubernetes Pod. Read the [Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides) for more information.
@@ -1472,6 +1576,32 @@ spec:
14721576
default: {}
14731577
description: '`envOverrides` configure environment variables to be set in the Pods. It is a map from strings to strings - environment variables and the value to set. Read the [environment variable overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#env-overrides) for more information and consult the operator specific usage guide to find out about the product specific environment variables that are available.'
14741578
type: object
1579+
jvmArgumentOverrides:
1580+
default:
1581+
add: []
1582+
remove: []
1583+
removeRegex: []
1584+
description: Allows overriding JVM arguments. Please read on the [JVM argument overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#jvm-argument-overrides) for details on the usage.
1585+
properties:
1586+
add:
1587+
default: []
1588+
description: JVM arguments to be added
1589+
items:
1590+
type: string
1591+
type: array
1592+
remove:
1593+
default: []
1594+
description: JVM arguments to be removed by exact match
1595+
items:
1596+
type: string
1597+
type: array
1598+
removeRegex:
1599+
default: []
1600+
description: JVM arguments matching any of this regexes will be removed
1601+
items:
1602+
type: string
1603+
type: array
1604+
type: object
14751605
podOverrides:
14761606
default: {}
14771607
description: In the `podOverrides` property you can define a [PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core) to override any property that can be set on a Kubernetes Pod. Read the [Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides) for more information.
@@ -1744,6 +1874,32 @@ spec:
17441874
default: {}
17451875
description: '`envOverrides` configure environment variables to be set in the Pods. It is a map from strings to strings - environment variables and the value to set. Read the [environment variable overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#env-overrides) for more information and consult the operator specific usage guide to find out about the product specific environment variables that are available.'
17461876
type: object
1877+
jvmArgumentOverrides:
1878+
default:
1879+
add: []
1880+
remove: []
1881+
removeRegex: []
1882+
description: Allows overriding JVM arguments. Please read on the [JVM argument overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#jvm-argument-overrides) for details on the usage.
1883+
properties:
1884+
add:
1885+
default: []
1886+
description: JVM arguments to be added
1887+
items:
1888+
type: string
1889+
type: array
1890+
remove:
1891+
default: []
1892+
description: JVM arguments to be removed by exact match
1893+
items:
1894+
type: string
1895+
type: array
1896+
removeRegex:
1897+
default: []
1898+
description: JVM arguments matching any of this regexes will be removed
1899+
items:
1900+
type: string
1901+
type: array
1902+
type: object
17471903
podOverrides:
17481904
default: {}
17491905
description: In the `podOverrides` property you can define a [PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core) to override any property that can be set on a Kubernetes Pod. Read the [Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides) for more information.

rust/crd/src/lib.rs

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ use stackable_operator::{
3838
spec::{ContainerLogConfig, Logging},
3939
},
4040
role_utils::{
41-
GenericProductSpecificCommonConfig, GenericRoleConfig, Role, RoleGroup, RoleGroupRef,
41+
self, GenericRoleConfig, JavaCommonConfig, JvmArgumentOverrides, Role, RoleGroup,
42+
RoleGroupRef,
4243
},
4344
schemars::{self, JsonSchema},
4445
status::condition::{ClusterCondition, HasStatusCondition},
@@ -72,7 +73,7 @@ pub enum Error {
7273
#[snafu(display("object has no associated namespace"))]
7374
NoNamespace,
7475

75-
#[snafu(display("missing node role {role:?}"))]
76+
#[snafu(display("missing role {role:?}"))]
7677
MissingRole { role: String },
7778

7879
#[snafu(display("missing role group {role_group:?} for role {role:?}"))]
@@ -103,6 +104,9 @@ pub enum Error {
103104

104105
#[snafu(display("failed to build role-group selector label"))]
105106
BuildRoleGroupSelectorLabel { source: LabelError },
107+
108+
#[snafu(display("failed to merge jvm argument overrides"))]
109+
MergeJvmArgumentOverrides { source: role_utils::Error },
106110
}
107111

108112
/// An HDFS cluster stacklet. This resource is managed by the Stackable operator for Apache Hadoop HDFS.
@@ -140,15 +144,15 @@ pub struct HdfsClusterSpec {
140144

141145
// no doc string - See Role struct
142146
#[serde(default, skip_serializing_if = "Option::is_none")]
143-
pub name_nodes: Option<Role<NameNodeConfigFragment>>,
147+
pub name_nodes: Option<Role<NameNodeConfigFragment, GenericRoleConfig, JavaCommonConfig>>,
144148

145149
// no doc string - See Role struct
146150
#[serde(default, skip_serializing_if = "Option::is_none")]
147-
pub data_nodes: Option<Role<DataNodeConfigFragment>>,
151+
pub data_nodes: Option<Role<DataNodeConfigFragment, GenericRoleConfig, JavaCommonConfig>>,
148152

149153
// no doc string - See Role struct
150154
#[serde(default, skip_serializing_if = "Option::is_none")]
151-
pub journal_nodes: Option<Role<JournalNodeConfigFragment>>,
155+
pub journal_nodes: Option<Role<JournalNodeConfigFragment, GenericRoleConfig, JavaCommonConfig>>,
152156
}
153157

154158
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
@@ -541,38 +545,73 @@ impl HdfsCluster {
541545
pub fn namenode_rolegroup(
542546
&self,
543547
role_group: &str,
544-
) -> Option<&RoleGroup<NameNodeConfigFragment, GenericProductSpecificCommonConfig>> {
548+
) -> Option<&RoleGroup<NameNodeConfigFragment, JavaCommonConfig>> {
545549
self.spec.name_nodes.as_ref()?.role_groups.get(role_group)
546550
}
547551

548552
/// Get a reference to the datanode [`RoleGroup`] struct if it exists.
549553
pub fn datanode_rolegroup(
550554
&self,
551555
role_group: &str,
552-
) -> Option<&RoleGroup<DataNodeConfigFragment, GenericProductSpecificCommonConfig>> {
556+
) -> Option<&RoleGroup<DataNodeConfigFragment, JavaCommonConfig>> {
553557
self.spec.data_nodes.as_ref()?.role_groups.get(role_group)
554558
}
555559

556560
/// Get a reference to the journalnode [`RoleGroup`] struct if it exists.
557561
pub fn journalnode_rolegroup(
558562
&self,
559563
role_group: &str,
560-
) -> Option<&RoleGroup<JournalNodeConfigFragment, GenericProductSpecificCommonConfig>> {
564+
) -> Option<&RoleGroup<JournalNodeConfigFragment, JavaCommonConfig>> {
561565
self.spec
562566
.journal_nodes
563567
.as_ref()?
564568
.role_groups
565569
.get(role_group)
566570
}
567571

568-
pub fn role_config(&self, role: &HdfsRole) -> Option<&GenericRoleConfig> {
569-
match role {
572+
pub fn role_config(&self, hdfs_role: &HdfsRole) -> Option<&GenericRoleConfig> {
573+
match hdfs_role {
570574
HdfsRole::NameNode => self.spec.name_nodes.as_ref().map(|nn| &nn.role_config),
571575
HdfsRole::DataNode => self.spec.data_nodes.as_ref().map(|dn| &dn.role_config),
572576
HdfsRole::JournalNode => self.spec.journal_nodes.as_ref().map(|jn| &jn.role_config),
573577
}
574578
}
575579

580+
pub fn get_merged_jvm_argument_overrides(
581+
&self,
582+
hdfs_role: &HdfsRole,
583+
role_group: &str,
584+
operator_generated: &JvmArgumentOverrides,
585+
) -> Result<JvmArgumentOverrides, Error> {
586+
match hdfs_role {
587+
HdfsRole::JournalNode => self
588+
.spec
589+
.journal_nodes
590+
.as_ref()
591+
.with_context(|| MissingRoleSnafu {
592+
role: HdfsRole::JournalNode.to_string(),
593+
})?
594+
.get_merged_jvm_argument_overrides(role_group, operator_generated),
595+
HdfsRole::NameNode => self
596+
.spec
597+
.name_nodes
598+
.as_ref()
599+
.with_context(|| MissingRoleSnafu {
600+
role: HdfsRole::NameNode.to_string(),
601+
})?
602+
.get_merged_jvm_argument_overrides(role_group, operator_generated),
603+
HdfsRole::DataNode => self
604+
.spec
605+
.data_nodes
606+
.as_ref()
607+
.with_context(|| MissingRoleSnafu {
608+
role: HdfsRole::DataNode.to_string(),
609+
})?
610+
.get_merged_jvm_argument_overrides(role_group, operator_generated),
611+
}
612+
.context(MergeJvmArgumentOverridesSnafu)
613+
}
614+
576615
pub fn pod_overrides_for_role(&self, role: &HdfsRole) -> Option<&PodTemplateSpec> {
577616
match role {
578617
HdfsRole::NameNode => self
@@ -768,7 +807,11 @@ impl HdfsCluster {
768807
String,
769808
(
770809
Vec<PropertyNameKind>,
771-
Role<impl Configuration<Configurable = HdfsCluster>>,
810+
Role<
811+
impl Configuration<Configurable = HdfsCluster>,
812+
GenericRoleConfig,
813+
JavaCommonConfig,
814+
>,
772815
),
773816
>,
774817
Error,

0 commit comments

Comments
 (0)