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

feat(operator): add support for pod template #5369

Merged
merged 8 commits into from
Oct 29, 2024
Merged

Conversation

jsenko
Copy link
Member

@jsenko jsenko commented Oct 18, 2024

No description provided.

@jsenko
Copy link
Member Author

jsenko commented Oct 18, 2024

@andreaTP Please review, I'll take a look at your PR soon.

@jsenko
Copy link
Member Author

jsenko commented Oct 23, 2024

@andreaTP I've changed the approach to implementing the PTS support. Let me know what you think.

@jsenko jsenko force-pushed the operator-7 branch 2 times, most recently from 4b143e1 to b65a6b5 Compare October 23, 2024 12:33
@jsenko
Copy link
Member Author

jsenko commented Oct 23, 2024

I can close and reopen the PR if you think this is too cluttered.

Copy link
Member

@andreaTP andreaTP left a comment

Choose a reason for hiding this comment

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

@jsenko I overall like where this is going, let's try to continue here if you are not too bothered by the comments.

I think we can improve by separating the "merge things" logic from the getDefaultXXXDeployment.

i.e.:

  • getDefaultXXDeployment -> constructs in code the default base without any check, from scratch
  • mergeXYZ -> contains all the logic for merging the default base with the user-defined values

The distinction will also make clear the intentions and semantic decisions over the merging strategies.

Please, remember that, before merging we should have some sort of documentation about the decisions we are taking when merging stuff.

*
* @param target must not be null
*/
public static <T, K> void mergeNotOverride(List<T> target, List<T> source, Function<T, K> extractKey) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm convinced this can be done in a simpler way, let me know if I should take a stab at it 👍

Copy link
Member Author

@jsenko jsenko Oct 24, 2024

Choose a reason for hiding this comment

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

Can you create a followup PR for this please? This PR does not have to be perfect, is should be correct. I'll be happy to review your PR.

Copy link
Member

Choose a reason for hiding this comment

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

I'm ok with this, agreed.

Copy link
Member

Choose a reason for hiding this comment

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

Follow up PR created: jsenko#1055

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

public class PodTemplateSpecTest {
Copy link
Member

Choose a reason for hiding this comment

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

Nice job here! Clear and well organized!

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you

@jsenko
Copy link
Member Author

jsenko commented Oct 24, 2024

@jsenko I overall like where this is going, let's try to continue here if you are not too bothered by the comments.

I think we can improve by separating the "merge things" logic from the getDefaultXXXDeployment.

i.e.:

* `getDefaultXXDeployment` -> constructs in code the default base without any check, from scratch

* `mergeXYZ` -> contains all the logic for merging the default base with the user-defined values

The distinction will also make clear the intentions and semantic decisions over the merging strategies.

Please, remember that, before merging we should have some sort of documentation about the decisions we are taking when merging stuff.

Updated.

@jsenko
Copy link
Member Author

jsenko commented Oct 24, 2024

Please, remember that, before merging we should have some sort of documentation about the decisions we are taking when merging stuff.

We do not have docs ported yet. What kind of documentation do you have in mind? The merge logic is stupidly simple at the moment and can be documented later.

@andreaTP
Copy link
Member

What kind of documentation do you have in mind?

Even a section in the Readme of the sub-module is fine by me.

The merge logic is stupidly simple

It's "stupidly simple" to you that have written the code, knows where to look for finding information, knows how to use the IDE etc. etc. I think we can improve in inclusiveness here and allow anyone looking at this PR to access a description in plain English of what we are trying to achieve.

All in all, it can be easy or complicated, but there is no documented decision about the tradeoffs we took:

  • merging containers based on names
  • merging ports based on the name of the port
  • rewriting completely probes when defined in PodTemplate
  • etc.

I want to be able to read a spec, reason about it, and verify the implementation.
Writing the code and extracting the rationale after the fact may incur in documented bugs and misinterpretations.

Once we have proper documentation in place we can move the text around.

@jsenko
Copy link
Member Author

jsenko commented Oct 29, 2024

@andreaTP I've added information to the README.

To allow the testing of Ingresses when using minikube, run:
```shell
minikube addons enable ingress
minikube tunnel
Copy link
Member

Choose a reason for hiding this comment

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

side note: this mechanism seems to be not enough on my machine, but I have not narrowed it down.

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm it works for me. Maybe try with the latest version?


If your cluster does not have an accessible ingress host, you can skip them using `test.operator.ingress-skip=true` (**not recommended**).

## PodTemplateSpec merging
Copy link
Member

Choose a reason for hiding this comment

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

Thanks 👍

} else {
r.getSpec().setTemplate(new PodTemplateSpec());
}
mergeDeploymentPodTemplateSpec(
Copy link
Member

Choose a reason for hiding this comment

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

I believe that the most idiomatic place to do this merging is in XXXDeploymentResource so that we have a clear distinction:

  • what comes as default -> comes from RegistryFactory
  • user defined customizations -> reconciled in the DeploymentResource (i.e. before setting the env var for the datasources)

But we can follow up in a separate PR.

Copy link
Member

@andreaTP andreaTP left a comment

Choose a reason for hiding this comment

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

LGTM, good to go, thanks for bearing with me @jsenko

@jsenko jsenko merged commit 0490d15 into Apicurio:main Oct 29, 2024
19 checks passed
@jsenko jsenko deleted the operator-7 branch October 29, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants