Skip to content

Commit 9f7be3a

Browse files
committed
refactor: change internal fabric name
1 parent 7228d38 commit 9f7be3a

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

pkg/gateway/fabric/geneve/internalnode_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (r *InternalNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request
7373
klog.V(4).Infof("Reconciling internalnode %s", req.String())
7474

7575
// The internal fabric has the same name of the gateway resource.
76-
internalFabricName := r.Options.GwOptions.Name
76+
internalFabricName := r.Options.GwOptions.RemoteClusterID
7777
id, err := geneve.GetGeneveTunnelID(ctx, r.Client, internalFabricName, internalnode.Name)
7878
if err != nil {
7979
return ctrl.Result{}, fmt.Errorf("internalnodecontroller waiting for geneve tunnel creation (with id %q): %w", id, err)

pkg/liqo-controller-manager/networking/forge/gatewayclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const (
3434

3535
// defaultGatewayClientName returns the default name for a GatewayClient.
3636
func defaultGatewayClientName(remoteClusterID liqov1beta1.ClusterID) string {
37-
return string(remoteClusterID)
37+
return "nomebrutto"
3838
}
3939

4040
// GwClientOptions encapsulate the options to forge a GatewayClient.

pkg/liqo-controller-manager/networking/internal-network/client-controller/client_controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,14 @@ func (r *ClientReconciler) ensureInternalFabric(ctx context.Context, gwClient *n
106106
return fmt.Errorf("internal endpoint not found for the gateway client %q", gwClient.Name)
107107
}
108108

109+
internalFabricName, err := getters.RetrieveClusterIDFromObject(gwClient)
110+
if err != nil {
111+
return fmt.Errorf("unable to retrieve the cluster ID from the gateway client %q", gwClient.Name)
112+
}
113+
109114
internalFabric := &networkingv1beta1.InternalFabric{
110115
ObjectMeta: metav1.ObjectMeta{
111-
Name: gwClient.Name,
116+
Name: string(internalFabricName),
112117
Namespace: gwClient.Namespace,
113118
},
114119
}

pkg/liqo-controller-manager/networking/internal-network/server-controller/server_controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,14 @@ func (r *ServerReconciler) ensureInternalFabric(ctx context.Context, gwServer *n
106106
return fmt.Errorf("internal endpoint not found for the gateway server %q", gwServer.Name)
107107
}
108108

109+
internalFabricName, err := getters.RetrieveClusterIDFromObject(gwServer)
110+
if err != nil {
111+
return fmt.Errorf("unable to retrieve the cluster ID from the gateway server %q", gwServer.Name)
112+
}
113+
109114
internalFabric := &networkingv1beta1.InternalFabric{
110115
ObjectMeta: metav1.ObjectMeta{
111-
Name: gwServer.Name,
116+
Name: string(internalFabricName),
112117
Namespace: gwServer.Namespace,
113118
},
114119
}

pkg/utils/getters/dataGetters.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,18 @@ func RetrieveClusterIDsFromObjectsLabels[T metav1.Object](objectList []T) []stri
180180
}
181181
return slices.Collect(maps.Keys(clusterIDs))
182182
}
183+
184+
// RetrieveClusterIDFromObject retrieves the remote cluster ID from the labels of a generic kubernetes object.
185+
func RetrieveClusterIDFromObject[T metav1.Object](object T) (liqov1beta1.ClusterID, error) {
186+
labels := object.GetLabels()
187+
if labels == nil {
188+
return "", fmt.Errorf("object %s/%s has no labels", object.GetNamespace(), object.GetName())
189+
}
190+
191+
clusterID, ok := labels[liqoconsts.RemoteClusterID]
192+
if !ok || clusterID == "" {
193+
return "", fmt.Errorf("object %s/%s has no remote cluster ID label", object.GetNamespace(), object.GetName())
194+
}
195+
196+
return liqov1beta1.ClusterID(clusterID), nil
197+
}

0 commit comments

Comments
 (0)