-
Notifications
You must be signed in to change notification settings - Fork 131
[Network] refactor InternalFabric name source #3077
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
|
Hi @cheina97. Thanks for your PR! I am @adamjensenbot.
Make sure this PR appears in the liqo changelog, adding one of the following labels:
|
|
/rebase test=true |
2c9577d to
9f7be3a
Compare
|
/build |
9f7be3a to
1f0a19e
Compare
1f0a19e to
8766fd5
Compare
|
/rebase |
8766fd5 to
62e218e
Compare
|
/rebase test=true |
pkg/liqo-controller-manager/networking/internal-network/client-controller/client_controller.go
Outdated
Show resolved
Hide resolved
28ae603 to
a389fd6
Compare
a389fd6 to
2e4a799
Compare
|
@cheina97 First, thanks for this nice contribution. |
07f6e67 to
c2b5d1c
Compare
The name for gateway is still fully customizable, the only resource that is changing name is the InternalFabric that will use the remote cluster ID |
b140dd9 to
7c806b8
Compare
|
/rebase test=true |
3f84205 to
92211df
Compare
|
/rebase test=true |
|
/merge |
| internalFabricName, err := netutils.ForgeInternalFabricName(ctx, r.Client, &gwClient.ObjectMeta) | ||
| if err != nil { | ||
| return fmt.Errorf("unable to retrieve the cluster ID from the gateway client %q", gwClient.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.
Nit: why are we getting the remote cluster ID from the object if we have it already here? I think we can just return the string statically (e.g., func ForgeInternalFabricName(remoteClusterID liqov1beta1.ClusterID) { return remoteClusterID }).
It seems safer (no possible errors raised, no contacting the apiserver).
| // getInternalFabric retrieves the InternalFabric resource associated with the given GatewayServer. | ||
| // WARNING: this function contains 2 calls to the Kubernetes API using 2 different names. | ||
| // This is intended to avoid breaking changes, since the InternalFabric name has changed from GatewayServer name to the GatewayServer cluster ID. | ||
| func getInternalFabric(ctx context.Context, cl client.Client, gatewayName, remoteID, ns string) (*networkingv1beta1.InternalFabric, error) { | ||
| internalFabric := &networkingv1beta1.InternalFabric{} | ||
| err := cl.Get(ctx, client.ObjectKey{ | ||
| Name: remoteID, | ||
| Namespace: ns, | ||
| }, internalFabric) | ||
| if client.IgnoreNotFound(err) != nil { | ||
| return nil, fmt.Errorf("unable to get the internal fabric %q: %w", remoteID, err) | ||
| } |
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.
The real reason for the above comment arises since here it is not clear why we are using the remoteID, and it is harder to maintain or lead to bugs if we change the logic of the ForgeInternalFabric() name again. Instead, we can call the forge method again, passing as argument only the remoteClusterID (also here we have it directly in the function)
Description
This public relations change replaces the Gateway name with the unique remote cluster ID used for Internalfabric.
This addresses a bug that arises when two gateways share the same name. The internal fabrics are created with the same name, and subsequently, their names are utilized to establish two distinct routing tables. However, the routing configuration webhook validates the uniqueness of the routing table names.