Skip to content

Commit aa5d466

Browse files
zepellinjavitonino
andauthored
Nidx: Support for S3 endpoint TLS validation option (#3644)
* Nidx: Support for S3 endpoint TLS validation option * Update helm values/docs * Fix bool option * Fix bool option * simpler --------- Co-authored-by: Javier Torres <nino@progress.com>
1 parent 258b45f commit aa5d466

3 files changed

Lines changed: 114 additions & 4 deletions

File tree

charts/nidx/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ nidx chart
2323
| imagePullPolicy | string | `"IfNotPresent"` | Image pull policy |
2424
| containerRegistry | string | `"CONTAINER_REGISTRY_TO_REPLACE"` | Container registry (e.g. docker.io/nuclia) |
2525
| image | string | `"IMAGE_TO_REPLACE"` | Image name (without registry eg. nidx:latest) |
26-
| env | object | `{}` | |
27-
| envFrom | object | `{}` | |
26+
| env | object | `{}` | Global environment variables to add to all containers |
27+
| envFrom | object | `{}` | Global environment variables mount to add to all containers |
2828
| podAnnotations | object | `{}` | Global pod annotations to add to all pods |
2929
| podLabels | object | `{"nidxMetrics":"enabled"}` | Global pod labels to add to all pods |
3030
| maintenance | bool | `false` | Enable maintenance mode, which disables writes while keeping searchers active |

charts/nidx/values.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,58 @@ containerRegistry: CONTAINER_REGISTRY_TO_REPLACE
1313
# -- Image name (without registry eg. nidx:latest)
1414
image: IMAGE_TO_REPLACE
1515

16+
# -- Global environment variables to add to all containers
1617
env: {}
18+
# -- Object store backend type for indexer.
19+
# INDEXER__OBJECT_STORE: s3
20+
# -- S3 bucket name used by indexer.
21+
# INDEXER__BUCKET: ndb-index-env-name
22+
# -- S3 region used by indexer.
23+
# INDEXER__REGION_NAME: env-name
24+
# -- Custom S3 endpoint URL for indexer.
25+
# INDEXER__ENDPOINT: https://<url>:9021
26+
# -- Enable or disable TLS certificate verification for indexer S3 connections.
27+
# INDEXER__ALLOW_INVALID_CERTIFICATES: "true"
28+
# -- S3 access key for indexer (if not using IAM or default credentials).
29+
# INDEXER__CLIENT_ID: "your-access-key"
30+
# -- S3 secret key for indexer (if not using IAM or default credentials).
31+
# INDEXER__CLIENT_SECRET: "your-secret-key"
32+
# -- GCP service account credentials for indexer (base64-encoded JSON).
33+
# INDEXER__BASE64_CREDS: "base64-encoded-json"
34+
# -- Azure Blob container URL for indexer.
35+
# INDEXER__CONTAINER_URL: "https://account.blob.core.windows.net/container"
36+
# -- Maximum number of concurrent indexer object store requests.
37+
# INDEXER__MAX_REQUESTS: "10"
38+
# -- Request timeout in seconds for indexer object store operations.
39+
# INDEXER__TIMEOUT: "120"
40+
# -- Azure storage account key for indexer.
41+
# INDEXER__ACCOUNT_KEY: "your-azure-account-key"
42+
# -- Object store backend type for storage.
43+
# STORAGE__OBJECT_STORE: s3
44+
# -- S3 bucket name used by storage.
45+
# STORAGE__BUCKET: ndb-nidx-env-name
46+
# -- S3 region used by storage.
47+
# STORAGE__REGION_NAME: env-name
48+
# -- Maximum number of concurrent storage object store requests.
49+
# STORAGE__MAX_REQUESTS: "10"
50+
# -- Request timeout in seconds for storage object store operations.
51+
# STORAGE__TIMEOUT: "120"
52+
# -- Custom S3 endpoint URL for storage.
53+
# STORAGE__ENDPOINT: https://<url>:9021
54+
# -- Enable or disable TLS certificate verification for storage S3 connections.
55+
# STORAGE__ALLOW_INVALID_CERTIFICATES: "true"
56+
# -- S3 access key for storage (if not using IAM or default credentials).
57+
# STORAGE__CLIENT_ID: "your-access-key"
58+
# -- S3 secret key for storage (if not using IAM or default credentials).
59+
# STORAGE__CLIENT_SECRET: "your-secret-key"
60+
# -- GCP service account credentials for storage (base64-encoded JSON).
61+
# STORAGE__BASE64_CREDS: "base64-encoded-json"
62+
# -- Azure Blob container URL for storage.
63+
# STORAGE__CONTAINER_URL: "https://account.blob.core.windows.net/container"
64+
# -- Azure storage account key for storage.
65+
# STORAGE__ACCOUNT_KEY: "your-azure-account-key"
66+
67+
# -- Global environment variables mount to add to all containers
1768
envFrom: {}
1869

1970
# -- Global pod annotations to add to all pods

nidx/src/settings.rs

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ pub enum ObjectStoreKind {
5656
client_secret: Option<String>,
5757
region_name: String,
5858
endpoint: Option<String>,
59+
#[serde(default, deserialize_with = "deserialize_bool")]
60+
allow_invalid_certificates: Option<bool>,
5961
},
6062
Azure {
6163
container_url: String,
@@ -70,6 +72,12 @@ fn deserialize_u64<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Option<
7072
))
7173
}
7274

75+
fn deserialize_bool<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Option<bool>, D::Error> {
76+
Ok(Some(
77+
String::deserialize(deserializer)?.parse().expect("Expected a bool"),
78+
))
79+
}
80+
7381
#[derive(Clone, Deserialize, Debug)]
7482
pub struct ObjectStoreConfig {
7583
#[serde(flatten)]
@@ -115,6 +123,7 @@ impl ObjectStoreConfig {
115123
client_secret,
116124
region_name,
117125
endpoint,
126+
allow_invalid_certificates,
118127
} => {
119128
let mut builder = AmazonS3Builder::from_env()
120129
.with_region(region_name.clone())
@@ -130,8 +139,15 @@ impl ObjectStoreConfig {
130139
// This is needed for minio compatibility
131140
builder = builder.with_endpoint(endpoint.clone().unwrap()).with_allow_http(true);
132141
}
133-
if let Some(t) = self.timeout {
134-
builder = builder.with_client_options(ClientOptions::new().with_timeout(Duration::from_secs(t)));
142+
if self.timeout.is_some() || allow_invalid_certificates.is_some() {
143+
let mut options = ClientOptions::new();
144+
if let Some(t) = self.timeout {
145+
options = options.with_timeout(Duration::from_secs(t));
146+
}
147+
if let Some(allow_invalid_certificates) = allow_invalid_certificates {
148+
options = options.with_allow_invalid_certificates(*allow_invalid_certificates);
149+
}
150+
builder = builder.with_client_options(options);
135151
}
136152
Box::new(builder.build().unwrap())
137153
}
@@ -422,6 +438,8 @@ impl Settings {
422438
mod tests {
423439
use std::collections::HashMap;
424440

441+
use serde_json::json;
442+
425443
use super::*;
426444

427445
#[test]
@@ -442,4 +460,45 @@ mod tests {
442460
LogMergeSettings::default().min_number_of_segments
443461
);
444462
}
463+
464+
#[test]
465+
fn test_s3_allow_invalid_certificates_default_is_none() {
466+
let raw = json!({
467+
"object_store": "s3",
468+
"bucket": "bucket",
469+
"region_name": "us-east-1"
470+
});
471+
let config: ObjectStoreConfig = serde_json::from_value(raw).unwrap();
472+
473+
match config.kind {
474+
ObjectStoreKind::S3 {
475+
allow_invalid_certificates,
476+
..
477+
} => {
478+
assert_eq!(allow_invalid_certificates, None);
479+
}
480+
_ => panic!("Expected s3 object store kind"),
481+
}
482+
}
483+
484+
#[test]
485+
fn test_s3_allow_invalid_certificates_enabled() {
486+
let raw = json!({
487+
"object_store": "s3",
488+
"bucket": "bucket",
489+
"region_name": "us-east-1",
490+
"allow_invalid_certificates": "true"
491+
});
492+
let config: ObjectStoreConfig = serde_json::from_value(raw).unwrap();
493+
494+
match config.kind {
495+
ObjectStoreKind::S3 {
496+
allow_invalid_certificates,
497+
..
498+
} => {
499+
assert_eq!(allow_invalid_certificates, Some(true));
500+
}
501+
_ => panic!("Expected s3 object store kind"),
502+
}
503+
}
445504
}

0 commit comments

Comments
 (0)