-
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 classNamespace to topology #11352
base: main
Are you sure you want to change the base?
✨ Add classNamespace to topology #11352
Conversation
ae1cb19
to
43cb995
Compare
2bddeeb
to
352fd66
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.
Thanks @Danil-Grigorev! I added a small suggestion but I think this looks good.
docs/book/src/tasks/experimental-features/cluster-class/write-clusterclass.md
Outdated
Show resolved
Hide resolved
352fd66
to
bd8a56f
Compare
Thanks @Danil-Grigorev /lgtm |
LGTM label has been added. Git tree hash: c4b418743a4683ae623b3264aae7636c41ad5675
|
/assign @chrischdi |
bd8a56f
to
4bbb218
Compare
4bbb218
to
d450768
Compare
New changes are detected. LGTM label has been removed. |
bbbddcf
to
b4b6131
Compare
docs/book/src/tasks/experimental-features/cluster-class/write-clusterclass.md
Outdated
Show resolved
Hide resolved
c581444
to
3639364
Compare
docs/book/src/tasks/experimental-features/cluster-class/write-clusterclass.md
Outdated
Show resolved
Hide resolved
docs/book/src/tasks/experimental-features/cluster-class/write-clusterclass.md
Outdated
Show resolved
Hide resolved
@chrischdi @fabriziopandini Can I get another review? All comments are addressed here. |
902e582
to
2730042
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
03780fe
to
1ae95a5
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.
Thank you for working on this and thx for the patience. Sorry for the delay
067fcc5
to
21ec29a
Compare
docs/book/src/tasks/experimental-features/cluster-class/write-clusterclass.md
Outdated
Show resolved
Hide resolved
@Danil-Grigorev Just a few minor comments |
8706ddc
to
681bdbd
Compare
- Add documentation on securing cross-namespace access for CC - Add ByClusterClassRef index - Support cross-ns CC rebase Signed-off-by: Danil-Grigorev <[email protected]>
681bdbd
to
ebdc21d
Compare
// managers cache. | ||
func ByClusterClassRef(ctx context.Context, mgr ctrl.Manager) error { | ||
if err := mgr.GetCache().IndexField(ctx, &clusterv1.Cluster{}, | ||
ClusterClassNameField, |
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.
ClusterClassNameField, | |
ClusterClassRefPath, |
(same for the Cluster List calls where we use the index)
Please also check all usages of ClusterClassNameField outside of this package (e.g. internal/webhooks/clusterclass_test.go)
return nil | ||
} | ||
|
||
// ClusterByClusterClassRef contains the logic to index Clusters by ClusterClass name. |
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.
// ClusterByClusterClassRef contains the logic to index Clusters by ClusterClass name. | |
// ClusterByClusterClassRef contains the logic to index Clusters by ClusterClass name and namespace. |
nit
@@ -401,19 +401,19 @@ func TestClusterClassesAreCompatible(t *testing.T) { | |||
APIVersion: "group.test.io/foo", |
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.
Didn't initially realize how broken this test is now :D
I think we should have defaultRef, incompatibleDefaultRef, compatibleRef, otherRef, ... (in the default & other namespace)
And then below we should make sure that each ClusterClass only has refs that match their own namespace (it's invalid to reference from a ClusterClass in one namespace to an external object in another namespace)
Let's also change l.476 to use "other" as namespace
desired: builder.ClusterClass(metav1.NamespacePublic, "class1"). | ||
WithInfrastructureClusterTemplate( | ||
builder.InfrastructureClusterTemplate(metav1.NamespaceDefault, "infra1").Build()). |
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.
desired: builder.ClusterClass(metav1.NamespacePublic, "class1"). | |
WithInfrastructureClusterTemplate( | |
builder.InfrastructureClusterTemplate(metav1.NamespaceDefault, "infra1").Build()). | |
desired: builder.ClusterClass("other"", "class1"). | |
WithInfrastructureClusterTemplate( | |
builder.InfrastructureClusterTemplate("other"", "infra1").Build()). |
I meant we have to change these refs. All referenced templates of a CC should be in the same Namespaces as the CC itself (same for the rest of this builder)
@@ -706,19 +706,19 @@ func TestMachineDeploymentClassesAreCompatible(t *testing.T) { | |||
APIVersion: "group.test.io/foo", | |||
Kind: "barTemplate", | |||
Name: "baz", | |||
Namespace: "default", | |||
Namespace: "other", |
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.
Let's keep this at default as well (otherwise we don't verify that it's okay to change namespace)
Same in l.855
} | ||
|
||
// ClusterClassRef returns ClusterClass index key to be used for search. | ||
func ClusterClassRef(o client.Object) string { |
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.
func ClusterClassRef(o client.Object) string { | |
func ClusterClassRef(cc *clusterv1.ClusterClass) string { |
To make this slightly more typesafe
What this PR does / why we need it:
Adding
classNamespace
variable to the cluster topology, which allows to point to a ClusterClass in a different namespace. This field is dormant, and is used for differentiation only.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Related to #5673
/area clusterclass