Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

- Rollout tracker for `StatefulSet` ([#833]).

### Fixed

- Invalid CRD schema for `StackableAffinity` contents. This was caused by the fields being optional and defaulting to `null`, while the custom schema marked the field as required ([836]).

[#833]: https://github.com/stackabletech/operator-rs/pull/833
[#836]: https://github.com/stackabletech/operator-rs/pull/836

Check failure on line 16 in crates/stackable-operator/CHANGELOG.md

View workflow job for this annotation

GitHub Actions / markdownlint

[markdownlint] crates/stackable-operator/CHANGELOG.md#L16

MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "#836"] [Context: "[#836]: https://github.com/sta..."]
Raw output
crates/stackable-operator/CHANGELOG.md:16:1 MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "#836"] [Context: "[#836]: https://github.com/sta..."]

## [0.72.0] - 2024-08-05

Expand Down
8 changes: 4 additions & 4 deletions crates/stackable-operator/src/commons/affinity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use stackable_operator_derive::Fragment;
use crate::{
config::merge::{Atomic, Merge},
kvp::consts::{K8S_APP_COMPONENT_KEY, K8S_APP_INSTANCE_KEY, K8S_APP_NAME_KEY},
utils::crds::raw_object_schema,
utils::crds::raw_optional_object_schema,
};

pub const TOPOLOGY_KEY_HOSTNAME: &str = "kubernetes.io/hostname";
Expand All @@ -38,15 +38,15 @@ pub const TOPOLOGY_KEY_HOSTNAME: &str = "kubernetes.io/hostname";
)]
pub struct StackableAffinity {
/// Same as the `spec.affinity.podAffinity` field on the Pod, see the [Kubernetes docs](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node)
#[fragment_attrs(schemars(schema_with = "raw_object_schema"))]
#[fragment_attrs(schemars(schema_with = "raw_optional_object_schema"))]
pub pod_affinity: Option<PodAffinity>,

/// Same as the `spec.affinity.podAntiAffinity` field on the Pod, see the [Kubernetes docs](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node)
#[fragment_attrs(schemars(schema_with = "raw_object_schema"))]
#[fragment_attrs(schemars(schema_with = "raw_optional_object_schema"))]
pub pod_anti_affinity: Option<PodAntiAffinity>,

/// Same as the `spec.affinity.nodeAffinity` field on the Pod, see the [Kubernetes docs](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node)
#[fragment_attrs(schemars(schema_with = "raw_object_schema"))]
#[fragment_attrs(schemars(schema_with = "raw_optional_object_schema"))]
pub node_affinity: Option<NodeAffinity>,

// This schema isn't big, so it can stay
Expand Down
9 changes: 9 additions & 0 deletions crates/stackable-operator/src/utils/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ pub fn raw_object_schema(_: &mut schemars::gen::SchemaGenerator) -> Schema {
.expect("Failed to parse JSON of custom raw object schema")
}

pub fn raw_optional_object_schema(_: &mut schemars::gen::SchemaGenerator) -> Schema {
serde_json::from_value(serde_json::json!({
"type": "object",
"nullable": true,
"x-kubernetes-preserve-unknown-fields": true,
}))
.expect("Failed to parse JSON of custom optional raw object schema")
}

pub fn raw_object_list_schema(_: &mut schemars::gen::SchemaGenerator) -> Schema {
serde_json::from_value(serde_json::json!({
"type": "array",
Expand Down
Loading