Skip to content

Commit

Permalink
move into constants
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer committed Oct 19, 2023
1 parent ff7135b commit 753a77a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ pub const METRICS_PORT: i32 = 8081;

pub const JVM_HEAP_FACTOR: f32 = 0.8;

const DEFAULT_MASTER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration = Duration::from_minutes_unchecked(20);
const DEFAULT_REGION_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration =
Duration::from_minutes_unchecked(60);
const DEFAULT_REST_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration = Duration::from_minutes_unchecked(5);

#[derive(Snafu, Debug)]
pub enum Error {
#[snafu(display("the role [{role}] is invalid and does not exist in HBase"))]
Expand Down Expand Up @@ -235,9 +240,9 @@ impl HbaseRole {
},
};
let graceful_shutdown_timeout = match &self {
HbaseRole::Master => Duration::from_minutes_unchecked(20),
HbaseRole::RegionServer => Duration::from_minutes_unchecked(60),
HbaseRole::RestServer => Duration::from_minutes_unchecked(5),
HbaseRole::Master => DEFAULT_MASTER_GRACEFUL_SHUTDOWN_TIMEOUT,
HbaseRole::RegionServer => DEFAULT_REGION_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT,
HbaseRole::RestServer => DEFAULT_REST_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT,
};

HbaseConfigFragment {
Expand Down Expand Up @@ -313,10 +318,8 @@ pub struct HbaseConfig {
pub logging: Logging<Container>,
#[fragment_attrs(serde(default))]
pub affinity: StackableAffinity,
/// Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the operator documentation for details.
#[fragment_attrs(serde(default))]
#[fragment_attrs(schemars(
description = "Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the operator documentation for details."
))]
pub graceful_shutdown_timeout: Option<Duration>,
}

Expand Down
4 changes: 2 additions & 2 deletions rust/operator-binary/src/hbase_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub enum Error {
FailedToCreatePdb {
source: crate::operations::pdb::Error,
},
#[snafu(display("failed to configure graceful shutdown"), context(false))]
#[snafu(display("failed to configure graceful shutdown"))]
GracefulShutdown {
source: crate::operations::graceful_shutdown::Error,
},
Expand Down Expand Up @@ -799,7 +799,7 @@ fn build_rolegroup_statefulset(
));
}

add_graceful_shutdown_config(config, &mut pod_builder)?;
add_graceful_shutdown_config(config, &mut pod_builder).context(GracefulShutdownSnafu)?;

let mut pod_template = pod_builder.build_template();
if let Some(role) = role {
Expand Down

0 comments on commit 753a77a

Please sign in to comment.