-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 ClusterClass variable and patch types #5418
✨ Add ClusterClass variable and patch types #5418
Conversation
3ced181
to
22ffd68
Compare
22ffd68
to
325c44c
Compare
325c44c
to
909885d
Compare
909885d
to
8563f84
Compare
e0ad631
to
a851a7f
Compare
api/v1beta1/cluster_types.go
Outdated
// VariableTopology can be used to customize the Cluster through | ||
// patches. It must comply to the corresponding | ||
// VariableDefinitionClass defined in the ClusterClass. | ||
type VariableTopology 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.
I see that there is a naming scheme, but maybe consider calling it TopologyVariable
as that makes it easier to understand what it actually is.
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 could change it, the problem is getting consensus again on the struct names. Same applies to the other suggestions.
I see (at least 3 options):
- keep the current names
- your suggestions
- just drop the Topology and Class suffixes entirely
(I would prefer option 3)
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 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'm personally for keeping current names because those name were discussed at length in the proposal/in the google doc predating the proposal and they are nicely consistent with the suffix used for all the Topology/Class types.
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'm also absolutely fine with the current implementation. And as you said we already discussed it on the proposal and I would also really like to avoid loosing too much time by waiting for consensus again.
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.
Further discussed in Slack and Zoom.
Result is the following:
spec:
variables: # []ClusterClassVariable
- name: clusterIdentityName
required: true
schema: # VariableSchema
openAPIV3Schema: # JSONSchemaProps
type: string
default: cluster-identity
patches: # []ClusterClassPatch
- name: clusterName
definitions: # []PatchDefinition
- selector: # PatchSelector
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlaneTemplate
matchResources: # PatchSelectorMatch
machineDeploymentClass: # PatchSelectorMatchMachineDeploymentClass
names:
- default-worker
jsonPatches: # []JSONPatchDefinition
- op: replace
path: "/spec/template/spec/kubeadmConfigSpec/clusterConfiguration/controllerManager/extraArgs/cluster-name"
valueFrom: # JSONPatchDefinitionValue
variable: builtin.cluster.name
spec:
topology:
variables: # []ClusterVariable
- name: clusterIdentityName
value: cluster-identity
Reasoning (re-stating some of Fabrizio's points for completeness):
- We should strive for names that mean something.
- Topology/ClusterClass Kinds that already exist and have been released before this proposal are ok. And they cannot be changed anymore without going through the full deprecation cycle.
- Essentially we have two kinds of new structs in this PR:
- Structs which are specific to the API type where they are used
- These structs have been prefixed:
ClusterClassVariable
,ClusterClassPatch
andClusterVariable
- These structs have been prefixed:
- Structs which are generic and could be reused in other types in the future (at least in theory)
- In those case we optimized for semantic, understandability, not too-long names. Those are:
VariableSchema
,JSONSchemaProps
PatchDefinition
,PatchSelector
,PatchSelectorMatch
,PatchSelectorMatchMachineDeploymentClass
JSONPatchDefinition
,JSONPatchDefinitionValue
- In those case we optimized for semantic, understandability, not too-long names. Those are:
- Structs which are specific to the API type where they are used
Note: We don't want to establish any hard rules here. That's just the reasoning for the current case/PR.
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 to the proposed solution
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.
Any reason not to drop the Definition
so we have JSONPatch
and JSONPatchValue
? The objects themselves are a definition of something, so it feels redundant.
The rest looks good.
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.
We could, but I'm not sure we should. The valueFrom
part does not exist in the usual definitions of what a JSON patch is supposed to look like. So it's maybe good to signal with JSONPatchDefinition (related to the other PatchDefinition we have) that it's not just a regular JSON patch.
But I would be fine with both.
@fabriziopandini @vincepri WDYT?
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.
Ok to drop definition from JSONPatchDefinition and JSONPatchDefinitionValue
/hold for review |
e27c834
to
1061a4f
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.
Overall lgtm pending discussion on fuzzers for JSON fields and type names
/lgtm |
/hold cancel |
8506454
to
c3e542c
Compare
the common way is to have the type at the end - e.g. "StorageClass" |
I agree for the top-level API type names, if something is a
|
i might be confusing what
having |
Yes, there are also a lot more not only Status and Spec (full list of core structs) |
Thx everyone for the discussion. I summarized the struct renaming in: #5418 (comment) (and adjusted the implementation and proposal accordingly) Additionally we dropped the ".variables.definitions[].{name,required,schema}" layer. Initially the idea was to use it to make variables extensible so we can later on consume variables from somewhere else. This was inconsistent with ".patches[].definitions[].{selector,jsonPatches}" (e.g. patches was an array, variables was not). We've kept We would now (probably) solve consuming external variables and patches by adding something like |
great job! |
d4a72e4
to
1563423
Compare
s/JSONPatchDefinition/JSONPatch/ + squashed |
/lgtm |
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
/assign @vincepri |
Signed-off-by: Stefan Büringer [email protected]
1563423
to
1022e26
Compare
in.Default = &apiextensionsv1.JSON{Raw: []byte("true")} | ||
|
||
// Not every random string is a valid JSON number, so we're setting a valid JSON number. | ||
number := json.Number("1") |
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.
Could we use an actual random number?
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.
Yeah, we could
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.
/approve
/lgtm
[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 |
Signed-off-by: Stefan Büringer [email protected]
What this PR does / why we need it:
This PR adds the patch and variable types as discussed in: #5212
It intentionally does not contain any webhook or controller code changes.
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 #