diff --git a/crates/stackable-operator/src/commons/affinity.rs b/crates/stackable-operator/src/commons/affinity.rs index 32fde9024..be05da763 100644 --- a/crates/stackable-operator/src/commons/affinity.rs +++ b/crates/stackable-operator/src/commons/affinity.rs @@ -6,7 +6,7 @@ use k8s_openapi::{ }, apimachinery::pkg::apis::meta::v1::LabelSelector, }; -use schemars::{schema::Schema, JsonSchema}; +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use stackable_operator_derive::Fragment; @@ -39,8 +39,6 @@ pub struct StackableAffinity { pub pod_affinity: Option, pub pod_anti_affinity: Option, pub node_affinity: Option, - #[schemars(schema_with = "optional_stackable_node_selector_schema")] - #[fragment_attrs(schemars(schema_with = "optional_stackable_node_selector_schema"))] pub node_selector: Option, } @@ -49,10 +47,13 @@ pub struct StackableAffinity { /// [`BTreeMap`]. /// /// We `#[serde(flatten)]` the contained [`BTreeMap`], so `serde_yaml` can deserialize everything as -/// expected. However the generated JsonSchema will be wrong, so we need to provide our custom one (see -/// for details). -#[derive(Clone, Debug, Eq, Deserialize, PartialEq, Serialize)] +/// expected. +// FIXME: However, the generated JsonSchema will be wrong, so we need to use `#[schemars(deny_unknown_fields)]`. +// See https://github.com/stackabletech/operator-rs/pull/752#issuecomment-2017630433 and +// https://github.com/GREsau/schemars/issues/259 for details. +#[derive(Clone, Debug, Eq, Deserialize, JsonSchema, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] +#[schemars(deny_unknown_fields)] pub struct StackableNodeSelector { #[serde(flatten)] pub node_selector: BTreeMap, @@ -60,11 +61,6 @@ pub struct StackableNodeSelector { impl Atomic for StackableNodeSelector {} -/// We need a custom JsonSchema for [`StackableNodeSelector`], please have a look at the documentation there. -pub fn optional_stackable_node_selector_schema(gen: &mut schemars::gen::SchemaGenerator) -> Schema { - Option::>::json_schema(gen) -} - /// Creates a `WeightedPodAffinityTerm`, which expresses a affinity towards all Pods of the given product (`app_name`) instance (`cluster_name`) role (`role`). /// This affinity can be used to attract towards (affinity) or away (anti-affinity) from the specified role. /// One common example would be to use this to distribute all the Pods of a certain role, e.g. hdfs datanodes.