Skip to content

Commit 2d36812

Browse files
committed
implement review feedback
1 parent e8c517e commit 2d36812

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

rust/crd/src/lib.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ const DEFAULT_REGION_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration =
8787
const DEFAULT_REST_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration = Duration::from_minutes_unchecked(5);
8888

8989
// Auto TLS certificate lifetime
90-
pub const DEFAULT_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(7);
90+
const DEFAULT_MASTER_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(7);
91+
const DEFAULT_REGION_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(7);
92+
const DEFAULT_REST_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(7);
9193

9294
#[derive(Snafu, Debug)]
9395
pub enum Error {
@@ -307,9 +309,15 @@ impl HbaseRole {
307309
};
308310

309311
let graceful_shutdown_timeout = match &self {
310-
HbaseRole::Master => DEFAULT_MASTER_GRACEFUL_SHUTDOWN_TIMEOUT,
311-
HbaseRole::RegionServer => DEFAULT_REGION_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT,
312-
HbaseRole::RestServer => DEFAULT_REST_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT,
312+
HbaseRole::Master => Some(DEFAULT_MASTER_GRACEFUL_SHUTDOWN_TIMEOUT),
313+
HbaseRole::RegionServer => Some(DEFAULT_REGION_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT),
314+
HbaseRole::RestServer => Some(DEFAULT_REST_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT),
315+
};
316+
317+
let requested_secret_lifetime = match &self {
318+
HbaseRole::Master => Some(DEFAULT_MASTER_SECRET_LIFETIME),
319+
HbaseRole::RegionServer => Some(DEFAULT_REGION_SECRET_LIFETIME),
320+
HbaseRole::RestServer => Some(DEFAULT_REST_SECRET_LIFETIME),
313321
};
314322

315323
HbaseConfigFragment {
@@ -318,8 +326,8 @@ impl HbaseRole {
318326
resources,
319327
logging: product_logging::spec::default_logging(),
320328
affinity: get_affinity(cluster_name, self, hdfs_discovery_cm_name),
321-
graceful_shutdown_timeout: Some(graceful_shutdown_timeout),
322-
requested_secret_lifetime: Some(DEFAULT_SECRET_LIFETIME),
329+
graceful_shutdown_timeout,
330+
requested_secret_lifetime,
323331
}
324332
}
325333

rust/operator-binary/src/hbase_controller.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ use strum::{EnumDiscriminants, IntoStaticStr, ParseError};
6767

6868
use stackable_hbase_crd::{
6969
merged_env, Container, HbaseCluster, HbaseClusterStatus, HbaseConfig, HbaseConfigFragment,
70-
HbaseRole, APP_NAME, CONFIG_DIR_NAME, DEFAULT_SECRET_LIFETIME, HBASE_ENV_SH, HBASE_HEAPSIZE,
71-
HBASE_MANAGES_ZK, HBASE_MASTER_OPTS, HBASE_REGIONSERVER_OPTS, HBASE_REST_OPTS,
72-
HBASE_REST_PORT_NAME_HTTP, HBASE_REST_PORT_NAME_HTTPS, HBASE_SITE_XML, JVM_HEAP_FACTOR,
73-
JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT, SSL_CLIENT_XML, SSL_SERVER_XML,
70+
HbaseRole, APP_NAME, CONFIG_DIR_NAME, HBASE_ENV_SH, HBASE_HEAPSIZE, HBASE_MANAGES_ZK,
71+
HBASE_MASTER_OPTS, HBASE_REGIONSERVER_OPTS, HBASE_REST_OPTS, HBASE_REST_PORT_NAME_HTTP,
72+
HBASE_REST_PORT_NAME_HTTPS, HBASE_SITE_XML, JVM_HEAP_FACTOR, JVM_SECURITY_PROPERTIES_FILE,
73+
METRICS_PORT, SSL_CLIENT_XML, SSL_SERVER_XML,
7474
};
7575

7676
use crate::product_logging::STACKABLE_LOG_DIR;
@@ -113,6 +113,9 @@ pub struct Ctx {
113113
#[strum_discriminants(derive(IntoStaticStr))]
114114
#[allow(clippy::enum_variant_names)]
115115
pub enum Error {
116+
#[snafu(display("missing secret lifetime"))]
117+
MissingSecretLifetime,
118+
116119
#[snafu(display("object defines no version"))]
117120
ObjectHasNoVersion,
118121

@@ -777,7 +780,7 @@ fn build_rolegroup_statefulset(
777780
hbase_role: &HbaseRole,
778781
rolegroup_ref: &RoleGroupRef<HbaseCluster>,
779782
rolegroup_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
780-
config: &HbaseConfig,
783+
merged_config: &HbaseConfig,
781784
resolved_product_image: &ResolvedProductImage,
782785
service_account: &ServiceAccount,
783786
) -> Result<StatefulSet> {
@@ -899,7 +902,7 @@ fn build_rolegroup_statefulset(
899902
.add_volume_mount("log", STACKABLE_LOG_DIR)
900903
.context(AddVolumeMountSnafu)?
901904
.add_container_ports(ports)
902-
.resources(config.resources.clone().into())
905+
.resources(merged_config.resources.clone().into())
903906
.startup_probe(startup_probe)
904907
.liveness_probe(liveness_probe)
905908
.readiness_probe(readiness_probe);
@@ -919,7 +922,7 @@ fn build_rolegroup_statefulset(
919922
pod_builder
920923
.metadata(pb_metadata)
921924
.image_pull_secrets_from_product_image(resolved_product_image)
922-
.affinity(&config.affinity)
925+
.affinity(&merged_config.affinity)
923926
.add_volume(stackable_operator::k8s_openapi::api::core::v1::Volume {
924927
name: "hbase-config".to_string(),
925928
config_map: Some(ConfigMapVolumeSource {
@@ -959,7 +962,7 @@ fn build_rolegroup_statefulset(
959962
Some(ContainerLogConfigChoice::Custom(CustomContainerLogConfig {
960963
custom: ConfigMapLogConfig { config_map },
961964
})),
962-
}) = config.logging.containers.get(&Container::Hbase)
965+
}) = merged_config.logging.containers.get(&Container::Hbase)
963966
{
964967
pod_builder
965968
.add_volume(Volume {
@@ -984,29 +987,29 @@ fn build_rolegroup_statefulset(
984987
.context(AddVolumeSnafu)?;
985988
}
986989

987-
add_graceful_shutdown_config(config, &mut pod_builder).context(GracefulShutdownSnafu)?;
990+
add_graceful_shutdown_config(merged_config, &mut pod_builder).context(GracefulShutdownSnafu)?;
988991
if hbase.has_kerberos_enabled() {
989992
add_kerberos_pod_config(
990993
hbase,
991994
hbase_role,
992995
&mut hbase_container,
993996
&mut pod_builder,
994-
config
997+
merged_config
995998
.requested_secret_lifetime
996-
.unwrap_or(DEFAULT_SECRET_LIFETIME),
999+
.context(MissingSecretLifetimeSnafu)?,
9971000
)
9981001
.context(AddKerberosConfigSnafu)?;
9991002
}
10001003
pod_builder.add_container(hbase_container.build());
10011004

10021005
// Vector sidecar shall be the last container in the list
1003-
if config.logging.enable_vector_agent {
1006+
if merged_config.logging.enable_vector_agent {
10041007
pod_builder.add_container(
10051008
product_logging::framework::vector_container(
10061009
resolved_product_image,
10071010
"hbase-config",
10081011
"log",
1009-
config.logging.containers.get(&Container::Vector),
1012+
merged_config.logging.containers.get(&Container::Vector),
10101013
ResourceRequirementsBuilder::new()
10111014
.with_cpu_request("250m")
10121015
.with_cpu_limit("500m")

0 commit comments

Comments
 (0)