Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,052 changes: 537 additions & 515 deletions Cargo.lock

Large diffs are not rendered by default.

2,811 changes: 1,589 additions & 1,222 deletions Cargo.nix

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ edition = "2024"
repository = "https://github.com/stackabletech/opensearch-operator"

[workspace.dependencies]
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", features = ["telemetry", "versioned"], tag = "stackable-operator-0.93.2" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", features = ["telemetry", "versioned"], tag = "stackable-operator-0.98.0" }

built = { version = "0.8.0", features = ["chrono", "git2"] }
clap = "4.5"
futures = { version = "0.3", features = ["compat"] }
rstest = "0.26"
schemars = { version = "0.8.21" } # same as in operator-rs
schemars = { version = "1.0.0", features = ["url2"] } # same as in operator-rs
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
snafu = "0.8"
strum = { version = "0.27", features = ["derive"] }
tokio = { version = "1.45", features = ["full"] }
tokio = { version = "1.47", features = ["full"] }
tracing = "0.1"
uuid = "1.18"

Expand Down
14 changes: 7 additions & 7 deletions crate-hashes.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

192 changes: 153 additions & 39 deletions deploy/helm/opensearch-operator/crds/crds.yaml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions deploy/helm/opensearch-operator/templates/roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ rules:
verbs:
- list
- watch
# For automatic cluster domain detection
- apiGroups:
- ""
resources:
- nodes/proxy
verbs:
- get
- apiGroups:
- ""
resources:
Expand Down
27 changes: 19 additions & 8 deletions rust/operator-binary/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use build::build;
use snafu::{ResultExt, Snafu};
use stackable_operator::{
cluster_resources::ClusterResourceApplyStrategy,
commons::{affinity::StackableAffinity, product_image_selection::ProductImage},
commons::{affinity::StackableAffinity, product_image_selection::ResolvedProductImage},
crd::listener::v1alpha1::Listener,
k8s_openapi::api::{
apps::v1::StatefulSet,
Expand All @@ -21,7 +21,7 @@ use stackable_operator::{
kube::{Resource, api::ObjectMeta, core::DeserializeGuard, runtime::controller::Action},
logging::controller::ReconcilerError,
role_utils::GenericRoleConfig,
time::Duration,
shared::time::Duration,
};
use strum::{EnumDiscriminants, IntoStaticStr};
use update_status::update_status;
Expand Down Expand Up @@ -144,7 +144,7 @@ pub struct ValidatedOpenSearchConfig {
#[derive(Clone, Debug, PartialEq)]
pub struct ValidatedCluster {
metadata: ObjectMeta,
pub image: ProductImage,
pub image: ResolvedProductImage,
pub product_version: ProductVersion,
pub name: ClusterName,
pub namespace: NamespaceName,
Expand All @@ -155,7 +155,7 @@ pub struct ValidatedCluster {

impl ValidatedCluster {
pub fn new(
image: ProductImage,
image: ResolvedProductImage,
product_version: ProductVersion,
name: ClusterName,
namespace: NamespaceName,
Expand Down Expand Up @@ -346,10 +346,15 @@ struct KubernetesResources<T> {

#[cfg(test)]
mod tests {
use std::collections::{BTreeMap, HashMap};
use std::{
collections::{BTreeMap, HashMap},
str::FromStr,
};

use stackable_operator::{
commons::affinity::StackableAffinity, k8s_openapi::api::core::v1::PodTemplateSpec,
commons::{affinity::StackableAffinity, product_image_selection::ResolvedProductImage},
k8s_openapi::api::core::v1::PodTemplateSpec,
kvp::LabelValue,
role_utils::GenericRoleConfig,
};
use uuid::uuid;
Expand Down Expand Up @@ -425,8 +430,14 @@ mod tests {

fn validated_cluster() -> ValidatedCluster {
ValidatedCluster::new(
serde_json::from_str(r#"{"productVersion": "3.1.0"}"#)
.expect("should be a valid ProductImage structure"),
ResolvedProductImage {
product_version: "3.1.0".to_owned(),
app_version_label_value: LabelValue::from_str("3.1.0-stackable0.0.0-dev")
.expect("should be a valid label value"),
image: "oci.stackable.tech/sdp/opensearch:3.1.0-stackable0.0.0-dev".to_string(),
image_pull_policy: "Always".to_owned(),
pull_secrets: None,
},
ProductVersion::from_str_unsafe("3.1.0"),
ClusterName::from_str_unsafe("my-opensearch"),
NamespaceName::from_str_unsafe("default"),
Expand Down
22 changes: 17 additions & 5 deletions rust/operator-binary/src/controller/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,17 @@ pub fn build(names: &ContextNames, cluster: ValidatedCluster) -> KubernetesResou

#[cfg(test)]
mod tests {
use std::collections::{BTreeMap, HashMap};
use std::{
collections::{BTreeMap, HashMap},
str::FromStr,
};

use stackable_operator::{
commons::affinity::StackableAffinity, k8s_openapi::api::core::v1::PodTemplateSpec,
kube::Resource, role_utils::GenericRoleConfig,
commons::{affinity::StackableAffinity, product_image_selection::ResolvedProductImage},
k8s_openapi::api::core::v1::PodTemplateSpec,
kube::Resource,
kvp::LabelValue,
role_utils::GenericRoleConfig,
};
use uuid::uuid;

Expand Down Expand Up @@ -148,8 +154,14 @@ mod tests {

fn validated_cluster() -> ValidatedCluster {
ValidatedCluster::new(
serde_json::from_str(r#"{"productVersion": "3.1.0"}"#)
.expect("should be a valid ProductImage structure"),
ResolvedProductImage {
product_version: "3.1.0".to_owned(),
app_version_label_value: LabelValue::from_str("3.1.0-stackable0.0.0-dev")
.expect("should be a valid label value"),
image: "oci.stackable.tech/sdp/opensearch:3.1.0-stackable0.0.0-dev".to_string(),
image_pull_policy: "Always".to_owned(),
pull_secrets: None,
},
ProductVersion::from_str_unsafe("3.1.0"),
ClusterName::from_str_unsafe("my-opensearch"),
NamespaceName::from_str_unsafe("default"),
Expand Down
13 changes: 11 additions & 2 deletions rust/operator-binary/src/controller/build/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,12 @@ mod tests {

use stackable_operator::{
commons::{
affinity::StackableAffinity, product_image_selection::ProductImage,
affinity::StackableAffinity,
product_image_selection::{ProductImage, ResolvedProductImage},
resources::Resources,
},
k8s_openapi::api::core::v1::PodTemplateSpec,
kvp::LabelValue,
role_utils::GenericRoleConfig,
};
use uuid::uuid;
Expand Down Expand Up @@ -328,7 +330,14 @@ mod tests {
};

let cluster = ValidatedCluster::new(
image.clone(),
ResolvedProductImage {
product_version: "3.1.0".to_owned(),
app_version_label_value: LabelValue::from_str("3.1.0-stackable0.0.0-dev")
.expect("should be a valid label value"),
image: "oci.stackable.tech/sdp/opensearch:3.1.0-stackable0.0.0-dev".to_string(),
image_pull_policy: "Always".to_owned(),
pull_secrets: None,
},
ProductVersion::from_str_unsafe(image.product_version()),
ClusterName::from_str_unsafe("my-opensearch-cluster"),
NamespaceName::from_str_unsafe("default"),
Expand Down
18 changes: 15 additions & 3 deletions rust/operator-binary/src/controller/build/role_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,20 @@ impl<'a> RoleBuilder<'a> {

#[cfg(test)]
mod tests {
use std::collections::{BTreeMap, HashMap};
use std::{
collections::{BTreeMap, HashMap},
str::FromStr,
};

use serde_json::json;
use stackable_operator::{
commons::{
affinity::StackableAffinity, product_image_selection::ProductImage,
affinity::StackableAffinity,
product_image_selection::{ProductImage, ResolvedProductImage},
resources::Resources,
},
k8s_openapi::api::core::v1::PodTemplateSpec,
kvp::LabelValue,
role_utils::GenericRoleConfig,
};
use uuid::uuid;
Expand Down Expand Up @@ -273,7 +278,14 @@ mod tests {
};

let cluster = ValidatedCluster::new(
image.clone(),
ResolvedProductImage {
product_version: "3.1.0".to_owned(),
app_version_label_value: LabelValue::from_str("3.1.0-stackable0.0.0-dev")
.expect("should be a valid label value"),
image: "oci.stackable.tech/sdp/opensearch:3.1.0-stackable0.0.0-dev".to_string(),
image_pull_policy: "Always".to_owned(),
pull_secrets: None,
},
ProductVersion::from_str_unsafe(image.product_version()),
ClusterName::from_str_unsafe("my-opensearch-cluster"),
NamespaceName::from_str_unsafe("default"),
Expand Down
27 changes: 16 additions & 11 deletions rust/operator-binary/src/controller/build/role_group_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,6 @@ impl<'a> RoleGroupBuilder<'a> {

/// Builds the container for the [`PodTemplateSpec`]
fn build_container(&self, role_group_config: &OpenSearchRoleGroupConfig) -> Container {
let product_image = self
.cluster
.image
.resolve("opensearch", crate::built_info::PKG_VERSION);

// Probe values taken from the official Helm chart
let startup_probe = Probe {
failure_threshold: Some(30),
Expand Down Expand Up @@ -322,7 +317,7 @@ impl<'a> RoleGroupBuilder<'a> {

ContainerBuilder::new("opensearch")
.expect("should be a valid container name")
.image_from_product_image(&product_image)
.image_from_product_image(&self.cluster.image)
.command(vec![format!(
"{opensearch_home}/opensearch-docker-entrypoint.sh"
)])
Expand Down Expand Up @@ -511,15 +506,19 @@ impl<'a> RoleGroupBuilder<'a> {

#[cfg(test)]
mod tests {
use std::collections::{BTreeMap, HashMap};
use std::{
collections::{BTreeMap, HashMap},
str::FromStr,
};

use serde_json::json;
use stackable_operator::{
commons::{
affinity::StackableAffinity, product_image_selection::ProductImage,
affinity::StackableAffinity, product_image_selection::ResolvedProductImage,
resources::Resources,
},
k8s_openapi::api::core::v1::PodTemplateSpec,
kvp::LabelValue,
role_utils::GenericRoleConfig,
};
use strum::IntoEnumIterator;
Expand Down Expand Up @@ -555,8 +554,14 @@ mod tests {
}

fn validated_cluster() -> ValidatedCluster {
let image: ProductImage = serde_json::from_str(r#"{"productVersion": "3.1.0"}"#)
.expect("should be a valid ProductImage");
let image = ResolvedProductImage {
product_version: "3.1.0".to_owned(),
app_version_label_value: LabelValue::from_str("3.1.0-stackable0.0.0-dev")
.expect("should be a valid label value"),
image: "oci.stackable.tech/sdp/opensearch:3.1.0-stackable0.0.0-dev".to_string(),
image_pull_policy: "Always".to_owned(),
pull_secrets: None,
};

let role_group_config = OpenSearchRoleGroupConfig {
replicas: 1,
Expand All @@ -581,7 +586,7 @@ mod tests {

ValidatedCluster::new(
image.clone(),
ProductVersion::from_str_unsafe(image.product_version()),
ProductVersion::from_str_unsafe(&image.product_version),
ClusterName::from_str_unsafe("my-opensearch-cluster"),
NamespaceName::from_str_unsafe("default"),
uuid!("0b1e30e6-326e-4c1a-868d-ad6598b49e8b"),
Expand Down
Loading
Loading