diff --git a/go.sum b/go.sum index 3fb5ad9d4b..06ff971ec2 100644 --- a/go.sum +++ b/go.sum @@ -165,8 +165,6 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk= github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA= -github.com/cheina97/virtual-kubelet v0.0.0-20241002172638-3284d0c838d6 h1:d4V8APh9MbxiPJhUh/m3qBeH0rm6a8oKtpFQtQUQsE8= -github.com/cheina97/virtual-kubelet v0.0.0-20241002172638-3284d0c838d6/go.mod h1:S2OyZEAA49O7sBmxt4Fl06F1AT6wCWUpRLH6ZwNntC4= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= diff --git a/pkg/liqo-controller-manager/authentication/localresourceslice-controller/localresourceslice_controller.go b/pkg/liqo-controller-manager/authentication/localresourceslice-controller/localresourceslice_controller.go index 9fe4fca6d0..be80e3547f 100644 --- a/pkg/liqo-controller-manager/authentication/localresourceslice-controller/localresourceslice_controller.go +++ b/pkg/liqo-controller-manager/authentication/localresourceslice-controller/localresourceslice_controller.go @@ -36,6 +36,9 @@ import ( tenantnamespace "github.com/liqotech/liqo/pkg/tenantNamespace" ) +// ControllerName is the name of the controller. +const ControllerName = "localResourceSlice" + // NewLocalResourceSliceReconciler returns a new LocalResourceSliceReconciler. func NewLocalResourceSliceReconciler(cl client.Client, s *runtime.Scheme, recorder record.EventRecorder, liqoNamespace string, @@ -150,7 +153,7 @@ func (r *LocalResourceSliceReconciler) SetupWithManager(mgr ctrl.Manager) error return err } - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(ControllerName). For(&authv1beta1.ResourceSlice{}, builder.WithPredicates(localResSliceFilter)). Complete(r) } diff --git a/pkg/liqo-controller-manager/authentication/noncesigner-controller/noncesigner_controller.go b/pkg/liqo-controller-manager/authentication/noncesigner-controller/noncesigner_controller.go index ceb22ac535..fb0e4da2ac 100644 --- a/pkg/liqo-controller-manager/authentication/noncesigner-controller/noncesigner_controller.go +++ b/pkg/liqo-controller-manager/authentication/noncesigner-controller/noncesigner_controller.go @@ -37,6 +37,11 @@ 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, @@ -148,7 +153,7 @@ func (r *NonceSignerReconciler) SetupWithManager(mgr ctrl.Manager) error { return selector.Matches(labels.Set(o.GetLabels())) }) - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(ControllerName). For(&corev1.Secret{}, builder.WithPredicates(filter)). Complete(r) } diff --git a/pkg/liqo-controller-manager/authentication/remoteresourceslice-controller/remoteresourceslice_controller.go b/pkg/liqo-controller-manager/authentication/remoteresourceslice-controller/remoteresourceslice_controller.go index feb4096009..39da5f318e 100644 --- a/pkg/liqo-controller-manager/authentication/remoteresourceslice-controller/remoteresourceslice_controller.go +++ b/pkg/liqo-controller-manager/authentication/remoteresourceslice-controller/remoteresourceslice_controller.go @@ -42,6 +42,9 @@ import ( liqolabels "github.com/liqotech/liqo/pkg/utils/labels" ) +// ControllerName is the name of the controller. +const ControllerName = "remoteResourceSlice" + // NewRemoteResourceSliceReconciler returns a new RemoteResourceSliceReconciler. func NewRemoteResourceSliceReconciler(cl client.Client, s *runtime.Scheme, config *rest.Config, recorder record.EventRecorder, @@ -254,7 +257,7 @@ func (r *RemoteResourceSliceReconciler) SetupWithManager(mgr ctrl.Manager) error return err } - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(ControllerName). For(&authv1beta1.ResourceSlice{}, builder.WithPredicates(predicate.And(remoteResSliceFilter, withCSR()))). Watches(&authv1beta1.Tenant{}, handler.EnqueueRequestsFromMapFunc(r.resourceSlicesEnquer())). Complete(r) diff --git a/pkg/liqo-controller-manager/ipmapping/configuration_controller.go b/pkg/liqo-controller-manager/ipmapping/configuration_controller.go index b77163196e..6ecf942a61 100644 --- a/pkg/liqo-controller-manager/ipmapping/configuration_controller.go +++ b/pkg/liqo-controller-manager/ipmapping/configuration_controller.go @@ -36,6 +36,9 @@ 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 @@ -95,7 +98,7 @@ func (r *ConfigurationReconciler) SetupWithManager(mgr ctrl.Manager) error { if err != nil { return err } - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(ConfigurationControllerName). For(&networkingv1beta1.Configuration{}, builder.WithPredicates(filterByLabelsPredicate)). Complete(r) } diff --git a/pkg/liqo-controller-manager/ipmapping/pod_controller.go b/pkg/liqo-controller-manager/ipmapping/pod_controller.go index a76494e674..57a111f245 100644 --- a/pkg/liqo-controller-manager/ipmapping/pod_controller.go +++ b/pkg/liqo-controller-manager/ipmapping/pod_controller.go @@ -33,6 +33,11 @@ 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 @@ -88,7 +93,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). + return ctrl.NewControllerManagedBy(mgr).Named(PodControllerName). For(&corev1.Pod{}, builder.WithPredicates(p)). Complete(r) } diff --git a/pkg/liqo-controller-manager/networking/external-network/remapping/configuration_controller.go b/pkg/liqo-controller-manager/networking/external-network/remapping/configuration_controller.go index a4ba445175..590c599663 100644 --- a/pkg/liqo-controller-manager/networking/external-network/remapping/configuration_controller.go +++ b/pkg/liqo-controller-manager/networking/external-network/remapping/configuration_controller.go @@ -48,6 +48,9 @@ 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() @@ -101,7 +104,7 @@ func (r *RemappingReconciler) SetupWithManager(mgr ctrl.Manager) error { if err != nil { return err } - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(ConfigurationControllerName). For(&networkingv1beta1.Configuration{}, builder.WithPredicates(filterByLabelsPredicate)). Complete(r) } diff --git a/pkg/liqo-controller-manager/networking/external-network/remapping/ip_controller.go b/pkg/liqo-controller-manager/networking/external-network/remapping/ip_controller.go index 8da4bbc79e..dafc93e851 100644 --- a/pkg/liqo-controller-manager/networking/external-network/remapping/ip_controller.go +++ b/pkg/liqo-controller-manager/networking/external-network/remapping/ip_controller.go @@ -32,6 +32,11 @@ 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 @@ -86,7 +91,7 @@ func (r *IPReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Re return ctrl.Result{}, nil } - if ip.Status.IPMappings == nil || len(ip.Status.IPMappings) == 0 { + if len(ip.Status.IPMappings) == 0 { klog.Warningf("IP %s has no IP mappings yet", req.String()) return ctrl.Result{}, nil } @@ -108,7 +113,7 @@ func (r *IPReconciler) SetupWithManager(mgr ctrl.Manager) error { if err != nil { return err } - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(IPControllerName). For(&ipamv1alpha1.IP{}, builder.WithPredicates(predicate.Not(filterByLabelsPredicate))). Complete(r) } diff --git a/pkg/liqo-controller-manager/networking/external-network/route/configuration_controller.go b/pkg/liqo-controller-manager/networking/external-network/route/configuration_controller.go index a4c07c368c..5badc6d90a 100644 --- a/pkg/liqo-controller-manager/networking/external-network/route/configuration_controller.go +++ b/pkg/liqo-controller-manager/networking/external-network/route/configuration_controller.go @@ -36,6 +36,9 @@ import ( "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 @@ -90,7 +93,7 @@ func (r *ConfigurationReconciler) SetupWithManager(mgr ctrl.Manager) error { if err != nil { return err } - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(ControllerName). For(&networkingv1beta1.Configuration{}, builder.WithPredicates(p)). Watches( &networkingv1beta1.GatewayServer{}, diff --git a/pkg/liqo-controller-manager/networking/internal-network/client-controller/client_controller.go b/pkg/liqo-controller-manager/networking/internal-network/client-controller/client_controller.go index 322c33158b..7784e7d953 100644 --- a/pkg/liqo-controller-manager/networking/internal-network/client-controller/client_controller.go +++ b/pkg/liqo-controller-manager/networking/internal-network/client-controller/client_controller.go @@ -35,6 +35,11 @@ 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 @@ -143,7 +148,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). + return ctrl.NewControllerManagedBy(mgr).Named(ControllerName). Owns(&networkingv1beta1.InternalFabric{}). For(&networkingv1beta1.GatewayClient{}). Complete(r) diff --git a/pkg/liqo-controller-manager/networking/internal-network/configuration-controller/configuration_controller.go b/pkg/liqo-controller-manager/networking/internal-network/configuration-controller/configuration_controller.go index d7cb36c274..2822896e98 100644 --- a/pkg/liqo-controller-manager/networking/internal-network/configuration-controller/configuration_controller.go +++ b/pkg/liqo-controller-manager/networking/internal-network/configuration-controller/configuration_controller.go @@ -30,6 +30,9 @@ import ( configuration "github.com/liqotech/liqo/pkg/liqo-controller-manager/networking/external-network/configuration" ) +// ControllerName is the name of the controller. +const ControllerName = "internalConfiguration" + // ConfigurationReconciler manage Configuration lifecycle. type ConfigurationReconciler struct { client.Client @@ -88,7 +91,7 @@ func (r *ConfigurationReconciler) SetupWithManager(mgr ctrl.Manager) error { return err } - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(ControllerName). For(&networkingv1beta1.Configuration{}, builder.WithPredicates(p)). Complete(r) } diff --git a/pkg/liqo-controller-manager/networking/internal-network/server-controller/server_controller.go b/pkg/liqo-controller-manager/networking/internal-network/server-controller/server_controller.go index 881bbaceff..0cc9515288 100644 --- a/pkg/liqo-controller-manager/networking/internal-network/server-controller/server_controller.go +++ b/pkg/liqo-controller-manager/networking/internal-network/server-controller/server_controller.go @@ -35,6 +35,11 @@ import ( "github.com/liqotech/liqo/pkg/utils/getters" ) +const ( + // ControllerName is the name of the controller. + ControllerName = "internalServer" +) + // ServerReconciler manage GatewayServer lifecycle. type ServerReconciler struct { client.Client @@ -144,7 +149,7 @@ func (r *ServerReconciler) ensureInternalFabric(ctx context.Context, gwServer *n // SetupWithManager register the ServerReconciler to the manager. func (r *ServerReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(ControllerName). Owns(&networkingv1beta1.InternalFabric{}). For(&networkingv1beta1.GatewayServer{}). Complete(r) diff --git a/pkg/liqo-controller-manager/offloading/podstatus-controller/podstatus_controller.go b/pkg/liqo-controller-manager/offloading/podstatus-controller/podstatus_controller.go index 1dc1cbd4a4..e0b5df9068 100644 --- a/pkg/liqo-controller-manager/offloading/podstatus-controller/podstatus_controller.go +++ b/pkg/liqo-controller-manager/offloading/podstatus-controller/podstatus_controller.go @@ -29,6 +29,11 @@ import ( "github.com/liqotech/liqo/pkg/utils/indexer" ) +const ( + // ControllerName is the name of the controller. + ControllerName = "podStatus" +) + // HasRemoteUnavailableLabel return true if the pod has the remote unavailable label. func HasRemoteUnavailableLabel(pod *corev1.Pod) bool { value, ok := pod.Labels[consts.RemoteUnavailableKey] @@ -110,7 +115,7 @@ func (r *PodStatusReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( // SetupWithManager monitors updates on nodes. func (r *PodStatusReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(ControllerName). For(&corev1.Node{}). Complete(r) } diff --git a/pkg/liqo-controller-manager/quotacreator-controller/quotacreator_controller.go b/pkg/liqo-controller-manager/quotacreator-controller/quotacreator_controller.go index f50c29e3cd..a841604ab4 100644 --- a/pkg/liqo-controller-manager/quotacreator-controller/quotacreator_controller.go +++ b/pkg/liqo-controller-manager/quotacreator-controller/quotacreator_controller.go @@ -37,6 +37,11 @@ import ( "github.com/liqotech/liqo/pkg/liqo-controller-manager/authentication" ) +const ( + // ControllerName is the name of the controller. + ControllerName = "quotaCreator" +) + // QuotaCreatorReconciler manage Quota lifecycle. type QuotaCreatorReconciler struct { client.Client @@ -136,7 +141,7 @@ func (r *QuotaCreatorReconciler) SetupWithManager(mgr ctrl.Manager) error { klog.Error(err) return err } - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(ControllerName). For(&authv1beta1.ResourceSlice{}, builder.WithPredicates(remoteResSliceFilter)). Owns(&offloadingv1beta1.Quota{}). diff --git a/pkg/liqo-controller-manager/virtualnodecreator-controller/virtualnodecreator_controller.go b/pkg/liqo-controller-manager/virtualnodecreator-controller/virtualnodecreator_controller.go index d7b7f155e0..09c47132c4 100644 --- a/pkg/liqo-controller-manager/virtualnodecreator-controller/virtualnodecreator_controller.go +++ b/pkg/liqo-controller-manager/virtualnodecreator-controller/virtualnodecreator_controller.go @@ -39,6 +39,11 @@ import ( "github.com/liqotech/liqo/pkg/utils/getters" ) +const ( + // ControllerName is the name of the controller. + ControllerName = "virtualNodeCreator" +) + // VirtualNodeCreatorReconciler create virtualnodes from resourceslice resources. type VirtualNodeCreatorReconciler struct { client.Client @@ -144,7 +149,7 @@ func (r *VirtualNodeCreatorReconciler) SetupWithManager(mgr ctrl.Manager) error klog.Error(err) return err } - return ctrl.NewControllerManagedBy(mgr). + return ctrl.NewControllerManagedBy(mgr).Named(ControllerName). For(&authv1beta1.ResourceSlice{}, builder.WithPredicates(predicate.And(localResSliceFilter, withConditionsAccepeted()))). Owns(&offloadingv1beta1.VirtualNode{}). Owns(&authv1beta1.Identity{}).