Skip to content

Commit

Permalink
Added controller name for external-configuration-controller
Browse files Browse the repository at this point in the history
  • Loading branch information
cheina97 committed Oct 4, 2024
1 parent 6d34287 commit 6d15db4
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 17 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/liqo-controller-manager/ipmapping/pod_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{}).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{}).
Expand Down

0 comments on commit 6d15db4

Please sign in to comment.