Skip to content

Commit 393ccf8

Browse files
fra98claudiolor
authored andcommitted
fix: added unique names to all controllers
1 parent c73f22f commit 393ccf8

File tree

47 files changed

+153
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+153
-119
lines changed

cmd/crd-replicator/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ func main() {
9595
clusterID, namespaceManager),
9696
}
9797
if err = d.SetupWithManager(mgr); err != nil {
98-
klog.Error(err, "unable to setup the crdreplicator-operator")
98+
klog.Error(err, "unable to setup the crdReplicator controller")
9999
os.Exit(1)
100100
}
101101

102-
klog.Info("Starting crdreplicator-operator")
102+
klog.Info("Starting crdReplicator manager")
103103
if err := mgr.Start(ctx); err != nil {
104-
klog.Error(err, "problem running manager")
104+
klog.Error(err, "unable to start the crdReplicator manager")
105105
os.Exit(1)
106106
}
107107
}

internal/crdReplicator/crdReplicator-operator.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ import (
4545
)
4646

4747
const (
48-
operatorName = "crdReplicator-operator"
49-
finalizer = "crdreplicator.liqo.io/operator"
48+
finalizer = "crdreplicator.liqo.io/operator"
5049
)
5150

5251
// Controller reconciles identity Secrets to start/stop the reflection of registered resources to remote clusters.
@@ -188,10 +187,9 @@ func (c *Controller) SetupWithManager(mgr ctrl.Manager) error {
188187
return err
189188
}
190189

191-
return ctrl.NewControllerManagedBy(mgr).
192-
Named(operatorName).
193-
WithEventFilter(resourceToBeProccesedPredicate).
190+
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlSecretsCRDReplicator).
194191
For(&corev1.Secret{}, builder.WithPredicates(secretsFilter)).
192+
WithEventFilter(resourceToBeProccesedPredicate).
195193
Complete(c)
196194
}
197195

pkg/consts/controllers.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright 2019-2024 The Liqo Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package consts
16+
17+
// Constants used to name and identify controllers.
18+
// Controller-runtime requires that each controller has a unique name within the container.
19+
// This name is used, for example, to identify a controller univocally in the logs
20+
// and must be a prometheus compatible name (underscores and alphanumeric characters only).
21+
// As a convention to avoid conflicts, we use the name of the reconciled resource (lowercase version of their kind),
22+
// and, if already used, we add a recognizable identifier, separated by the underscore character.
23+
// To catch duplicated names, we name the constant as its value (in CamelCase and stripping the separator character),
24+
// with the prefix "Ctrl".
25+
const (
26+
// Core.
27+
CtrlForeignCluster = "foreigncluster"
28+
CtrlSecretsCRDReplicator = "secrets_crdreplicator"
29+
30+
// Networking.
31+
CtrlConfigurationExternal = "configuration_external"
32+
CtrlConfigurationInternal = "configuration_internal"
33+
CtrlConfigurationIPMapping = "configuration_ipmapping"
34+
CtrlConfigurationRemapping = "configuration_remapping"
35+
CtrlConfigurationRoute = "configuration_route"
36+
CtrlConnections = "connections"
37+
CtrlFirewallConfiguration = "firewallconfiguration"
38+
CtrlGatewayClientExternal = "gatewayclient_external"
39+
CtrlGatewayClientInternal = "gatewayclient_internal"
40+
CtrlGatewayServerExternal = "gatewayserver_external"
41+
CtrlGatewayServerInternal = "gatewayserver_internal"
42+
CtrlInternalFabricsCM = "internalfabrics_cm"
43+
CtrlInternalFabricsFabric = "internalfabrics_fabric"
44+
CtrlInternalNodeGeneve = "internalnode_geneve"
45+
CtrlInternalNodeRoute = "internalnode_route"
46+
CtrlIP = "ip"
47+
CtrlIPRemapping = "ip_remapping"
48+
CtrlNetwork = "network"
49+
CtrlNode = "node"
50+
CtrlPodGateway = "pod_gateway"
51+
CtrlPodGwMasq = "pod_gw_masq"
52+
CtrlPodInternalNet = "pod_internalnet"
53+
CtrlPodIPMapping = "pod_ipmapping"
54+
CtrlPulicKeys = "publickeys"
55+
CtrlRouteConfiguration = "routeconfiguration"
56+
CtrlWGGatewayClient = "wggatewayclient"
57+
CtrlWGGatewayServer = "wggatewayserver"
58+
59+
// Authentication.
60+
CtrlIdentity = "identity"
61+
CtrlIdentityCreator = "identity_creator"
62+
CtrlNonceCreator = "nonce_creator"
63+
CtrlNonceSigner = "nonce_signer"
64+
CtrlResourceSlicesLocal = "resourceslices_local"
65+
CtrlResourceSlicesRemote = "resourceslices_remote"
66+
CtrlTenant = "tenant"
67+
68+
// Offloading.
69+
CtrlNamespaceMap = "namespace_map"
70+
CtrlNamespaceOffloading = "namespaceoffloading"
71+
CtrlNodeFailure = "node_failure"
72+
CtrlPodStatus = "pod_status"
73+
CtrlShadowEndpointSlice = "shadowendpointslice"
74+
CtrlShadowPods = "shadowpods"
75+
CtrlVirtualNode = "virtualnode"
76+
CtrlVirtualNodeCreator = "virtualnode_creator"
77+
78+
// Cross modules.
79+
CtrlResourceSlicesQuotaCreator = "resourceslices_quotacreator"
80+
)

pkg/fabric/internalfabric_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
ctrlutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2929

3030
networkingv1beta1 "github.com/liqotech/liqo/apis/networking/v1beta1"
31+
"github.com/liqotech/liqo/pkg/consts"
3132
"github.com/liqotech/liqo/pkg/utils/network/geneve"
3233
)
3334

@@ -126,7 +127,7 @@ func (r *InternalFabricReconciler) Reconcile(ctx context.Context, req ctrl.Reque
126127

127128
// SetupWithManager register the InternalFabricReconciler to the manager.
128129
func (r *InternalFabricReconciler) SetupWithManager(mgr ctrl.Manager) error {
129-
return ctrl.NewControllerManagedBy(mgr).
130+
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlInternalFabricsFabric).
130131
For(&networkingv1beta1.InternalFabric{}).
131132
Complete(r)
132133
}

pkg/fabric/source-detector/gateway_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"sigs.k8s.io/controller-runtime/pkg/predicate"
3333

3434
networkingv1beta1 "github.com/liqotech/liqo/apis/networking/v1beta1"
35+
"github.com/liqotech/liqo/pkg/consts"
3536
"github.com/liqotech/liqo/pkg/fabric"
3637
"github.com/liqotech/liqo/pkg/gateway"
3738
)
@@ -115,7 +116,7 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error {
115116
return err
116117
}
117118

118-
return ctrl.NewControllerManagedBy(mgr).
119+
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlPodGateway).
119120
For(&corev1.Pod{}, builder.WithPredicates(filterByLabelsGatewayPods)).
120121
Complete(r)
121122
}

pkg/firewall/firewallconfiguration_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"sigs.k8s.io/controller-runtime/pkg/predicate"
3636

3737
networkingv1beta1 "github.com/liqotech/liqo/apis/networking/v1beta1"
38+
"github.com/liqotech/liqo/pkg/consts"
3839
"github.com/liqotech/liqo/pkg/utils/network/netmonitor"
3940
)
4041

@@ -172,7 +173,7 @@ func (r *FirewallConfigurationReconciler) SetupWithManager(ctx context.Context,
172173
go func() {
173174
utilruntime.Must(netmonitor.InterfacesMonitoring(ctx, src, &netmonitor.Options{Nftables: &netmonitor.OptionsNftables{Delete: true}}))
174175
}()
175-
return ctrl.NewControllerManagedBy(mgr).
176+
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlFirewallConfiguration).
176177
For(&networkingv1beta1.FirewallConfiguration{}, builder.WithPredicates(filterByLabelsPredicate)).
177178
WatchesRawSource(NewFirewallWatchSource(src, NewFirewallWatchEventHandler(r.Client, r.LabelsSets))).
178179
Complete(r)

pkg/gateway/connection/connections_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (r *ConnectionsReconciler) SetupWithManager(mgr ctrl.Manager) error {
117117
if err != nil {
118118
return err
119119
}
120-
return ctrl.NewControllerManagedBy(mgr).
120+
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlConnections).
121121
For(&networkingv1beta1.Connection{}, builder.WithPredicates(filterByLabelsPredicate)).
122122
Complete(r)
123123
}

pkg/gateway/fabric/geneve/internalnode_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"sigs.k8s.io/controller-runtime/pkg/client"
2929

3030
networkingv1beta1 "github.com/liqotech/liqo/apis/networking/v1beta1"
31+
"github.com/liqotech/liqo/pkg/consts"
3132
"github.com/liqotech/liqo/pkg/gateway/fabric"
3233
"github.com/liqotech/liqo/pkg/utils/network/geneve"
3334
)
@@ -116,7 +117,7 @@ func (r *InternalNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request
116117

117118
// SetupWithManager register the InternalNodeReconciler to the manager.
118119
func (r *InternalNodeReconciler) SetupWithManager(mgr ctrl.Manager) error {
119-
return ctrl.NewControllerManagedBy(mgr).
120+
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlInternalNodeGeneve).
120121
For(&networkingv1beta1.InternalNode{}).
121122
Complete(r)
122123
}

pkg/gateway/tunnel/wireguard/publickeys_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (r *PublicKeysReconciler) Reconcile(ctx context.Context, req ctrl.Request)
8888

8989
// SetupWithManager register the ConfigurationReconciler to the manager.
9090
func (r *PublicKeysReconciler) SetupWithManager(mgr ctrl.Manager, src <-chan event.GenericEvent) error {
91-
return ctrl.NewControllerManagedBy(mgr).
91+
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlPulicKeys).
9292
For(&networkingv1beta1.PublicKey{}, r.Predicates()).
9393
WatchesRawSource(NewDNSSource(src, NewDNSEventHandler(r.Client, r.Options))).
9494
Complete(r)

pkg/liqo-controller-manager/authentication/identity-controller/identity_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2929

3030
authv1beta1 "github.com/liqotech/liqo/apis/authentication/v1beta1"
31+
"github.com/liqotech/liqo/pkg/consts"
3132
"github.com/liqotech/liqo/pkg/liqo-controller-manager/authentication"
3233
"github.com/liqotech/liqo/pkg/liqo-controller-manager/authentication/forge"
3334
)
@@ -88,7 +89,7 @@ func (r *IdentityReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
8889

8990
// SetupWithManager sets up the controller with the Manager.
9091
func (r *IdentityReconciler) SetupWithManager(mgr ctrl.Manager) error {
91-
return ctrl.NewControllerManagedBy(mgr).
92+
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlIdentity).
9293
For(&authv1beta1.Identity{}).
9394
Owns(&corev1.Secret{}).
9495
Complete(r)

0 commit comments

Comments
 (0)