Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
469 changes: 237 additions & 232 deletions Cargo.lock

Large diffs are not rendered by default.

882 changes: 436 additions & 446 deletions Cargo.nix

Large diffs are not rendered by default.

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

[workspace.dependencies]
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.111.1", features = ["webhook"] }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.112.0", features = ["webhook"] }

built = { version = "0.8.0", features = ["chrono", "git2"] }
clap = "4.5"
built = { version = "0.8", features = ["chrono", "git2"] }
clap = "4.6"
futures = { version = "0.3", features = ["compat"] }
json-patch = { version = "4.2", features = ["schemars"] }
pretty_assertions = "1.4"
regex = "1.11"
regex = "1.12"
rstest = "0.26"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9"
snafu = { version = "0.9", features = ["futures"] }
strum = { version = "0.28", features = ["derive"] }
tokio = { version = "1.47", features = ["full"] }
tokio = { version = "1.52", features = ["full"] }
tracing = "0.1"
uuid = "1.18"
uuid = "1.23"

[patch."https://github.com/stackabletech/operator-rs"]
# stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
18 changes: 9 additions & 9 deletions crate-hashes.json

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

82 changes: 49 additions & 33 deletions extra/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ spec:
managingRoleGroup:
default: security-config
description: The role group that updates the security index if any setting is managed by the operator.
maxLength: 16
maxLength: 63
minLength: 1
type: string
settings:
Expand Down Expand Up @@ -1885,31 +1885,39 @@ spec:

Example for key-value pairs:

stringProperty: new value
booleanProperty: "true"
```yaml
stringProperty: new value
booleanProperty: "true"
```

Example for a JSON merge patch:

jsonMergePatch:
stringProperty: new value
booleanProperty: true
nestedProperty:
key: value
```yaml
jsonMergePatch:
stringProperty: new value
booleanProperty: true
nestedProperty:
key: value
```

Example for a JSON patch:

jsonPatch:
- op: replace
path: /stringProperty
value: new value
```yaml
jsonPatch:
- op: replace
path: /stringProperty
value: new value
```

Example for a JSON object:

userProvided:
stringProperty: new value
booleanProperty: true
nestedProperty:
key: value
```yaml
userProvided:
stringProperty: new value
booleanProperty: true
nestedProperty:
key: value
```
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
Expand Down Expand Up @@ -2608,31 +2616,39 @@ spec:

Example for key-value pairs:

stringProperty: new value
booleanProperty: "true"
```yaml
stringProperty: new value
booleanProperty: "true"
```

Example for a JSON merge patch:

jsonMergePatch:
stringProperty: new value
booleanProperty: true
nestedProperty:
key: value
```yaml
jsonMergePatch:
stringProperty: new value
booleanProperty: true
nestedProperty:
key: value
```

Example for a JSON patch:

jsonPatch:
- op: replace
path: /stringProperty
value: new value
```yaml
jsonPatch:
- op: replace
path: /stringProperty
value: new value
```

Example for a JSON object:

userProvided:
stringProperty: new value
booleanProperty: true
nestedProperty:
key: value
```yaml
userProvided:
stringProperty: new value
booleanProperty: true
nestedProperty:
key: value
```
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
Expand Down
10 changes: 8 additions & 2 deletions rust/operator-binary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ repository.workspace = true
publish = false
build = "build.rs"

[features]
# The macro attributed_string_type is used in this operator. It produces test
# code if the feature "test-support" is set. This feature is defined here to
# suppress a Clippy warning.
test-support = []

[dependencies]
stackable-operator.workspace = true

clap.workspace = true
futures.workspace = true
json-patch.workspace = true
regex.workspace = true
serde.workspace = true
serde_json.workspace = true
Expand All @@ -23,11 +28,12 @@ snafu.workspace = true
strum.workspace = true
tokio.workspace = true
tracing.workspace = true
uuid.workspace = true

[build-dependencies]
built.workspace = true

[dev-dependencies]
pretty_assertions.workspace = true
rstest.workspace = true
stackable-operator = { workspace = true, features = ["test-support"] }
uuid.workspace = true
49 changes: 25 additions & 24 deletions rust/operator-binary/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ use stackable_operator::{
kube::{Resource, api::ObjectMeta, core::DeserializeGuard, runtime::controller::Action},
logging::controller::ReconcilerError,
shared::time::Duration,
};
use strum::{Display, EnumDiscriminants, EnumIter, IntoStaticStr};
use update_status::update_status;
use validate::validate;

use crate::{
controller::preprocess::preprocess,
crd::v1alpha1,
framework::{
v2::{
HasName, HasUid, NameIsValidLabelValue,
config_overrides::JsonConfigOverrides,
product_logging::framework::{ValidatedContainerLogConfigChoice, VectorContainerLogConfig},
Expand All @@ -54,6 +46,11 @@ use crate::{
},
},
};
use strum::{Display, EnumDiscriminants, EnumIter, IntoStaticStr};
use update_status::update_status;
use validate::validate;

use crate::{controller::preprocess::preprocess, crd::v1alpha1};

mod apply;
mod build;
Expand Down Expand Up @@ -160,6 +157,13 @@ type OpenSearchRoleGroupConfig = RoleGroupConfig<
ValidatedOpenSearchConfigOverrides,
>;

/// Returns the replication count for the given role group config
///
/// Returns 1 if not set, as this is the Kubernetes default.
pub fn replicas(role_group_config: &OpenSearchRoleGroupConfig) -> u16 {
role_group_config.replicas.unwrap_or(1)
}

type OpenSearchNodeResources =
stackable_operator::commons::resources::Resources<v1alpha1::StorageConfig>;

Expand Down Expand Up @@ -313,11 +317,8 @@ impl ValidatedCluster {
}

/// Returns the sum of the replicas in all role-groups
pub fn node_count(&self) -> u32 {
self.role_group_configs
.values()
.map(|rg| rg.replicas as u32)
.sum()
pub fn node_count(&self) -> u16 {
self.role_group_configs.values().map(replicas).sum()
}

/// Returns all role-group configurations which contain the given node role
Expand Down Expand Up @@ -516,6 +517,15 @@ mod tests {
kvp::LabelValue,
product_logging::spec::AutomaticContainerLogConfig,
shared::time::Duration,
v2::{
builder::pod::container::EnvVarSet,
product_logging::framework::ValidatedContainerLogConfigChoice,
role_utils::GenericCommonConfig,
types::{
kubernetes::{ListenerClassName, NamespaceName, SecretClassName},
operator::{ClusterName, OperatorName, ProductVersion, RoleGroupName},
},
},
};
use uuid::uuid;

Expand All @@ -526,15 +536,6 @@ mod tests {
ValidatedOpenSearchConfig, ValidatedOpenSearchConfigOverrides, ValidatedSecurity,
},
crd::v1alpha1,
framework::{
builder::pod::container::EnvVarSet,
product_logging::framework::ValidatedContainerLogConfigChoice,
role_utils::GenericCommonConfig,
types::{
kubernetes::{ListenerClassName, NamespaceName, SecretClassName},
operator::{ClusterName, OperatorName, ProductVersion, RoleGroupName},
},
},
};

#[test]
Expand Down Expand Up @@ -662,7 +663,7 @@ mod tests {
node_roles: impl Into<ValidatedNodeRoles>,
) -> OpenSearchRoleGroupConfig {
OpenSearchRoleGroupConfig {
replicas,
replicas: Some(replicas),
config: ValidatedOpenSearchConfig {
affinity: StackableAffinity::default(),
discovery_service_exposed: true,
Expand Down
14 changes: 7 additions & 7 deletions rust/operator-binary/src/controller/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ use stackable_operator::{
client::Client,
cluster_resources::{ClusterResource, ClusterResourceApplyStrategy, ClusterResources},
deep_merger::ObjectOverrides,
v2::{
cluster_resources::cluster_resources_new,
types::{
kubernetes::{NamespaceName, Uid},
operator::ClusterName,
},
},
};
use strum::{EnumDiscriminants, IntoStaticStr};

use super::{Applied, ContextNames, KubernetesResources, Prepared};
use crate::framework::{
cluster_resources::cluster_resources_new,
types::{
kubernetes::{NamespaceName, Uid},
operator::ClusterName,
},
};

#[derive(Snafu, Debug, EnumDiscriminants)]
#[strum_discriminants(derive(IntoStaticStr))]
Expand Down
26 changes: 13 additions & 13 deletions rust/operator-binary/src/controller/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ mod tests {
kvp::LabelValue,
product_logging::spec::AutomaticContainerLogConfig,
shared::time::Duration,
v2::{
builder::pod::container::EnvVarSet,
role_utils::GenericCommonConfig,
types::{
common::Port,
kubernetes::{Hostname, ListenerClassName, NamespaceName, SecretClassName},
operator::{
ClusterName, ControllerName, OperatorName, ProductName, ProductVersion,
RoleGroupName,
},
},
},
};
use uuid::uuid;

Expand All @@ -86,18 +98,6 @@ mod tests {
ValidatedOpenSearchConfigOverrides, ValidatedSecurity,
},
crd::v1alpha1,
framework::{
builder::pod::container::EnvVarSet,
role_utils::GenericCommonConfig,
types::{
common::Port,
kubernetes::{Hostname, ListenerClassName, NamespaceName, SecretClassName},
operator::{
ClusterName, ControllerName, OperatorName, ProductName, ProductVersion,
RoleGroupName,
},
},
},
};

#[test]
Expand Down Expand Up @@ -229,7 +229,7 @@ mod tests {
node_roles: impl Into<ValidatedNodeRoles>,
) -> OpenSearchRoleGroupConfig {
OpenSearchRoleGroupConfig {
replicas,
replicas: Some(replicas),
config: ValidatedOpenSearchConfig {
affinity: StackableAffinity::default(),
discovery_service_exposed: true,
Expand Down
Loading
Loading