Skip to content

Commit 732b082

Browse files
Do not use overrides to determine if TLS is enabled
1 parent f78b37f commit 732b082

4 files changed

Lines changed: 17 additions & 32 deletions

File tree

rust/operator-binary/src/controller.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,14 @@ impl ValidatedCluster {
281281
.filter(|c| c.1.config.node_roles.contains(node_role))
282282
.collect()
283283
}
284+
285+
/// Whether security is enabled and a server TLS class is defined or not.
286+
pub fn is_server_tls_enabled(&self) -> bool {
287+
self.security
288+
.as_ref()
289+
.and_then(|security| security.tls.server_secret_class.as_ref())
290+
.is_some()
291+
}
284292
}
285293

286294
impl HasName for ValidatedCluster {

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

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
//! Configuration of an OpenSearch node
22
3-
use std::str::FromStr;
4-
53
use serde_json::{Value, json};
64
use stackable_operator::{
75
builder::pod::container::FieldPathEnvVar, commons::networking::DomainName,
86
};
7+
use tracing::warn;
98

109
use super::ValidatedCluster;
1110
use crate::{
@@ -184,7 +183,12 @@ impl NodeConfig {
184183
.into_iter()
185184
.flatten()
186185
{
187-
config.insert(setting.to_owned(), json!(value));
186+
let old_value = config.insert(setting.to_owned(), json!(value));
187+
if let Some(old_value) = old_value {
188+
warn!(
189+
"configOverrides: Configuration setting {setting:?} changed from {old_value} to {value:?}."
190+
);
191+
}
188192
}
189193

190194
// Ensure a deterministic result
@@ -310,26 +314,6 @@ impl NodeConfig {
310314
config
311315
}
312316

313-
// TODO Obsolete or should configOverrides be the truth?
314-
/// Returns `true` if TLS is enabled on the HTTP port
315-
pub fn tls_on_http_port_enabled(&self) -> bool {
316-
self.opensearch_config()
317-
.get(CONFIG_OPTION_PLUGINS_SECURITY_SSL_HTTP_ENABLED)
318-
.and_then(Self::value_as_bool)
319-
== Some(true)
320-
}
321-
322-
/// Converts the given JSON value to [`bool`] if possible
323-
pub fn value_as_bool(value: &Value) -> Option<bool> {
324-
value.as_bool().or(
325-
// OpenSearch parses the strings "true" and "false" as boolean, see
326-
// https://github.com/opensearch-project/OpenSearch/blob/3.4.0/libs/common/src/main/java/org/opensearch/common/Booleans.java#L45-L84
327-
value
328-
.as_str()
329-
.and_then(|value| FromStr::from_str(value).ok()),
330-
)
331-
}
332-
333317
/// Creates environment variables for the OpenSearch configurations
334318
///
335319
/// The environment variables should only contain node-specific configuration options.

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,7 @@ impl<'a> RoleBuilder<'a> {
171171

172172
let metadata = self.common_metadata(discovery_config_map_name(&self.cluster.name));
173173

174-
let tls_server_secret_class_defined = self
175-
.cluster
176-
.security
177-
.as_ref()
178-
.and_then(|security| security.tls.server_secret_class.as_ref())
179-
.is_some();
180-
181-
let protocol = if tls_server_secret_class_defined {
174+
let protocol = if self.cluster.is_server_tls_enabled() {
182175
"https"
183176
} else {
184177
"http"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ cp --archive config/opensearch.keystore {OPENSEARCH_INITIALIZED_KEYSTORE_DIRECTO
948948
.common_metadata(self.resource_names.headless_service_name())
949949
.with_labels(Self::prometheus_labels())
950950
.with_annotations(Self::prometheus_annotations(
951-
self.node_config.tls_on_http_port_enabled(),
951+
self.cluster.is_server_tls_enabled(),
952952
))
953953
.build();
954954

0 commit comments

Comments
 (0)