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

refactor(multicluster): Replace use of unstructured API with typed bindings for Link CR #13420

Merged
merged 8 commits into from
Dec 10, 2024

Conversation

adleong
Copy link
Member

@adleong adleong commented Dec 4, 2024

The linkerd-multicluster extension uses client-go's unstructured API to access Link custom resources. This API allowed us to develop quickly without the work of generating typed bindings. However, using the unstrucutred API is error prone since fields must be accessed by their string name. It is also inconsistent with the rest of the project which uses typed bindings.

We replace the use of the unstructured API for Link resources with generated typed bindings. The client-go APIs are slightly different and client-go does not provide a way to update subresources for typed bindings. Therefore, when updating a Link's status subresource, we use a patch instead of an update.

Signed-off-by: Alex Leong <alex@buoyant.io>
Signed-off-by: Alex Leong <alex@buoyant.io>
Signed-off-by: Alex Leong <alex@buoyant.io>
Signed-off-by: Alex Leong <alex@buoyant.io>
Signed-off-by: Alex Leong <alex@buoyant.io>
Signed-off-by: Alex Leong <alex@buoyant.io>
Signed-off-by: Alex Leong <alex@buoyant.io>
@adleong adleong marked this pull request as ready for review December 6, 2024 17:01
@adleong adleong requested a review from a team as a code owner December 6, 2024 17:01
Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

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

This is awesome; nice riddance of the unstructured mess!

One minor thing: we still have old versions for both server and link in bin/update-codegen.sh, can you update that as well?

controller/gen/apis/link/v1alpha2/types.go Outdated Show resolved Hide resolved
cleanupWorkers()
// Use a small buffered channel for Link updates to avoid dropping
// updates if there is an update burst.
results := make(chan *v1alpha2.Link, 100)
Copy link
Member

Choose a reason for hiding this comment

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

Would be cool as a followup to get a metric on the size of this queue and/or the number of dropped updates

@@ -58,7 +58,7 @@ rules:
verbs: ["list", "get", "watch"]
- apiGroups: ["multicluster.linkerd.io"]
resources: ["links/status"]
verbs: ["update"]
verbs: ["update", "patch"]
Copy link
Member

Choose a reason for hiding this comment

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

Do you know if we still require update here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't believe so, but it might be safer to keep it to give us more flexibility in terms of the exact API calls that are used to update the status.

Signed-off-by: Alex Leong <alex@buoyant.io>
@adleong adleong changed the title Replace use of unstructured API with typed bindings for Link CR refactor(multicluster): Replace use of unstructured API with typed bindings for Link CR Dec 9, 2024
@adleong adleong merged commit 396af7c into main Dec 10, 2024
42 checks passed
@adleong adleong deleted the alex/link-bindings branch December 10, 2024 19:44
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