Skip to content

Commit

Permalink
fixup! fix: added unique names to all controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
fra98 committed Oct 14, 2024
1 parent bd75084 commit d140a49
Show file tree
Hide file tree
Showing 39 changed files with 96 additions and 92 deletions.
44 changes: 41 additions & 3 deletions pkg/consts/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,56 @@ package consts
// with the prefix "Ctrl".
const (
// Core.
CtrlForeignCluster = "foreigncluster"
CtrlSecretsCRDReplicator = "secrets_crdreplicator"

// Networking.
CtrlInternalFabricsFabric = "internalfabrics_fabric"
CtrlInternalFabricsCM = "internalfabrics_cm"
CtrlConfigurationExternal = "configuration_external"
CtrlConfigurationInternal = "configuration_internal"
CtrlConfigurationIPMapping = "configuration_ipmapping"
CtrlConfigurationRemapping = "configuration_remapping"
CtrlConfigurationRoute = "configuration_route"
CtrlConnections = "connections"
CtrlFirewallConfiguration = "firewallconfiguration"
CtrlGatewayClientExternal = "gatewayclient_external"
CtrlGatewayClientInternal = "gatewayclient_internal"
CtrlGatewayServerExternal = "gatewayserver_external"
CtrlGatewayServerInternal = "gatewayserver_internal"
CtrlInternalFabricsCM = "internalfabrics_cm"
CtrlInternalFabricsFabric = "internalfabrics_fabric"
CtrlInternalNodeGeneve = "internalnode_geneve"
CtrlInternalNodeRoute = "internalnode_route"
CtrlIP = "ip"
CtrlIPRemapping = "ip_remapping"
CtrlNetwork = "network"
CtrlNode = "node"
CtrlPodGateway = "pod_gateway"
CtrlPodGwMasq = "pod_gw_masq"
CtrlPodInternalNet = "pod_internalnet"
CtrlPodIPMapping = "pod_ipmapping"
CtrlPulicKeys = "publickeys"
CtrlRouteConfiguration = "routeconfiguration"
CtrlWGGatewayClient = "wggatewayclient"
CtrlWGGatewayServer = "wggatewayserver"

// Authentication.
CtrlIdentity = "identity"
CtrlIdentityCreator = "identity_creator"
CtrlNonceCreator = "nonce_creator"
CtrlNonceSigner = "nonce_signer"
CtrlResourceSlicesLocal = "resourceslices_local"
CtrlResourceSlicesRemote = "resourceslices_remote"
CtrlTenant = "tenant"

// Offloading.
CtrlShadowPods = "shadowpods"
CtrlNamespaceMap = "namespace_map"
CtrlNamespaceOffloading = "namespaceoffloading"
CtrlNodeFailure = "node_failure"
CtrlPodStatus = "pod_status"
CtrlShadowEndpointSlice = "shadowendpointslice"
CtrlShadowPods = "shadowpods"
CtrlVirtualNode = "virtualnode"
CtrlVirtualNodeCreator = "virtualnode_creator"

// Cross modules.
CtrlResourceSlicesQuotaCreator = "resourceslices_quotacreator"
Expand Down
3 changes: 2 additions & 1 deletion pkg/fabric/source-detector/gateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"

networkingv1beta1 "github.com/liqotech/liqo/apis/networking/v1beta1"
"github.com/liqotech/liqo/pkg/consts"
"github.com/liqotech/liqo/pkg/fabric"
"github.com/liqotech/liqo/pkg/gateway"
)
Expand Down Expand Up @@ -115,7 +116,7 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error {
return err
}

return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlPodGateway).
For(&corev1.Pod{}, builder.WithPredicates(filterByLabelsGatewayPods)).
Complete(r)
}
3 changes: 2 additions & 1 deletion pkg/firewall/firewallconfiguration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"

networkingv1beta1 "github.com/liqotech/liqo/apis/networking/v1beta1"
"github.com/liqotech/liqo/pkg/consts"
"github.com/liqotech/liqo/pkg/utils/network/netmonitor"
)

Expand Down Expand Up @@ -172,7 +173,7 @@ func (r *FirewallConfigurationReconciler) SetupWithManager(ctx context.Context,
go func() {
utilruntime.Must(netmonitor.InterfacesMonitoring(ctx, src, &netmonitor.Options{Nftables: &netmonitor.OptionsNftables{Delete: true}}))
}()
return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlFirewallConfiguration).
For(&networkingv1beta1.FirewallConfiguration{}, builder.WithPredicates(filterByLabelsPredicate)).
WatchesRawSource(NewFirewallWatchSource(src, NewFirewallWatchEventHandler(r.Client, r.LabelsSets))).
Complete(r)
Expand Down
2 changes: 1 addition & 1 deletion pkg/gateway/connection/connections_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (r *ConnectionsReconciler) SetupWithManager(mgr ctrl.Manager) error {
if err != nil {
return err
}
return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlConnections).
For(&networkingv1beta1.Connection{}, builder.WithPredicates(filterByLabelsPredicate)).
Complete(r)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/gateway/fabric/geneve/internalnode_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

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

// SetupWithManager register the InternalNodeReconciler to the manager.
func (r *InternalNodeReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlInternalNodeGeneve).
For(&networkingv1beta1.InternalNode{}).
Complete(r)
}
2 changes: 1 addition & 1 deletion pkg/gateway/tunnel/wireguard/publickeys_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (r *PublicKeysReconciler) Reconcile(ctx context.Context, req ctrl.Request)

// SetupWithManager register the ConfigurationReconciler to the manager.
func (r *PublicKeysReconciler) SetupWithManager(mgr ctrl.Manager, src <-chan event.GenericEvent) error {
return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlPulicKeys).
For(&networkingv1beta1.PublicKey{}, r.Predicates()).
WatchesRawSource(NewDNSSource(src, NewDNSEventHandler(r.Client, r.Options))).
Complete(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

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

// SetupWithManager sets up the controller with the Manager.
func (r *IdentityReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlIdentity).
For(&authv1beta1.Identity{}).
Owns(&corev1.Secret{}).
Complete(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (r *IdentityCreatorReconciler) SetupWithManager(mgr ctrl.Manager) error {
return err
}

return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlIdentityCreator).
For(&authv1beta1.ResourceSlice{}, builder.WithPredicates(predicate.And(localResSliceFilter, withAuthCondition()))).
Owns(&authv1beta1.Identity{}).
Complete(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (r *NonceCreatorReconciler) SetupWithManager(mgr ctrl.Manager) error {
return selector.Matches(labels.Set(o.GetLabels()))
})

return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlNonceCreator).
For(&corev1.Secret{}, builder.WithPredicates(filter)).
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ import (
"github.com/liqotech/liqo/pkg/utils"
)

const (
// ControllerName is the name of the controller.
ControllerName = "nonceSigner"
)

// NewNonceSignerReconciler returns a new SecretReconciler.
func NewNonceSignerReconciler(cl client.Client, s *runtime.Scheme,
recorder record.EventRecorder,
Expand Down Expand Up @@ -153,7 +148,7 @@ func (r *NonceSignerReconciler) SetupWithManager(mgr ctrl.Manager) error {
return selector.Matches(labels.Set(o.GetLabels()))
})

return ctrl.NewControllerManagedBy(mgr).Named(ControllerName).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlNonceSigner).
For(&corev1.Secret{}, builder.WithPredicates(filter)).
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (r *TenantReconciler) ensureSetup(ctx context.Context) error {

// SetupWithManager sets up the TenantReconciler with the Manager.
func (r *TenantReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlTenant).
For(&authv1beta1.Tenant{}).
Owns(&corev1.Namespace{}).
Complete(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (r *ForeignClusterReconciler) SetupWithManager(mgr ctrl.Manager, workers in
return err
}

return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlForeignCluster).
For(&liqov1beta1.ForeignCluster{}, builder.WithPredicates(foreignClusterPredicate)).
Watches(&networkingv1beta1.Connection{}, handler.EnqueueRequestsFromMapFunc(r.foreignclusterEnqueuer)).
Watches(&networkingv1beta1.GatewayServer{}, handler.EnqueueRequestsFromMapFunc(r.foreignclusterEnqueuer)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ import (
configuration "github.com/liqotech/liqo/pkg/liqo-controller-manager/networking/external-network/configuration"
)

// ConfigurationControllerName is the name of the controller.
const ConfigurationControllerName = "IpMappingConfiguration"

// cluster-role
// +kubebuilder:rbac:groups=networking.liqo.io,resources=configurations,verbs=get;list;watch
// +kubebuilder:rbac:groups=ipam.liqo.io,resources=ips,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -98,7 +95,7 @@ func (r *ConfigurationReconciler) SetupWithManager(mgr ctrl.Manager) error {
if err != nil {
return err
}
return ctrl.NewControllerManagedBy(mgr).Named(ConfigurationControllerName).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlConfigurationIPMapping).
For(&networkingv1beta1.Configuration{}, builder.WithPredicates(filterByLabelsPredicate)).
Complete(r)
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/liqo-controller-manager/ipmapping/pod_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ import (
"github.com/liqotech/liqo/pkg/consts"
)

const (
// PodControllerName is the name of the controller.
PodControllerName = "IPMappingPod"
)

// OffloadedPodReconciler manage offloaded pods lifecycle.
type OffloadedPodReconciler struct {
client.Client
Expand Down Expand Up @@ -93,7 +88,7 @@ func (r *OffloadedPodReconciler) SetupWithManager(mgr ctrl.Manager) error {
if err != nil {
return fmt.Errorf("unable to create predicate: %w", err)
}
return ctrl.NewControllerManagedBy(mgr).Named(PodControllerName).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlPodIPMapping).
For(&corev1.Pod{}, builder.WithPredicates(p)).
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (r *ClientReconciler) SetupWithManager(mgr ctrl.Manager) error {
factorySource.ForResource(gvr)
}

return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlGatewayClientExternal).
WatchesRawSource(factorySource.Source(ownerEnqueuer)).
For(&networkingv1beta1.GatewayClient{}).
Complete(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func isConfigurationConfigured(cfg *networkingv1beta1.Configuration) bool {

// SetupWithManager register the ConfigurationReconciler to the manager.
func (r *ConfigurationReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlConfigurationExternal).
For(&networkingv1beta1.Configuration{}).
Owns(&ipamv1alpha1.Network{}).
Complete(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"

networkingv1beta1 "github.com/liqotech/liqo/apis/networking/v1beta1"
"github.com/liqotech/liqo/pkg/consts"
configuration "github.com/liqotech/liqo/pkg/liqo-controller-manager/networking/external-network/configuration"
)

Expand All @@ -48,9 +49,6 @@ type RemappingReconciler struct {
Options *Options
}

// ConfigurationControllerName is the name of the controller.
const ConfigurationControllerName = "configurationRemapping"

// NewRemappingReconciler returns a new PublicKeysReconciler.
func NewRemappingReconciler(cl client.Client, s *runtime.Scheme, er record.EventRecorder) (*RemappingReconciler, error) {
opts, err := NewOptions()
Expand Down Expand Up @@ -104,7 +102,7 @@ func (r *RemappingReconciler) SetupWithManager(mgr ctrl.Manager) error {
if err != nil {
return err
}
return ctrl.NewControllerManagedBy(mgr).Named(ConfigurationControllerName).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlConfigurationRemapping).
For(&networkingv1beta1.Configuration{}, builder.WithPredicates(filterByLabelsPredicate)).
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ import (
"github.com/liqotech/liqo/pkg/consts"
)

const (
// IPControllerName is the name of the controller.
IPControllerName = "ipMapping"
)

// IPReconciler manage IP.
type IPReconciler struct {
client.Client
Expand Down Expand Up @@ -113,7 +108,7 @@ func (r *IPReconciler) SetupWithManager(mgr ctrl.Manager) error {
if err != nil {
return err
}
return ctrl.NewControllerManagedBy(mgr).Named(IPControllerName).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlIPRemapping).
For(&ipamv1alpha1.IP{}, builder.WithPredicates(predicate.Not(filterByLabelsPredicate))).
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

networkingv1beta1 "github.com/liqotech/liqo/apis/networking/v1beta1"
"github.com/liqotech/liqo/pkg/consts"
configuration "github.com/liqotech/liqo/pkg/liqo-controller-manager/networking/external-network/configuration"
"github.com/liqotech/liqo/pkg/utils"
"github.com/liqotech/liqo/pkg/utils/getters"
)

// ControllerName is the name of the controller.
const ControllerName = "externalConfiguration"

// ConfigurationReconciler manage Configuration.
type ConfigurationReconciler struct {
client.Client
Expand Down Expand Up @@ -93,7 +91,7 @@ func (r *ConfigurationReconciler) SetupWithManager(mgr ctrl.Manager) error {
if err != nil {
return err
}
return ctrl.NewControllerManagedBy(mgr).Named(ControllerName).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlConfigurationRoute).
For(&networkingv1beta1.Configuration{}, builder.WithPredicates(p)).
Watches(
&networkingv1beta1.GatewayServer{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (r *ServerReconciler) SetupWithManager(mgr ctrl.Manager) error {
factorySource.ForResource(gvr)
}

return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlGatewayServerExternal).
WatchesRawSource(factorySource.Source(ownerEnqueuer)).
For(&networkingv1beta1.GatewayServer{}).
Complete(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (r *WgGatewayClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ

// SetupWithManager register the WgGatewayClientReconciler to the manager.
func (r *WgGatewayClientReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlWGGatewayClient).
For(&networkingv1beta1.WgGatewayClient{}).
Owns(&appsv1.Deployment{}).
Owns(&corev1.ServiceAccount{}).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (r *WgGatewayServerReconciler) Reconcile(ctx context.Context, req ctrl.Requ

// SetupWithManager register the WgGatewayServerReconciler to the manager.
func (r *WgGatewayServerReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlWGGatewayServer).
For(&networkingv1beta1.WgGatewayServer{}).
Owns(&appsv1.Deployment{}).
Owns(&corev1.Service{}).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ import (
"github.com/liqotech/liqo/pkg/utils/getters"
)

const (
// ControllerName is the name of the controller.
ControllerName = "internalClient"
)

// ClientReconciler manage GatewayClient lifecycle.
type ClientReconciler struct {
client.Client
Expand Down Expand Up @@ -148,7 +143,7 @@ func (r *ClientReconciler) ensureInternalFabric(ctx context.Context, gwClient *n

// SetupWithManager register the ClientReconciler to the manager.
func (r *ClientReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).Named(ControllerName).
return ctrl.NewControllerManagedBy(mgr).Named(consts.CtrlGatewayClientInternal).
Owns(&networkingv1beta1.InternalFabric{}).
For(&networkingv1beta1.GatewayClient{}).
Complete(r)
Expand Down
Loading

0 comments on commit d140a49

Please sign in to comment.