Skip to content

Commit 6e203e9

Browse files
committed
fix: cleanup, visibility, constants
1 parent 83bfe01 commit 6e203e9

14 files changed

Lines changed: 82 additions & 94 deletions

File tree

rust/operator-binary/src/authentication/ldap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn add_authorizer_config(config: &mut BTreeMap<String, String>) {
8383
);
8484
}
8585

86-
pub fn generate_runtime_properties_config(
86+
pub(super) fn generate_runtime_properties_config(
8787
provider: &ldap::v1alpha1::AuthenticationProvider,
8888
config: &mut BTreeMap<String, String>,
8989
) -> Result<(), Error> {
@@ -93,7 +93,7 @@ pub fn generate_runtime_properties_config(
9393
Ok(())
9494
}
9595

96-
pub fn prepare_container_commands(
96+
pub(super) fn prepare_container_commands(
9797
provider: &ldap::v1alpha1::AuthenticationProvider,
9898
command: &mut Vec<String>,
9999
) {
@@ -106,7 +106,7 @@ pub fn prepare_container_commands(
106106
}
107107
}
108108

109-
pub fn add_volumes_and_mounts(
109+
pub(super) fn add_volumes_and_mounts(
110110
provider: &ldap::v1alpha1::AuthenticationProvider,
111111
pb: &mut PodBuilder,
112112
cb_druid: &mut ContainerBuilder,

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
crd::{
1212
DruidRole,
1313
authentication::{AuthenticationClassResolved, AuthenticationClassesResolved},
14-
security::{ESCALATOR_INTERNAL_CLIENT_PASSWORD_ENV, INTERNAL_INITIAL_CLIENT_PASSWORD_ENV},
14+
security::INTERNAL_INITIAL_CLIENT_PASSWORD_ENV,
1515
v1alpha1,
1616
},
1717
internal_secret::{build_shared_internal_secret_name, env_var_from_secret},
@@ -20,6 +20,9 @@ use crate::{
2020
pub mod ldap;
2121
pub mod oidc;
2222

23+
// It seems this needs to be the same password for Druid to work, so we re-use the existing env variable.
24+
const ESCALATOR_INTERNAL_CLIENT_PASSWORD_ENV: &str = INTERNAL_INITIAL_CLIENT_PASSWORD_ENV;
25+
2326
type Result<T, E = Error> = std::result::Result<T, E>;
2427

2528
#[derive(Snafu, Debug)]

rust/operator-binary/src/authentication/oidc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn add_authorizer_config(config: &mut BTreeMap<String, String>) {
9797
/// Creates the OIDC parts of the runtime.properties config file.
9898
/// OIDC authentication is not configured on middlemanagers, because end users don't interact with them directly using the web console and
9999
/// turning on OIDC will lead to problems with the communication with coordinators during data ingest.
100-
pub fn generate_runtime_properties_config(
100+
pub(super) fn generate_runtime_properties_config(
101101
provider: &oidc::v1alpha1::AuthenticationProvider,
102102
oidc: &DruidClientAuthenticationOptions,
103103
role: &DruidRole,
@@ -118,7 +118,7 @@ pub fn generate_runtime_properties_config(
118118
Ok(())
119119
}
120120

121-
pub fn main_container_commands(
121+
pub(super) fn main_container_commands(
122122
provider: &oidc::v1alpha1::AuthenticationProvider,
123123
command: &mut Vec<String>,
124124
) {
@@ -129,7 +129,7 @@ pub fn main_container_commands(
129129

130130
/// Mounts the OIDC credentials secret and the auto-generated internal secret containing the cookie passphrase.
131131
/// Not necessary on middlemanagers, because OIDC is not configured on them.
132-
pub fn get_env_var_mounts(
132+
pub(super) fn get_env_var_mounts(
133133
role: &DruidRole,
134134
oidc: &DruidClientAuthenticationOptions,
135135
internal_secret_name: &str,
@@ -153,7 +153,7 @@ pub fn get_env_var_mounts(
153153
envs
154154
}
155155

156-
pub fn add_volumes_and_mounts(
156+
pub(super) fn add_volumes_and_mounts(
157157
provider: &oidc::v1alpha1::AuthenticationProvider,
158158
pb: &mut PodBuilder,
159159
cb_druid: &mut ContainerBuilder,

rust/operator-binary/src/controller/build/discovery.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ use crate::{
1818

1919
#[derive(Snafu, Debug)]
2020
pub enum Error {
21-
#[snafu(display("failed to get service FQDN"))]
22-
NoServiceFqdn,
23-
2421
#[snafu(display("failed to build ConfigMap"))]
2522
BuildConfigMap {
2623
source: stackable_operator::builder::configmap::Error,

rust/operator-binary/src/controller/validate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ pub type RoleGroupName = String;
8888
#[derive(Clone)]
8989
pub struct DruidRoleGroupConfig {
9090
pub merged_config: CommonRoleGroupConfig,
91-
/// The runtime.properties "validated config" (compute_files + recommended defaults + merged overrides).
91+
/// The runtime.properties config: recommended defaults plus merged overrides.
9292
pub runtime_config: BTreeMap<String, String>,
9393
/// The security.properties "validated config".
9494
pub security_config: BTreeMap<String, String>,
95-
/// Merged env overrides (role <- rolegroup). compute_env is empty for druid.
95+
/// Merged env overrides (role <- rolegroup). Druid has no computed env vars.
9696
pub env: BTreeMap<String, String>,
9797
/// The fully rendered `jvm.config` (operator defaults merged with the role/rolegroup JVM
9898
/// argument overrides). Precomputed here so the config-map builder no longer needs the raw
@@ -300,8 +300,8 @@ fn build_role_group_config(
300300

301301
const INDEXER_JAVA_OPTS: &str = "druid.indexer.runner.javaOptsArray";
302302

303-
/// The `druid.indexer.runner.javaOptsArray` entry that `MiddleManagerConfigFragment::compute_files`
304-
/// adds for *every* file (runtime.properties and security.properties).
303+
/// The `druid.indexer.runner.javaOptsArray` entry that must be present in *every* rendered file
304+
/// (runtime.properties and security.properties) for MiddleManagers.
305305
fn middlemanager_indexer_java_opts() -> (String, String) {
306306
(
307307
INDEXER_JAVA_OPTS.to_string(),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::crd::v1alpha1::DruidClusterConfig;
1313
type Result<T, E = Error> = std::result::Result<T, E>;
1414

1515
// The assumed OIDC provider if no hint is given in the AuthClass
16-
pub const DEFAULT_OIDC_PROVIDER: oidc::v1alpha1::IdentityProviderHint =
16+
const DEFAULT_OIDC_PROVIDER: oidc::v1alpha1::IdentityProviderHint =
1717
oidc::v1alpha1::IdentityProviderHint::Keycloak;
1818

1919
const SUPPORTED_OIDC_PROVIDERS: &[oidc::v1alpha1::IdentityProviderHint] =
@@ -101,7 +101,7 @@ impl AuthenticationClassesResolved {
101101
}
102102

103103
/// Retrieves all provided `AuthenticationClass` references and checks if the configuration (TLS settings, secret class, OIDC config, etc.) is valid.
104-
pub async fn resolve<R>(
104+
async fn resolve<R>(
105105
cluster_config: &DruidClusterConfig,
106106
resolve_auth_class: impl Fn(
107107
core::v1alpha1::ClientAuthenticationDetails<

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use stackable_operator::{
1111
};
1212

1313
// metadata storage config properties
14-
pub const METADATA_STORAGE_TYPE: &str = "druid.metadata.storage.type";
15-
pub const METADATA_STORAGE_CONNECTOR_CONNECT_URI: &str =
14+
pub(crate) const METADATA_STORAGE_TYPE: &str = "druid.metadata.storage.type";
15+
pub(crate) const METADATA_STORAGE_CONNECTOR_CONNECT_URI: &str =
1616
"druid.metadata.storage.connector.connectURI";
17-
pub const METADATA_STORAGE_USER: &str = "druid.metadata.storage.connector.user";
18-
pub const METADATA_STORAGE_PASSWORD: &str = "druid.metadata.storage.connector.password";
17+
pub(crate) const METADATA_STORAGE_USER: &str = "druid.metadata.storage.connector.user";
18+
pub(crate) const METADATA_STORAGE_PASSWORD: &str = "druid.metadata.storage.connector.password";
1919

2020
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
2121
#[serde(rename_all = "camelCase")]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub static RESERVED_OS_MEMORY: LazyLock<MemoryQuantity> =
2121

2222
/// Max size for direct access buffers. This is defined in Druid to be 2GB:
2323
/// <https://druid.apache.org/docs/latest/configuration/index.html#processing-1>
24-
pub static MAX_DIRECT_BUFFER_SIZE: LazyLock<MemoryQuantity> =
24+
static MAX_DIRECT_BUFFER_SIZE: LazyLock<MemoryQuantity> =
2525
LazyLock::new(|| MemoryQuantity::from_gibi(2.));
2626

2727
#[derive(Snafu, Debug)]
@@ -55,7 +55,7 @@ pub struct HistoricalDerivedSettings {
5555
}
5656

5757
impl HistoricalDerivedSettings {
58-
pub fn new(total_memory: MemoryQuantity, cpu_millis: CpuQuantity) -> Self {
58+
fn new(total_memory: MemoryQuantity, cpu_millis: CpuQuantity) -> Self {
5959
Self {
6060
total_memory,
6161
cpu_millis,

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub mod tls;
5959

6060
pub const APP_NAME: &str = "druid";
6161
pub const OPERATOR_NAME: &str = "druid.stackable.tech";
62-
pub const FIELD_MANAGER: &str = "druid-operator";
6362

6463
// config directories
6564
pub const DRUID_CONFIG_DIRECTORY: &str = "/stackable/config";
@@ -73,22 +72,21 @@ pub const STACKABLE_TRUST_STORE_PASSWORD: &str = "changeit";
7372
pub const STACKABLE_LOG_DIR: &str = "/stackable/log";
7473

7574
pub const PROP_SEGMENT_CACHE_LOCATIONS: &str = "druid.segmentCache.locations";
76-
pub const PATH_SEGMENT_CACHE: &str = "/stackable/var/druid/segment-cache";
7775

7876
/////////////////////////////
7977
// CONFIG PROPERTIES //
8078
/////////////////////////////
8179
// deep storage
82-
pub const DS_TYPE: &str = "druid.storage.type";
83-
pub const DS_DIRECTORY: &str = "druid.storage.storageDirectory";
84-
pub const DS_BASE_KEY: &str = "druid.storage.baseKey";
80+
const DS_TYPE: &str = "druid.storage.type";
81+
const DS_DIRECTORY: &str = "druid.storage.storageDirectory";
82+
const DS_BASE_KEY: &str = "druid.storage.baseKey";
8583
// OPA
86-
pub const AUTH_AUTHORIZERS: &str = "druid.auth.authorizers";
87-
pub const AUTH_AUTHORIZERS_VALUE: &str = "[\"OpaAuthorizer\"]";
88-
pub const AUTH_AUTHORIZER_OPA_TYPE: &str = "druid.auth.authorizer.OpaAuthorizer.type";
89-
pub const AUTH_AUTHORIZER_OPA_TYPE_VALUE: &str = "opa";
84+
const AUTH_AUTHORIZERS: &str = "druid.auth.authorizers";
85+
const AUTH_AUTHORIZERS_VALUE: &str = "[\"OpaAuthorizer\"]";
86+
const AUTH_AUTHORIZER_OPA_TYPE: &str = "druid.auth.authorizer.OpaAuthorizer.type";
87+
const AUTH_AUTHORIZER_OPA_TYPE_VALUE: &str = "opa";
9088
// metrics
91-
pub const PROMETHEUS_PORT: &str = "druid.emitter.prometheus.port";
89+
const PROMETHEUS_PORT: &str = "druid.emitter.prometheus.port";
9290
pub const METRICS_PORT_NAME: &str = "metrics";
9391
pub const METRICS_PORT: u16 = 9090;
9492

@@ -546,7 +544,7 @@ impl v1alpha1::DruidCluster {
546544
}
547545

548546
/// Merges and validates the given role group, role, and default configurations
549-
pub fn merged_rolegroup_config<T>(
547+
pub(crate) fn merged_rolegroup_config<T>(
550548
rolegroup_config: &T::Fragment,
551549
role_config: &T::Fragment,
552550
default_config: &T::Fragment,
@@ -900,7 +898,7 @@ impl DruidRole {
900898
}
901899

902900
/// Return the default graceful shutdown timeout
903-
pub fn default_graceful_shutdown_timeout(&self) -> Duration {
901+
fn default_graceful_shutdown_timeout(&self) -> Duration {
904902
match &self {
905903
DruidRole::Coordinator => DEFAULT_COORDINATOR_GRACEFUL_SHUTDOWN_TIMEOUT,
906904
DruidRole::Broker => DEFAULT_BROKER_GRACEFUL_SHUTDOWN_TIMEOUT,
@@ -1003,11 +1001,7 @@ pub enum DeepStorageSpec {
10031001
}
10041002

10051003
impl DeepStorageSpec {
1006-
pub fn is_hdfs(&self) -> bool {
1007-
matches!(self, DeepStorageSpec::Hdfs(_))
1008-
}
1009-
1010-
pub fn is_s3(&self) -> bool {
1004+
fn is_s3(&self) -> bool {
10111005
matches!(self, DeepStorageSpec::S3(_))
10121006
}
10131007
}

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

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ use stackable_operator::{
1717
use strum::{EnumDiscriminants, IntoStaticStr};
1818

1919
use crate::crd::{
20-
DruidRole, PATH_SEGMENT_CACHE, PROP_SEGMENT_CACHE_LOCATIONS,
20+
DruidRole, PROP_SEGMENT_CACHE_LOCATIONS,
2121
memory::{HistoricalDerivedSettings, RESERVED_OS_MEMORY},
2222
storage::{self, default_free_percentage_empty_dir_fragment},
2323
};
2424

25+
const PATH_SEGMENT_CACHE: &str = "/stackable/var/druid/segment-cache";
26+
2527
// volume names
2628
const SEGMENT_CACHE_VOLUME_NAME: &str = "segment-cache";
2729

@@ -172,7 +174,7 @@ impl RoleResource {
172174
}
173175
}
174176

175-
pub static MIDDLE_MANAGER_RESOURCES: LazyLock<
177+
pub(crate) static MIDDLE_MANAGER_RESOURCES: LazyLock<
176178
ResourcesFragment<storage::DruidStorage, NoRuntimeLimits>,
177179
> = LazyLock::new(|| ResourcesFragment {
178180
cpu: CpuLimitsFragment {
@@ -186,20 +188,21 @@ pub static MIDDLE_MANAGER_RESOURCES: LazyLock<
186188
storage: storage::DruidStorageFragment {},
187189
});
188190

189-
pub static BROKER_RESOURCES: LazyLock<ResourcesFragment<storage::DruidStorage, NoRuntimeLimits>> =
190-
LazyLock::new(|| ResourcesFragment {
191-
cpu: CpuLimitsFragment {
192-
min: Some(Quantity("300m".to_owned())),
193-
max: Some(Quantity("1200m".to_owned())),
194-
},
195-
memory: MemoryLimitsFragment {
196-
limit: Some(Quantity("1500Mi".to_owned())),
197-
runtime_limits: NoRuntimeLimitsFragment {},
198-
},
199-
storage: storage::DruidStorageFragment {},
200-
});
191+
pub(crate) static BROKER_RESOURCES: LazyLock<
192+
ResourcesFragment<storage::DruidStorage, NoRuntimeLimits>,
193+
> = LazyLock::new(|| ResourcesFragment {
194+
cpu: CpuLimitsFragment {
195+
min: Some(Quantity("300m".to_owned())),
196+
max: Some(Quantity("1200m".to_owned())),
197+
},
198+
memory: MemoryLimitsFragment {
199+
limit: Some(Quantity("1500Mi".to_owned())),
200+
runtime_limits: NoRuntimeLimitsFragment {},
201+
},
202+
storage: storage::DruidStorageFragment {},
203+
});
201204

202-
pub static HISTORICAL_RESOURCES: LazyLock<
205+
pub(crate) static HISTORICAL_RESOURCES: LazyLock<
203206
ResourcesFragment<storage::HistoricalStorage, NoRuntimeLimits>,
204207
> = LazyLock::new(|| ResourcesFragment {
205208
cpu: CpuLimitsFragment {
@@ -215,7 +218,7 @@ pub static HISTORICAL_RESOURCES: LazyLock<
215218
},
216219
});
217220

218-
pub static COORDINATOR_RESOURCES: LazyLock<
221+
pub(crate) static COORDINATOR_RESOURCES: LazyLock<
219222
ResourcesFragment<storage::DruidStorage, NoRuntimeLimits>,
220223
> = LazyLock::new(|| ResourcesFragment {
221224
cpu: CpuLimitsFragment {
@@ -229,18 +232,19 @@ pub static COORDINATOR_RESOURCES: LazyLock<
229232
storage: storage::DruidStorageFragment {},
230233
});
231234

232-
pub static ROUTER_RESOURCES: LazyLock<ResourcesFragment<storage::DruidStorage, NoRuntimeLimits>> =
233-
LazyLock::new(|| ResourcesFragment {
234-
cpu: CpuLimitsFragment {
235-
min: Some(Quantity("300m".to_owned())),
236-
max: Some(Quantity("1200m".to_owned())),
237-
},
238-
memory: MemoryLimitsFragment {
239-
limit: Some(Quantity("512Mi".to_owned())),
240-
runtime_limits: NoRuntimeLimitsFragment {},
241-
},
242-
storage: storage::DruidStorageFragment {},
243-
});
235+
pub(crate) static ROUTER_RESOURCES: LazyLock<
236+
ResourcesFragment<storage::DruidStorage, NoRuntimeLimits>,
237+
> = LazyLock::new(|| ResourcesFragment {
238+
cpu: CpuLimitsFragment {
239+
min: Some(Quantity("300m".to_owned())),
240+
max: Some(Quantity("1200m".to_owned())),
241+
},
242+
memory: MemoryLimitsFragment {
243+
limit: Some(Quantity("512Mi".to_owned())),
244+
runtime_limits: NoRuntimeLimitsFragment {},
245+
},
246+
storage: storage::DruidStorageFragment {},
247+
});
244248

245249
#[cfg(test)]
246250
mod test {

0 commit comments

Comments
 (0)