Skip to content

Commit 1f5019f

Browse files
committed
wip: Inject the vector aggregator address into the vector config using an env var
1 parent 58f7170 commit 1f5019f

File tree

9 files changed

+638
-378
lines changed

9 files changed

+638
-378
lines changed

Cargo.lock

Lines changed: 441 additions & 172 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ tokio = { version = "1.40", features = ["full"] }
3131
tracing = "0.1"
3232
tracing-futures = { version = "0.2", features = ["futures-03"] }
3333

34-
# [patch."https://github.com/stackabletech/operator-rs.git"]
35-
# stackable-operator = { path = "../operator-rs/crates/stackable-operator" }
34+
[patch."https://github.com/stackabletech/operator-rs.git"]
35+
stackable-operator = { path = "../operator-rs/crates/stackable-operator" }
3636
# stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }

rust/operator-binary/src/container.rs

Lines changed: 71 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ pub enum Error {
142142
AddVolumeMount {
143143
source: builder::pod::container::Error,
144144
},
145+
146+
#[snafu(display("vector agent is enabled but vector aggregator ConfigMap is missing"))]
147+
VectorAggregatorConfigMapMissing,
145148
}
146149

147150
/// ContainerConfig contains information to create all main, side and init containers for
@@ -240,21 +243,34 @@ impl ContainerConfig {
240243

241244
// Vector side container
242245
if merged_config.vector_logging_enabled() {
243-
pb.add_container(
244-
product_logging::framework::vector_container(
245-
resolved_product_image,
246-
ContainerConfig::HDFS_CONFIG_VOLUME_MOUNT_NAME,
247-
ContainerConfig::STACKABLE_LOG_VOLUME_MOUNT_NAME,
248-
Some(&merged_config.vector_logging()),
249-
ResourceRequirementsBuilder::new()
250-
.with_cpu_request("250m")
251-
.with_cpu_limit("500m")
252-
.with_memory_request("128Mi")
253-
.with_memory_limit("128Mi")
254-
.build(),
255-
)
256-
.context(ConfigureLoggingSnafu)?,
257-
);
246+
match hdfs
247+
.spec
248+
.cluster_config
249+
.vector_aggregator_config_map_name
250+
.to_owned()
251+
{
252+
Some(vector_aggregator_config_map_name) => {
253+
pb.add_container(
254+
product_logging::framework::vector_container(
255+
resolved_product_image,
256+
ContainerConfig::HDFS_CONFIG_VOLUME_MOUNT_NAME,
257+
ContainerConfig::STACKABLE_LOG_VOLUME_MOUNT_NAME,
258+
Some(&merged_config.vector_logging()),
259+
ResourceRequirementsBuilder::new()
260+
.with_cpu_request("250m")
261+
.with_cpu_limit("500m")
262+
.with_memory_request("128Mi")
263+
.with_memory_limit("128Mi")
264+
.build(),
265+
&vector_aggregator_config_map_name,
266+
)
267+
.context(ConfigureLoggingSnafu)?,
268+
);
269+
}
270+
None => {
271+
VectorAggregatorConfigMapMissingSnafu.fail()?;
272+
}
273+
}
258274
}
259275

260276
if let Some(authentication_config) = hdfs.authentication_config() {
@@ -869,37 +885,52 @@ wait_for_termination $!
869885
// See https://github.com/stackabletech/hdfs-operator/issues/138 for details
870886
if let ContainerConfig::Hdfs { role, .. } = self {
871887
let role_opts_name = role.hadoop_opts_env_var_for_role().to_string();
872-
env.insert(role_opts_name.clone(), EnvVar {
873-
name: role_opts_name,
874-
value: Some(self.build_hadoop_opts(hdfs, role_group, resources)?),
875-
..EnvVar::default()
876-
});
888+
env.insert(
889+
role_opts_name.clone(),
890+
EnvVar {
891+
name: role_opts_name,
892+
value: Some(self.build_hadoop_opts(hdfs, role_group, resources)?),
893+
..EnvVar::default()
894+
},
895+
);
877896
}
878897

879-
env.insert("HADOOP_OPTS".to_string(), EnvVar {
880-
name: "HADOOP_OPTS".to_string(),
881-
value: Some(construct_global_jvm_args(hdfs.has_kerberos_enabled())),
882-
..EnvVar::default()
883-
});
884-
if hdfs.has_kerberos_enabled() {
885-
env.insert("KRB5_CONFIG".to_string(), EnvVar {
886-
name: "KRB5_CONFIG".to_string(),
887-
value: Some(format!("{KERBEROS_CONTAINER_PATH}/krb5.conf")),
888-
..EnvVar::default()
889-
});
890-
env.insert("KRB5_CLIENT_KTNAME".to_string(), EnvVar {
891-
name: "KRB5_CLIENT_KTNAME".to_string(),
892-
value: Some(format!("{KERBEROS_CONTAINER_PATH}/keytab")),
898+
env.insert(
899+
"HADOOP_OPTS".to_string(),
900+
EnvVar {
901+
name: "HADOOP_OPTS".to_string(),
902+
value: Some(construct_global_jvm_args(hdfs.has_kerberos_enabled())),
893903
..EnvVar::default()
894-
});
904+
},
905+
);
906+
if hdfs.has_kerberos_enabled() {
907+
env.insert(
908+
"KRB5_CONFIG".to_string(),
909+
EnvVar {
910+
name: "KRB5_CONFIG".to_string(),
911+
value: Some(format!("{KERBEROS_CONTAINER_PATH}/krb5.conf")),
912+
..EnvVar::default()
913+
},
914+
);
915+
env.insert(
916+
"KRB5_CLIENT_KTNAME".to_string(),
917+
EnvVar {
918+
name: "KRB5_CLIENT_KTNAME".to_string(),
919+
value: Some(format!("{KERBEROS_CONTAINER_PATH}/keytab")),
920+
..EnvVar::default()
921+
},
922+
);
895923
}
896924

897925
// Needed for the `containerdebug` process to log it's tracing information to.
898-
env.insert("CONTAINERDEBUG_LOG_DIRECTORY".to_string(), EnvVar {
899-
name: "CONTAINERDEBUG_LOG_DIRECTORY".to_string(),
900-
value: Some(format!("{STACKABLE_LOG_DIR}/containerdebug")),
901-
value_from: None,
902-
});
926+
env.insert(
927+
"CONTAINERDEBUG_LOG_DIRECTORY".to_string(),
928+
EnvVar {
929+
name: "CONTAINERDEBUG_LOG_DIRECTORY".to_string(),
930+
value: Some(format!("{STACKABLE_LOG_DIR}/containerdebug")),
931+
value_from: None,
932+
},
933+
);
903934

904935
// Overrides need to come last
905936
let mut env_override_vars: BTreeMap<String, EnvVar> =

rust/operator-binary/src/crd/affinity.rs

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -74,58 +74,64 @@ spec:
7474
let hdfs: v1alpha1::HdfsCluster = serde_yaml::from_str(input).unwrap();
7575
let merged_config = role.merged_config(&hdfs, "default").unwrap();
7676

77-
assert_eq!(merged_config.affinity, StackableAffinity {
78-
pod_affinity: Some(PodAffinity {
79-
preferred_during_scheduling_ignored_during_execution: Some(vec![
80-
WeightedPodAffinityTerm {
81-
pod_affinity_term: PodAffinityTerm {
82-
label_selector: Some(LabelSelector {
83-
match_expressions: None,
84-
match_labels: Some(BTreeMap::from([
85-
("app.kubernetes.io/name".to_string(), "hdfs".to_string(),),
86-
(
87-
"app.kubernetes.io/instance".to_string(),
88-
"simple-hdfs".to_string(),
89-
),
90-
]))
91-
}),
92-
namespace_selector: None,
93-
namespaces: None,
94-
topology_key: "kubernetes.io/hostname".to_string(),
95-
..PodAffinityTerm::default()
96-
},
97-
weight: 20
98-
}
99-
]),
100-
required_during_scheduling_ignored_during_execution: None,
101-
}),
102-
pod_anti_affinity: Some(PodAntiAffinity {
103-
preferred_during_scheduling_ignored_during_execution: Some(vec![
104-
WeightedPodAffinityTerm {
105-
pod_affinity_term: PodAffinityTerm {
106-
label_selector: Some(LabelSelector {
107-
match_expressions: None,
108-
match_labels: Some(BTreeMap::from([
109-
("app.kubernetes.io/name".to_string(), "hdfs".to_string(),),
110-
(
111-
"app.kubernetes.io/instance".to_string(),
112-
"simple-hdfs".to_string(),
113-
),
114-
("app.kubernetes.io/component".to_string(), role.to_string(),)
115-
]))
116-
}),
117-
namespace_selector: None,
118-
namespaces: None,
119-
topology_key: "kubernetes.io/hostname".to_string(),
120-
..PodAffinityTerm::default()
121-
},
122-
weight: 70
123-
}
124-
]),
125-
required_during_scheduling_ignored_during_execution: None,
126-
}),
127-
node_affinity: None,
128-
node_selector: None,
129-
});
77+
assert_eq!(
78+
merged_config.affinity,
79+
StackableAffinity {
80+
pod_affinity: Some(PodAffinity {
81+
preferred_during_scheduling_ignored_during_execution: Some(vec![
82+
WeightedPodAffinityTerm {
83+
pod_affinity_term: PodAffinityTerm {
84+
label_selector: Some(LabelSelector {
85+
match_expressions: None,
86+
match_labels: Some(BTreeMap::from([
87+
("app.kubernetes.io/name".to_string(), "hdfs".to_string(),),
88+
(
89+
"app.kubernetes.io/instance".to_string(),
90+
"simple-hdfs".to_string(),
91+
),
92+
]))
93+
}),
94+
namespace_selector: None,
95+
namespaces: None,
96+
topology_key: "kubernetes.io/hostname".to_string(),
97+
..PodAffinityTerm::default()
98+
},
99+
weight: 20
100+
}
101+
]),
102+
required_during_scheduling_ignored_during_execution: None,
103+
}),
104+
pod_anti_affinity: Some(PodAntiAffinity {
105+
preferred_during_scheduling_ignored_during_execution: Some(vec![
106+
WeightedPodAffinityTerm {
107+
pod_affinity_term: PodAffinityTerm {
108+
label_selector: Some(LabelSelector {
109+
match_expressions: None,
110+
match_labels: Some(BTreeMap::from([
111+
("app.kubernetes.io/name".to_string(), "hdfs".to_string(),),
112+
(
113+
"app.kubernetes.io/instance".to_string(),
114+
"simple-hdfs".to_string(),
115+
),
116+
(
117+
"app.kubernetes.io/component".to_string(),
118+
role.to_string(),
119+
)
120+
]))
121+
}),
122+
namespace_selector: None,
123+
namespaces: None,
124+
topology_key: "kubernetes.io/hostname".to_string(),
125+
..PodAffinityTerm::default()
126+
},
127+
weight: 70
128+
}
129+
]),
130+
required_during_scheduling_ignored_during_execution: None,
131+
}),
132+
node_affinity: None,
133+
node_selector: None,
134+
}
135+
);
130136
}
131137
}

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,15 +1317,18 @@ impl DataNodeConfigFragment {
13171317
limit: Some(Quantity("512Mi".to_owned())),
13181318
runtime_limits: NoRuntimeLimitsFragment {},
13191319
},
1320-
storage: BTreeMap::from([("data".to_string(), DataNodePvcFragment {
1321-
pvc: PvcConfigFragment {
1322-
capacity: Some(Quantity("10Gi".to_owned())),
1323-
storage_class: None,
1324-
selectors: None,
1320+
storage: BTreeMap::from([(
1321+
"data".to_string(),
1322+
DataNodePvcFragment {
1323+
pvc: PvcConfigFragment {
1324+
capacity: Some(Quantity("10Gi".to_owned())),
1325+
storage_class: None,
1326+
selectors: None,
1327+
},
1328+
count: Some(1),
1329+
hdfs_storage_type: Some(HdfsStorageType::default()),
13251330
},
1326-
count: Some(1),
1327-
hdfs_storage_type: Some(HdfsStorageType::default()),
1328-
})]),
1331+
)]),
13291332
},
13301333
logging: product_logging::spec::default_logging(),
13311334
listener_class: Some(DEFAULT_LISTENER_CLASS.to_string()),

rust/operator-binary/src/crd/storage.rs

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,18 @@ mod test {
198198
#[test]
199199
pub fn test_datanode_storage_defaults() {
200200
let data_node_storage = DataNodeStorageConfig {
201-
pvcs: BTreeMap::from([("data".to_string(), DataNodePvc {
202-
pvc: PvcConfig {
203-
capacity: Some(Quantity("5Gi".to_owned())),
204-
storage_class: None,
205-
selectors: None,
201+
pvcs: BTreeMap::from([(
202+
"data".to_string(),
203+
DataNodePvc {
204+
pvc: PvcConfig {
205+
capacity: Some(Quantity("5Gi".to_owned())),
206+
storage_class: None,
207+
selectors: None,
208+
},
209+
count: 1,
210+
hdfs_storage_type: HdfsStorageType::default(),
206211
},
207-
count: 1,
208-
hdfs_storage_type: HdfsStorageType::default(),
209-
})]),
212+
)]),
210213
};
211214

212215
let pvcs = data_node_storage.build_pvcs();
@@ -236,30 +239,36 @@ mod test {
236239
pub fn test_datanode_storage_multiple_storage_types() {
237240
let data_node_storage = DataNodeStorageConfig {
238241
pvcs: BTreeMap::from([
239-
("hdd".to_string(), DataNodePvc {
240-
pvc: PvcConfig {
241-
capacity: Some(Quantity("12Ti".to_owned())),
242-
storage_class: Some("hdd-storage-class".to_string()),
243-
selectors: Some(LabelSelector {
244-
match_expressions: None,
245-
match_labels: Some(BTreeMap::from([(
246-
"foo".to_string(),
247-
"bar".to_string(),
248-
)])),
249-
}),
242+
(
243+
"hdd".to_string(),
244+
DataNodePvc {
245+
pvc: PvcConfig {
246+
capacity: Some(Quantity("12Ti".to_owned())),
247+
storage_class: Some("hdd-storage-class".to_string()),
248+
selectors: Some(LabelSelector {
249+
match_expressions: None,
250+
match_labels: Some(BTreeMap::from([(
251+
"foo".to_string(),
252+
"bar".to_string(),
253+
)])),
254+
}),
255+
},
256+
count: 8,
257+
hdfs_storage_type: HdfsStorageType::Disk,
250258
},
251-
count: 8,
252-
hdfs_storage_type: HdfsStorageType::Disk,
253-
}),
254-
("ssd".to_string(), DataNodePvc {
255-
pvc: PvcConfig {
256-
capacity: Some(Quantity("2Ti".to_owned())),
257-
storage_class: Some("premium-ssd".to_string()),
258-
selectors: None,
259+
),
260+
(
261+
"ssd".to_string(),
262+
DataNodePvc {
263+
pvc: PvcConfig {
264+
capacity: Some(Quantity("2Ti".to_owned())),
265+
storage_class: Some("premium-ssd".to_string()),
266+
selectors: None,
267+
},
268+
count: 4,
269+
hdfs_storage_type: HdfsStorageType::Ssd,
259270
},
260-
count: 4,
261-
hdfs_storage_type: HdfsStorageType::Ssd,
262-
}),
271+
),
263272
]),
264273
};
265274
let pvcs = data_node_storage.build_pvcs();

0 commit comments

Comments
 (0)