Skip to content

Commit b3a4e16

Browse files
committed
fix: Remove the hive-env.sh
1 parent 326438f commit b3a4e16

File tree

5 files changed

+74
-112
lines changed

5 files changed

+74
-112
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ All notable changes to this project will be documented in this file.
1414

1515
- Default to OCI for image metadata and product image selection ([#561]).
1616

17+
### Fixed
18+
19+
- BREAKING: Remove the `hive-env.sh` config file, as e.g. setting `HADOOP_OPTS` in there had absolutely no effect.
20+
This is considered a fix, as users expected the envs to be used, but they haven't.
21+
Users should use `envOverrides` instead, which are actually working ([#572]).
22+
- BREAKING: The env variable `HADOOP_HEAPSIZE` was previously put in `hive-env.sh` and very likely had no effect.
23+
It is now passed as env variable, thus working.
24+
This might impact your stacklet as the heap size setting now actually has an effect ([#572]).
25+
1726
[#554]: https://github.com/stackabletech/hive-operator/pull/554
1827
[#560]: https://github.com/stackabletech/hive-operator/pull/560
1928
[#561]: https://github.com/stackabletech/hive-operator/pull/561

rust/operator-binary/src/controller.rs

Lines changed: 28 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ use stackable_operator::{
3737
api::{
3838
apps::v1::{StatefulSet, StatefulSetSpec},
3939
core::v1::{
40-
ConfigMap, ConfigMapVolumeSource, EmptyDirVolumeSource, EnvVar, EnvVarSource,
41-
Probe, SecretKeySelector, Service, ServicePort, ServiceSpec, TCPSocketAction,
42-
Volume,
40+
ConfigMap, ConfigMapVolumeSource, EmptyDirVolumeSource, Probe, Service,
41+
ServicePort, ServiceSpec, TCPSocketAction, Volume,
4342
},
4443
},
4544
apimachinery::pkg::{
@@ -66,7 +65,7 @@ use stackable_operator::{
6665
CustomContainerLogConfig,
6766
},
6867
},
69-
role_utils::{GenericRoleConfig, JavaCommonConfig, Role, RoleGroupRef},
68+
role_utils::{GenericRoleConfig, RoleGroupRef},
7069
status::condition::{
7170
compute_conditions, operations::ClusterOperationsConditionBuilder,
7271
statefulset::StatefulSetConditionBuilder,
@@ -81,11 +80,10 @@ use crate::{
8180
command::build_container_command_args,
8281
config::jvm::{construct_hadoop_heapsize_env, construct_non_heap_jvm_args},
8382
crd::{
84-
v1alpha1, Container, HiveClusterStatus, HiveRole, MetaStoreConfig, MetaStoreConfigFragment,
85-
APP_NAME, CORE_SITE_XML, DB_PASSWORD_ENV, DB_USERNAME_ENV, HIVE_ENV_SH, HIVE_PORT,
86-
HIVE_PORT_NAME, HIVE_SITE_XML, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT,
87-
METRICS_PORT_NAME, STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_DIR_NAME,
88-
STACKABLE_CONFIG_MOUNT_DIR, STACKABLE_CONFIG_MOUNT_DIR_NAME,
83+
v1alpha1, Container, HiveClusterStatus, HiveRole, MetaStoreConfig, APP_NAME, CORE_SITE_XML,
84+
DB_PASSWORD_ENV, DB_USERNAME_ENV, HIVE_PORT, HIVE_PORT_NAME, HIVE_SITE_XML,
85+
JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT, METRICS_PORT_NAME, STACKABLE_CONFIG_DIR,
86+
STACKABLE_CONFIG_DIR_NAME, STACKABLE_CONFIG_MOUNT_DIR, STACKABLE_CONFIG_MOUNT_DIR_NAME,
8987
STACKABLE_LOG_CONFIG_MOUNT_DIR, STACKABLE_LOG_CONFIG_MOUNT_DIR_NAME, STACKABLE_LOG_DIR,
9088
STACKABLE_LOG_DIR_NAME,
9189
},
@@ -387,7 +385,6 @@ pub async fn reconcile_hive(
387385
PropertyNameKind::Env,
388386
PropertyNameKind::Cli,
389387
PropertyNameKind::File(HIVE_SITE_XML.to_string()),
390-
PropertyNameKind::File(HIVE_ENV_SH.to_string()),
391388
PropertyNameKind::File(JVM_SECURITY_PROPERTIES_FILE.to_string()),
392389
],
393390
role.clone(),
@@ -460,7 +457,6 @@ pub async fn reconcile_hive(
460457
hive,
461458
&hive_namespace,
462459
&resolved_product_image,
463-
role,
464460
&rolegroup,
465461
rolegroup_config,
466462
s3_connection_spec.as_ref(),
@@ -604,7 +600,6 @@ fn build_metastore_rolegroup_config_map(
604600
hive: &v1alpha1::HiveCluster,
605601
hive_namespace: &str,
606602
resolved_product_image: &ResolvedProductImage,
607-
role: &Role<MetaStoreConfigFragment, GenericRoleConfig, JavaCommonConfig>,
608603
rolegroup: &RoleGroupRef<v1alpha1::HiveCluster>,
609604
role_group_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
610605
s3_connection_spec: Option<&S3ConnectionSpec>,
@@ -613,35 +608,9 @@ fn build_metastore_rolegroup_config_map(
613608
cluster_info: &KubernetesClusterInfo,
614609
) -> Result<ConfigMap> {
615610
let mut hive_site_data = String::new();
616-
let mut hive_env_data = String::new();
617611

618612
for (property_name_kind, config) in role_group_config {
619613
match property_name_kind {
620-
PropertyNameKind::File(file_name) if file_name == HIVE_ENV_SH => {
621-
let mut data = BTreeMap::from([
622-
(
623-
"HADOOP_HEAPSIZE".to_string(),
624-
construct_hadoop_heapsize_env(merged_config)
625-
.context(ConstructJvmArgumentsSnafu)?,
626-
),
627-
(
628-
"HADOOP_OPTS".to_string(),
629-
construct_non_heap_jvm_args(hive, role, &rolegroup.role_group)
630-
.context(ConstructJvmArgumentsSnafu)?,
631-
),
632-
]);
633-
634-
// other properties / overrides
635-
for (property_name, property_value) in config {
636-
data.insert(property_name.to_string(), property_value.to_string());
637-
}
638-
639-
hive_env_data = data
640-
.into_iter()
641-
.map(|(key, value)| format!("export {key}=\"{value}\""))
642-
.collect::<Vec<String>>()
643-
.join("\n");
644-
}
645614
PropertyNameKind::File(file_name) if file_name == HIVE_SITE_XML => {
646615
let mut data = BTreeMap::new();
647616

@@ -724,7 +693,6 @@ fn build_metastore_rolegroup_config_map(
724693
.build(),
725694
)
726695
.add_data(HIVE_SITE_XML, hive_site_data)
727-
.add_data(HIVE_ENV_SH, hive_env_data)
728696
.add_data(
729697
JVM_SECURITY_PROPERTIES_FILE,
730698
to_java_properties_string(jvm_sec_props.iter()).with_context(|_| {
@@ -827,6 +795,27 @@ fn build_metastore_rolegroup_statefulset(
827795
name: APP_NAME.to_string(),
828796
})?;
829797

798+
let credentials_secret_name = hive.spec.cluster_config.database.credentials_secret.clone();
799+
800+
container_builder
801+
// load database credentials to environment variables: these will be used to replace
802+
// the placeholders in hive-site.xml so that the operator does not "touch" the secret.
803+
.add_env_var_from_secret(DB_USERNAME_ENV, &credentials_secret_name, "username")
804+
.add_env_var_from_secret(DB_PASSWORD_ENV, &credentials_secret_name, "password")
805+
.add_env_var(
806+
"HADOOP_HEAPSIZE",
807+
construct_hadoop_heapsize_env(merged_config).context(ConstructJvmArgumentsSnafu)?,
808+
)
809+
.add_env_var(
810+
"HADOOP_OPTS",
811+
construct_non_heap_jvm_args(hive, role, &rolegroup_ref.role_group)
812+
.context(ConstructJvmArgumentsSnafu)?,
813+
)
814+
.add_env_var(
815+
"CONTAINERDEBUG_LOG_DIRECTORY",
816+
format!("{STACKABLE_LOG_DIR}/containerdebug"),
817+
);
818+
830819
for (property_name_kind, config) in metastore_config {
831820
if property_name_kind == &PropertyNameKind::Env {
832821
// overrides
@@ -844,21 +833,6 @@ fn build_metastore_rolegroup_statefulset(
844833
}
845834
}
846835

847-
// load database credentials to environment variables: these will be used to replace
848-
// the placeholders in hive-site.xml so that the operator does not "touch" the secret.
849-
let credentials_secret_name = hive.spec.cluster_config.database.credentials_secret.clone();
850-
851-
container_builder.add_env_vars(vec![
852-
env_var_from_secret(DB_USERNAME_ENV, &credentials_secret_name, "username"),
853-
env_var_from_secret(DB_PASSWORD_ENV, &credentials_secret_name, "password"),
854-
// Needed for the `containerdebug` process to log it's tracing information to.
855-
EnvVar {
856-
name: "CONTAINERDEBUG_LOG_DIRECTORY".to_string(),
857-
value: Some(format!("{STACKABLE_LOG_DIR}/containerdebug")),
858-
value_from: None,
859-
},
860-
]);
861-
862836
let mut pod_builder = PodBuilder::new();
863837

864838
if let Some(hdfs) = &hive.spec.cluster_config.hdfs {
@@ -1127,21 +1101,6 @@ fn build_metastore_rolegroup_statefulset(
11271101
})
11281102
}
11291103

1130-
fn env_var_from_secret(var_name: &str, secret: &str, secret_key: &str) -> EnvVar {
1131-
EnvVar {
1132-
name: String::from(var_name),
1133-
value_from: Some(EnvVarSource {
1134-
secret_key_ref: Some(SecretKeySelector {
1135-
name: String::from(secret),
1136-
key: String::from(secret_key),
1137-
..Default::default()
1138-
}),
1139-
..Default::default()
1140-
}),
1141-
..Default::default()
1142-
}
1143-
}
1144-
11451104
pub fn error_policy(
11461105
_obj: Arc<DeserializeGuard<v1alpha1::HiveCluster>>,
11471106
error: &Error,

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

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pub const STACKABLE_LOG_CONFIG_MOUNT_DIR_NAME: &str = "log-config-mount";
5151
// Config file names
5252
pub const CORE_SITE_XML: &str = "core-site.xml";
5353
pub const HIVE_SITE_XML: &str = "hive-site.xml";
54-
pub const HIVE_ENV_SH: &str = "hive-env.sh";
5554
pub const HIVE_METASTORE_LOG4J2_PROPERTIES: &str = "metastore-log4j2.properties";
5655
pub const JVM_SECURITY_PROPERTIES_FILE: &str = "security.properties";
5756

@@ -590,39 +589,35 @@ impl Configuration for MetaStoreConfigFragment {
590589
) -> Result<BTreeMap<String, Option<String>>, product_config_utils::Error> {
591590
let mut result = BTreeMap::new();
592591

593-
match file {
594-
HIVE_SITE_XML => {
595-
if let Some(warehouse_dir) = &self.warehouse_dir {
596-
result.insert(
597-
MetaStoreConfig::METASTORE_WAREHOUSE_DIR.to_string(),
598-
Some(warehouse_dir.to_string()),
599-
);
600-
}
592+
if file == HIVE_SITE_XML {
593+
if let Some(warehouse_dir) = &self.warehouse_dir {
601594
result.insert(
602-
MetaStoreConfig::CONNECTION_URL.to_string(),
603-
Some(hive.spec.cluster_config.database.conn_string.clone()),
604-
);
605-
// use a placeholder that will be replaced in the start command (also for the password)
606-
result.insert(
607-
MetaStoreConfig::CONNECTION_USER_NAME.to_string(),
608-
Some(DB_USERNAME_PLACEHOLDER.into()),
609-
);
610-
result.insert(
611-
MetaStoreConfig::CONNECTION_PASSWORD.to_string(),
612-
Some(DB_PASSWORD_PLACEHOLDER.into()),
613-
);
614-
result.insert(
615-
MetaStoreConfig::CONNECTION_DRIVER_NAME.to_string(),
616-
Some(hive.db_type().get_jdbc_driver_class().to_string()),
617-
);
618-
619-
result.insert(
620-
MetaStoreConfig::METASTORE_METRICS_ENABLED.to_string(),
621-
Some("true".to_string()),
595+
MetaStoreConfig::METASTORE_WAREHOUSE_DIR.to_string(),
596+
Some(warehouse_dir.to_string()),
622597
);
623598
}
624-
HIVE_ENV_SH => {}
625-
_ => {}
599+
result.insert(
600+
MetaStoreConfig::CONNECTION_URL.to_string(),
601+
Some(hive.spec.cluster_config.database.conn_string.clone()),
602+
);
603+
// use a placeholder that will be replaced in the start command (also for the password)
604+
result.insert(
605+
MetaStoreConfig::CONNECTION_USER_NAME.to_string(),
606+
Some(DB_USERNAME_PLACEHOLDER.into()),
607+
);
608+
result.insert(
609+
MetaStoreConfig::CONNECTION_PASSWORD.to_string(),
610+
Some(DB_PASSWORD_PLACEHOLDER.into()),
611+
);
612+
result.insert(
613+
MetaStoreConfig::CONNECTION_DRIVER_NAME.to_string(),
614+
Some(hive.db_type().get_jdbc_driver_class().to_string()),
615+
);
616+
617+
result.insert(
618+
MetaStoreConfig::METASTORE_METRICS_ENABLED.to_string(),
619+
Some("true".to_string()),
620+
);
626621
}
627622

628623
Ok(result)

tests/templates/kuttl/smoke/60-install-hive.yaml.j2

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,20 @@ spec:
3030
COMMON_VAR: role-value # overridden by role group below
3131
ROLE_VAR: role-value # only defined here at role level
3232
configOverrides:
33-
hive-env.sh:
34-
HADOOP_HEAPSIZE: "512" # also set by the operator
35-
COMMON_VAR: role-value # overridden by role group below
36-
ROLE_VAR: role-value # only defined here at role level
33+
hive-site.xml:
34+
hive.metastore.warehouse.dir: "/stackable/warehouse/override" # Also set by the operator
35+
common-var: role-value # Overridden by role group below
36+
role-var: role-value # Only defined here at role level
3737
roleGroups:
3838
default:
3939
replicas: 1
4040
envOverrides:
4141
COMMON_VAR: group-value # overrides role value
4242
GROUP_VAR: group-value # only defined here at group level
4343
configOverrides:
44-
hive-env.sh:
45-
COMMON_VAR: group-value # overridden by role group below
46-
GROUP_VAR: group-value # only defined here at group level
47-
44+
hive-site.xml:
45+
common-var: group-value
46+
group-var: group-value
4847
---
4948
apiVersion: s3.stackable.tech/v1alpha1
5049
kind: S3Connection

tests/templates/kuttl/smoke/61-assert.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ commands:
1414
# Test configOverrides
1515
#
1616
- script: |
17-
kubectl -n $NAMESPACE get cm hive-metastore-default -o yaml | yq -e '.data."hive-env.sh"' | grep "export ROLE_VAR=role-value"
18-
kubectl -n $NAMESPACE get cm hive-metastore-default -o yaml | yq -e '.data."hive-env.sh"' | grep "export GROUP_VAR=group-value"
19-
kubectl -n $NAMESPACE get cm hive-metastore-default -o yaml | yq -e '.data."hive-env.sh"' | grep "export COMMON_VAR=group-value"
20-
kubectl -n $NAMESPACE get cm hive-metastore-default -o yaml | yq -e '.data."hive-env.sh"' | grep "export HADOOP_HEAPSIZE=512"
17+
kubectl -n $NAMESPACE get cm hive-metastore-default -o yaml | yq -e '.data."hive-site.xml"' | yq -p=xml '.configuration.property[] | select(.name == "hive.metastore.warehouse.dir") | .value' | grep -qx "/stackable/warehouse/override"
18+
kubectl -n $NAMESPACE get cm hive-metastore-default -o yaml | yq -e '.data."hive-site.xml"' | yq -p=xml '.configuration.property[] | select(.name == "role-var") | .value' | grep -qx "role-value"
19+
kubectl -n $NAMESPACE get cm hive-metastore-default -o yaml | yq -e '.data."hive-site.xml"' | yq -p=xml '.configuration.property[] | select(.name == "group-var") | .value' | grep -qx "group-value"
20+
kubectl -n $NAMESPACE get cm hive-metastore-default -o yaml | yq -e '.data."hive-site.xml"' | yq -p=xml '.configuration.property[] | select(.name == "common-var") | .value' | grep -qx "group-value"

0 commit comments

Comments
 (0)