Skip to content

Commit 3cebee3

Browse files
committed
fix: remove hardcoded volume names
1 parent fb55644 commit 3cebee3

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

rust/operator-binary/src/controller/build/resource/statefulset.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ use crate::{
5858
validate::ValidatedLogging,
5959
},
6060
crd::{
61-
BROKER_ID_POD_MAP_DIR, KAFKA_HEAP_OPTS, LISTENER_BOOTSTRAP_VOLUME_NAME,
62-
LISTENER_BROKER_VOLUME_NAME, LOG_DIRS_VOLUME_NAME, METRICS_PORT, METRICS_PORT_NAME,
63-
STACKABLE_CONFIG_DIR, STACKABLE_DATA_DIR, STACKABLE_LISTENER_BOOTSTRAP_DIR,
64-
STACKABLE_LISTENER_BROKER_DIR, STACKABLE_LOG_CONFIG_DIR,
61+
BROKER_ID_POD_MAP_DIR, BROKER_ID_POD_MAP_DIR_NAME, KAFKA_HEAP_OPTS,
62+
LISTENER_BOOTSTRAP_VOLUME_NAME, LISTENER_BROKER_VOLUME_NAME, LOG_DIRS_VOLUME_NAME,
63+
METRICS_PORT, METRICS_PORT_NAME, STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_DIR_NAME,
64+
STACKABLE_DATA_DIR, STACKABLE_LISTENER_BOOTSTRAP_DIR, STACKABLE_LISTENER_BROKER_DIR,
65+
STACKABLE_LOG_CONFIG_DIR, STACKABLE_LOG_CONFIG_DIR_NAME, STACKABLE_LOG_DIR_NAME,
6566
role::{
6667
AnyConfig, KAFKA_NODE_ID_OFFSET, KafkaRole, broker::BrokerContainer,
6768
controller::ControllerContainer,
@@ -269,7 +270,7 @@ pub fn build_broker_rolegroup_statefulset(
269270
.add_container_ports(container_ports(kafka_security))
270271
.add_volume_mount(LOG_DIRS_VOLUME_NAME, STACKABLE_DATA_DIR)
271272
.context(AddVolumeMountSnafu)?
272-
.add_volume_mount("config", STACKABLE_CONFIG_DIR)
273+
.add_volume_mount(STACKABLE_CONFIG_DIR_NAME, STACKABLE_CONFIG_DIR)
273274
.context(AddVolumeMountSnafu)?
274275
.add_volume_mount(
275276
LISTENER_BOOTSTRAP_VOLUME_NAME,
@@ -278,9 +279,9 @@ pub fn build_broker_rolegroup_statefulset(
278279
.context(AddVolumeMountSnafu)?
279280
.add_volume_mount(LISTENER_BROKER_VOLUME_NAME, STACKABLE_LISTENER_BROKER_DIR)
280281
.context(AddVolumeMountSnafu)?
281-
.add_volume_mount("log-config", STACKABLE_LOG_CONFIG_DIR)
282+
.add_volume_mount(STACKABLE_LOG_CONFIG_DIR_NAME, STACKABLE_LOG_CONFIG_DIR)
282283
.context(AddVolumeMountSnafu)?
283-
.add_volume_mount("log", STACKABLE_LOG_DIR)
284+
.add_volume_mount(STACKABLE_LOG_DIR_NAME, STACKABLE_LOG_DIR)
284285
.context(AddVolumeMountSnafu)?
285286
.resources(merged_config.resources().clone().into());
286287

@@ -349,13 +350,13 @@ pub fn build_broker_rolegroup_statefulset(
349350
{
350351
pod_builder
351352
.add_volume(
352-
VolumeBuilder::new("broker-id-pod-map-dir")
353+
VolumeBuilder::new(BROKER_ID_POD_MAP_DIR_NAME)
353354
.with_config_map(broker_id_config_map_name)
354355
.build(),
355356
)
356357
.context(AddVolumeSnafu)?;
357358
cb_kafka
358-
.add_volume_mount("broker-id-pod-map-dir", BROKER_ID_POD_MAP_DIR)
359+
.add_volume_mount(BROKER_ID_POD_MAP_DIR_NAME, BROKER_ID_POD_MAP_DIR)
359360
.context(AddVolumeMountSnafu)?;
360361
}
361362

@@ -533,11 +534,11 @@ pub fn build_controller_rolegroup_statefulset(
533534
.add_container_ports(container_ports(kafka_security))
534535
.add_volume_mount(LOG_DIRS_VOLUME_NAME, STACKABLE_DATA_DIR)
535536
.context(AddVolumeMountSnafu)?
536-
.add_volume_mount("config", STACKABLE_CONFIG_DIR)
537+
.add_volume_mount(STACKABLE_CONFIG_DIR_NAME, STACKABLE_CONFIG_DIR)
537538
.context(AddVolumeMountSnafu)?
538-
.add_volume_mount("log-config", STACKABLE_LOG_CONFIG_DIR)
539+
.add_volume_mount(STACKABLE_LOG_CONFIG_DIR_NAME, STACKABLE_LOG_CONFIG_DIR)
539540
.context(AddVolumeMountSnafu)?
540-
.add_volume_mount("log", STACKABLE_LOG_DIR)
541+
.add_volume_mount(STACKABLE_LOG_DIR_NAME, STACKABLE_LOG_DIR)
541542
.context(AddVolumeMountSnafu)?
542543
.resources(merged_config.resources().clone().into())
543544
// TODO: improve probes
@@ -727,7 +728,7 @@ fn add_log_config_volume(
727728
};
728729
pod_builder
729730
.add_volume(
730-
VolumeBuilder::new("log-config")
731+
VolumeBuilder::new(STACKABLE_LOG_CONFIG_DIR_NAME)
731732
.with_config_map(config_map)
732733
.build(),
733734
)
@@ -744,7 +745,7 @@ fn add_common_pod_config(
744745
) -> Result<(), Error> {
745746
pod_builder
746747
.add_volume(Volume {
747-
name: "config".to_string(),
748+
name: STACKABLE_CONFIG_DIR_NAME.to_string(),
748749
config_map: Some(ConfigMapVolumeSource {
749750
name: resource_names.role_group_config_map().to_string(),
750751
..ConfigMapVolumeSource::default()
@@ -753,7 +754,7 @@ fn add_common_pod_config(
753754
})
754755
.context(AddVolumeSnafu)?
755756
.add_empty_dir_volume(
756-
"log",
757+
STACKABLE_LOG_DIR_NAME,
757758
Some(product_logging::framework::calculate_log_volume_size_limit(
758759
&[MAX_KAFKA_LOG_FILES_SIZE],
759760
)),

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,16 @@ pub const STACKABLE_LISTENER_BROKER_DIR: &str = "/stackable/listener-broker";
5656
pub const STACKABLE_LISTENER_BOOTSTRAP_DIR: &str = "/stackable/listener-bootstrap";
5757
pub const STACKABLE_DATA_DIR: &str = "/stackable/data";
5858
pub const STACKABLE_CONFIG_DIR: &str = "/stackable/config";
59+
pub const STACKABLE_CONFIG_DIR_NAME: &str = "config";
5960
// kerberos
6061
pub const STACKABLE_KERBEROS_DIR: &str = "/stackable/kerberos";
6162
pub const STACKABLE_KERBEROS_KRB5_PATH: &str = "/stackable/kerberos/krb5.conf";
6263
// logging
6364
pub const STACKABLE_LOG_CONFIG_DIR: &str = "/stackable/log_config";
65+
pub const STACKABLE_LOG_CONFIG_DIR_NAME: &str = "log-config";
66+
pub const STACKABLE_LOG_DIR_NAME: &str = "log";
6467
pub const BROKER_ID_POD_MAP_DIR: &str = "/stackable/broker-id-pod-map";
68+
pub const BROKER_ID_POD_MAP_DIR_NAME: &str = "broker-id-pod-map-dir";
6569

6670
#[derive(Snafu, Debug)]
6771
pub enum Error {

0 commit comments

Comments
 (0)