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

Add MC transit gateway reconciler #69

Merged
merged 18 commits into from
Sep 18, 2023
Merged

Add MC transit gateway reconciler #69

merged 18 commits into from
Sep 18, 2023

Conversation

mnitchev
Copy link
Member

@mnitchev mnitchev commented Sep 11, 2023

What this PR does / why we need it

Towards giantswarm/roadmap#1827 and https://github.com/giantswarm/giantswarm/issues/25875
This is only the first out of 3 reconcilers that implement he aws-network-topology-operator, which is why it isn't yet added in main.go, so after merging this PR it still won't be enabled.

Checklist

  • Update changelog in CHANGELOG.md.

@mnitchev mnitchev marked this pull request as ready for review September 11, 2023 13:06
@mnitchev mnitchev requested a review from a team as a code owner September 11, 2023 13:06
Co-authored-by: Jose Armesto <github@armesto.net>
go.mod Outdated Show resolved Hide resolved
@mnitchev mnitchev requested a review from fiunchinho September 12, 2023 14:00
Copy link
Member

@fiunchinho fiunchinho left a comment

Choose a reason for hiding this comment

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

Left a few comments.

Apart from that, on this repository I tried to avoid mixing dependencies between packages as much as possible. For example, the aws package didn't depend on any CAPI/CAPA/k8s library. That's why there is a Cluster object defined on this repository.

I think there is value on this isolation, that will help us later on when upgrading these libraries. Thoughts?

Comment on lines +71 to +73
if len(gateways) == 0 {
return nil, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

I think a potential client of this function would expect an error when trying to find an object that doesn't exist. What do you think about returning error on that case?

Copy link
Member Author

Choose a reason for hiding this comment

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

It'll probably be added later. As it is right now it isn't needed as it's private.

pkg/k8sclient/package.go Outdated Show resolved Hide resolved
pkg/resolver/package.go Outdated Show resolved Hide resolved
controllers/management_cluster_transit_gateway.go Outdated Show resolved Hide resolved
Comment on lines +75 to +77
defer func() {
_ = r.clusterClient.UpdateStatus(ctx, cluster)
}()
Copy link
Member

Choose a reason for hiding this comment

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

Functions like Addfinalizer call the k8s API right away, sending a patch request to modify the object. So I think it's odd that we are mixing both approaches here. On one hand, we send request to the API right away to do the modification, while using defer we update the object when the function returns. It's fine, but I'd prefer to use the same approach for all cases.

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'm not too sure about this one. This updates the conditions in the status and those can be overwritten in the course of reconciling (for example it starts as InProgress, but can transition to error or completed in the same loop). So I think it makes sense to do it with defer here.
For the finalizer though it does make sense to just change that and nothing else. In fact we explicitly don't want to change anything else because we shouldn't be changing the desired state. I guess we can convert the status updates to be done the same way, but I'm not too sure about it

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense, let's keep it like you have now then 👍

@mnitchev
Copy link
Member Author

I've changed the client to take name string as an argument as that's the only thing needed. I felt that's the easiest way to do it as converting to the cluster object also requires getting the identity and that's totally unnecessary.

@mnitchev mnitchev requested a review from fiunchinho September 18, 2023 07:41
@mnitchev mnitchev merged commit a9532f9 into main Sep 18, 2023
3 checks passed
@mnitchev mnitchev deleted the pr-add-transit-gateways branch September 18, 2023 08:35
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.

3 participants