Skip to content

Commit 411f755

Browse files
committed
refactor: internalnode name
1 parent 65b12d2 commit 411f755

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

pkg/gateway/fabric/geneve/internalfabric.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,33 @@ import (
1818
"context"
1919
"fmt"
2020

21-
"k8s.io/apimachinery/pkg/api/errors"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
"sigs.k8s.io/controller-runtime/pkg/client"
2323

2424
networkingv1beta1 "github.com/liqotech/liqo/apis/networking/v1beta1"
25+
"github.com/liqotech/liqo/pkg/consts"
26+
"github.com/liqotech/liqo/pkg/liqo-controller-manager/networking/utils"
2527
)
2628

2729
// getInternalFabric retrieves the InternalFabric resource associated with the given GatewayServer.
2830
// WARNING: this function contains 2 calls to the Kubernetes API using 2 different names.
2931
// This is intended to avoid breaking changes, since the InternalFabric name has changed from GatewayServer name to the GatewayServer cluster ID.
3032
func getInternalFabric(ctx context.Context, cl client.Client, gatewayName, remoteID, ns string) (*networkingv1beta1.InternalFabric, error) {
33+
name, err := utils.ForgeInternalFabricName(ctx, cl, &metav1.ObjectMeta{
34+
Name: gatewayName,
35+
Labels: map[string]string{
36+
consts.RemoteClusterID: remoteID,
37+
},
38+
})
39+
3140
internalFabric := &networkingv1beta1.InternalFabric{}
32-
err := cl.Get(ctx, client.ObjectKey{
33-
Name: remoteID,
41+
err = cl.Get(ctx, client.ObjectKey{
42+
Name: name,
3443
Namespace: ns,
3544
}, internalFabric)
3645
if client.IgnoreNotFound(err) != nil {
3746
return nil, fmt.Errorf("unable to get the internal fabric %q: %w", remoteID, err)
3847
}
3948

40-
err = cl.Get(ctx, client.ObjectKey{
41-
Name: gatewayName,
42-
Namespace: ns,
43-
}, internalFabric)
44-
45-
switch {
46-
case errors.IsNotFound(err):
47-
return nil, fmt.Errorf("could not find internal fabric with names %q and %q: %w", gatewayName, remoteID, err)
48-
case err != nil:
49-
return nil, fmt.Errorf("unable to get the internal fabric %q: %w", gatewayName, err)
50-
}
51-
5249
return internalFabric, nil
5350
}

pkg/liqo-controller-manager/networking/utils/internalfabric.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ func ForgeInternalFabricName(ctx context.Context, cl client.Client, meta *metav1
5050
case err != nil:
5151
return "", fmt.Errorf("unable to get the internal fabric %q: %w", meta.Name, err)
5252
}
53-
return internalFabric.Name, nil
53+
return meta.Name, nil
5454
}

0 commit comments

Comments
 (0)