-
Notifications
You must be signed in to change notification settings - Fork 316
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
Add apply configurations to generated client #1818
Conversation
6590e96
to
ae215d5
Compare
@kevin85421 the new e2e test, that covers SSA, currently fails because of the I need to review the possible solutions, but I might request your feedback on this if I fail to find a good solution. |
@astefanutti Do you mind giving me some keywords that I need to understand in order to have enough context to review this PR? Thanks! |
e1f4d29
to
6100e89
Compare
@kevin85421 you'll find a very good introduction about SSA here https://kubernetes.io/blog/2022/10/20/advanced-server-side-apply/. Here is the breakdown of the changes introduced by this PR:
|
2039d4b
to
5effdac
Compare
) | ||
|
||
var ( | ||
TestApplyOptions = metav1.ApplyOptions{FieldManager: "kuberay-test", Force: true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read this article and it said "Controllers typically should unconditionally set all the fields they own by setting Force: true
in the ApplyOptions
.". I can't understand what "the fields they own" means. Would you mind explaining why we need to add Force: true
and what's the difference with and without Force: true
? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Force
option is used to control the resolution logic when conflicts occur. The possible strategies are documented at:
https://kubernetes.io/docs/reference/using-api/server-side-apply/#conflicts
In the case of e2e tests here, the recommendation to use Force: true
applies well. The e2e tests impersonate / emulate a real client / end-user, and what the tests specify using SSA apply configurations (e.g. RayCluster / RayJob spec) is what's owned by that client / end-user.
} | ||
} | ||
|
||
func headPodTemplateApplyConfiguration() *corev1ac.PodTemplateSpecApplyConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we can create a RayJob custom resource by SSA using an applyconfiguration
(e.g., headPodTemplateApplyConfiguration()
), or we can directly construct the CR using headPodTemplate()
. Should we consider gradually updating existing tests to use SSA for creating RayJob CRs in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be my suggestion / recommendation too. I find apply configurations fluent API style and SSA conflict management very convenient.
My original intention with the e2e tests was to use SSA, but that needed the work introduced by that PR first. We could gradually update the existing tests as you suggest.
Note the benefits of SSA are also applicable to the operator itself, but that would require more substantial work.
|
||
type labelSelector string | ||
|
||
var _ Option[*metav1.ListOptions] = (*labelSelector)(nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ChatGPT tells me that *"This line asserts that labelSelector implements the Option interface for metav1.ListOptions. It's a common way in Go to ensure at compile time that a type satisfies an interface.". Is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's exactly that :)
ray-operator/test/support/meta.go
Outdated
|
||
// nolint: unused | ||
// To be removed when the false-positivity is fixed. | ||
func (l labelSelector) applyTo(to *metav1.ListOptions) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind sharing more details about "To be removed when the false-positivity is fixed."? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the root issue is dominikh/go-tools#1294.
There are still a number of false positive w.r.t. generics support: https://github.com/dominikh/go-tools/issues?q=is%3Aopen+label%3Afalse-positive+generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q1: I haven't reviewed the files under pkg/client
. Are they generated files?
I want to double-check the reason why we decided to use applyconfiguration
.
- There are two field managers, the KubeRay operator and
kuberay-test
, in e2e tests. - Prior to this PR, we used
Update
without SSA, but it may have led to some 409 conflicts. - In this PR, we use SSA Apply with
Force: true
. TheApply
request will always succeed.
Is my understanding correct? Thanks!
Yes, these files are generated, as the other ones that already exist in They are "validated" by the added e2e test.
Yes, your understanding is correct 👍🏼. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I learned a lot from reviewing this PR. Thank you!
FYI I think CI is currently broken because the generated applyconfigurtaion was not updated after this change #1839
|
(I'll open a PR to fix it) |
@astefanutti I've been finding that runing |
@andrewsykim it takes around 2 minutes to complete on my setup. How long does that take on your side? I'm not that surprised, compared to the data points I have from other projects. It may be embedding the I don't see anything obvious we could do to optimise that generation time. That'd probably require to look deeper at code-generator. There is kubernetes/code-generator#69 open that could be related as well. |
Why are these changes needed?
This PR generates apply configurations for the Kuberay API client.
Related issue number
Closes #1811.
Checks