-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Embed only a subset of metav1.ObjectMeta fields #1062
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
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/assign @ncdc |
7d0f193
to
78f2559
Compare
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
/hold
This looks okay to me though it is a significant breaking change so we should probably wait until a weekly meeting to ensure consensus.
@@ -56,3 +57,69 @@ type MachineClassRef struct { | |||
// +optional | |||
Provider string `json:"provider,omitempty"` | |||
} | |||
|
|||
// ObjectMeta is metadata that all persisted resources must have, which includes all objects |
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.
Can we leave more context? For example, why is this necessary for Machine
and not other CRDs? And if it's only because Machine
is embedded in other CRDs, then is there an upstream ticket to track this issue?
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.
Added more context
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.
This is a fair explanation. I was mostly thinking about the problem this attempts to solve, and how it is likely to come up again. For example, suppose someone embeds MachineDeployment
in another CRD. Won't they run into these same issues? And if so, why not remove ObjectMeta
from MachineDeployment
too?
I guess I am wondering what the long term guidance is from api machinery...
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.
There's a couple of things going on here:
- All objects have root-level
ObjectMeta
- Some objects, such as
Machine
andMachineSet
, include non-rootObjectMeta
somewhere in their nested structures
If anyone includes any Kubernetes object (built-in or CRD) in their own object, you'll end up with a similar situation: root-level ObjectMetadata
along with non-root ObjectMeta
. In the past, we've tried to design the API types such that the portions that someone might want to include are reusable (e.g. including MachineSpec
in MachineSet
(instead of a full Machine
)). This could work, in theory, except some of these types have an ObjectMeta
in them, even though they're not root-level types. It would be nice if these types used some other structure instead of ObjectMeta
.
That's not necessarily a problem - we've been doing it for a while in CAPI, and core Kubernetes does it too. The problem @vincepri is running into is that the newer version of kubebuilder/controller-runtime/controller-tools generates openapi schema validation definitions that make it so you can't successfully create a Machine because of this nested ObjectMeta
and a null creationTimestamp
field.
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.
Also, when including a non-root ObjectMeta
field, a lot of the time it's just to use it for the annotations
and/or labels
, but not the entire set of fields. It may be better to scope the non-root field to just the fields you need, instead of a full ObjectMeta
struct.
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.
+1 on inspecting long term effects.
i think the PR should include more detail on the actual problem it's solving.
e.g. comments about:
validation failure list:
spec.metadata.creationTimestamp in body must be of type string: "null"
something puzzling in the slack thread was that this started happening suddenly, did you figure out what caused that? was it kubernetes/kubernetes#77653 ?
78f2559
to
175725e
Compare
/hold cancel Merging this now unblocks v1alpha2 work. We should discuss further on Wednesday. |
I like it! Merge, unblock, correct later if needed. 🎉 |
@ncdc Adding more details to the commit, one second |
175725e
to
30567fa
Compare
@ncdc @neolit123 @davidewatson Added more details to the comment above ObjectMeta. @neolit123 The issue popped up for multiple reasons, I'm unaware of the implications for the PR you mentioned. The change that broke this behavior for us is in |
Signed-off-by: Vince Prignano <[email protected]>
30567fa
to
842731b
Compare
/lgtm |
Signed-off-by: Vince Prignano [email protected]
What this PR does / why we need it:
This PR removes all references to
metav1.ObjectMeta
to embedded resources. This patch came from a discussion in the upstream kubebuilder slack. Themetav1.ObjectMeta
type, when embedded, contains a lot of fields that cannot be set from a client. This PR bring a copy of ObjectMeta into Cluster API including only fields that a user can set.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
Release note: