Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Implement custom schema for config.affinity.nodeSelector #752

Merged
merged 14 commits into from
Mar 26, 2024

Conversation

sbernauer
Copy link
Member

@sbernauer sbernauer commented Mar 22, 2024

Description

Fixes stackabletech/issues#554.

IMHO it's not worth an immediate platform bugfix release, as there is a workaround available.

The effect can be seen e.g. in Trino:

diff --git a/deploy/helm/trino-operator/crds/crds.yaml b/deploy/helm/trino-operator/crds/crds.yaml
index e41fdfb..5de8694 100644
--- a/deploy/helm/trino-operator/crds/crds.yaml
+++ b/deploy/helm/trino-operator/crds/crds.yaml
@@ -305,6 +305,8 @@ spec:
                                   type: object
                               type: object
                             nodeSelector:
+                              additionalProperties:
+                                type: string
                               nullable: true
                               type: object
                             podAffinity:
@@ -647,6 +649,8 @@ spec:
                                     type: object
                                   type: array
                               type: object
+                          required:
+                            - nodeSelector
                           type: object

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

Reviewer

Acceptance

@Techassi
Copy link
Member

IMHO it's not worth an immediate bugfix release, as there is a workaround available.

I would be happy to release a new version, because there are now multiple things which are unreleased.

@Techassi
Copy link
Member

I would however do one additional PR regarding the changelog before bumping the version.

@sbernauer
Copy link
Member Author

I already changed the wording the "bugfix platform version", sorry for the confusion. No objections against op-rs release whatsoever

CHANGELOG.md Outdated Show resolved Hide resolved
crates/stackable-operator/src/commons/affinity.rs Outdated Show resolved Hide resolved
Co-authored-by: Techassi <[email protected]>
@sbernauer sbernauer requested a review from Techassi March 22, 2024 10:58
Techassi
Techassi previously approved these changes Mar 22, 2024
@Techassi Techassi changed the title fix: Fixed wrong schema for config.affinity.nodeSelector fix: Implement custom schema for config.affinity.nodeSelector Mar 22, 2024
@nightkr
Copy link
Member

nightkr commented Mar 22, 2024

I tried diffing the output before/after this patch: https://gist.github.com/nightkr/9446c9e3747aa6f58ce616cd86c1f13e

As far as I can tell, the actual issue here is that schemars doesn't propagate additionalProperties when used with #[serde(flatten)]? We should probably file an upstream ticket for that and link to it in the code.

@nightkr
Copy link
Member

nightkr commented Mar 22, 2024

This looks like GREsau/schemars#259.

@nightkr
Copy link
Member

nightkr commented Mar 22, 2024

GREsau/schemars#275 generates the schema https://gist.github.com/nightkr/f7f06df7a14286a9b682ad6be7e3da14, which should also contain the correct additionalProperties.

@nightkr
Copy link
Member

nightkr commented Mar 22, 2024

Another workaround is to add #[schemars(deny_unknown_fields)] to StackableNodeSelector: https://gist.github.com/nightkr/af2236b2d3cf77eb71242124d588a638

@sbernauer
Copy link
Member Author

Many thanks for tracking this down @nightkr! What would you suggest as the next step?

  1. Merge as is
  2. Use #[schemars(deny_unknown_fields)]
  3. Wait for a few days to see if Propagate additional_properties when using #[serde(flatten)] GREsau/schemars#275 get's merged
  4. Something else

@nightkr
Copy link
Member

nightkr commented Mar 25, 2024

@sbernauer I'd say 2 and add a tracking issue for 3. schemars doesn't look too lively these days so we shouldn't block on it.

@sbernauer
Copy link
Member Author

Makes sense to me! Adopted Option 2 and created #756.
A quick review would be great, so that @Techassi can release :)

@sbernauer sbernauer requested a review from nightkr March 25, 2024 11:01
@sbernauer sbernauer disabled auto-merge March 25, 2024 14:20
@sbernauer sbernauer requested a review from nightkr March 25, 2024 14:24
Copy link
Member

@NickLarsenNZ NickLarsenNZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust that this works, and as I understand it we simple remove the [schemars(deny_unknown_fields)] as soon as that schemars issue is resolved.

@sbernauer sbernauer added this pull request to the merge queue Mar 26, 2024
Merged via the queue into main with commit a1a1390 Mar 26, 2024
17 checks passed
@sbernauer sbernauer deleted the fix/node-selector-schema branch March 26, 2024 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

config.affinity.nodeSelector not working
4 participants