@@ -3,9 +3,7 @@ package ionos
33import (
44 "context"
55 "errors"
6- "math/rand"
76 "strings"
8- "time"
97
108 v1 "k8s.io/api/core/v1"
119 cloudprovider "k8s.io/cloud-provider"
@@ -36,7 +34,7 @@ func (l loadbalancer) AddClient(datacenterId string, token []byte) error {
3634// For the given LB service, the GetLoadBalancer must return "exists=True" if
3735// there exists a LoadBalancer instance created by ServiceController.
3836// In all other cases, GetLoadBalancer must return a NotFound error.
39- func (l loadbalancer ) GetLoadBalancer (ctx context.Context , clusterName string , service * v1.Service ) (status * v1.LoadBalancerStatus , exists bool , err error ) {
37+ func (l loadbalancer ) GetLoadBalancer (ctx context.Context , _ string , service * v1.Service ) (status * v1.LoadBalancerStatus , exists bool , err error ) {
4038 klog .Infof ("getLoadBalancer (service %s/%s)" , service .Namespace , service .Name )
4139
4240 server , err := l .ServerWithLoadBalancer (ctx , service .Spec .LoadBalancerIP )
@@ -53,7 +51,7 @@ func (l loadbalancer) GetLoadBalancer(ctx context.Context, clusterName string, s
5351
5452// GetLoadBalancerName returns the name of the load balancer. Implementations must treat the
5553// *v1.Service parameter as read-only and not modify it.
56- func (l loadbalancer ) GetLoadBalancerName (ctx context.Context , clusterName string , service * v1.Service ) string {
54+ func (l loadbalancer ) GetLoadBalancerName (_ context.Context , _ string , service * v1.Service ) string {
5755 return cloudprovider .DefaultLoadBalancerName (service )
5856}
5957
@@ -90,7 +88,7 @@ func (l loadbalancer) UpdateLoadBalancer(ctx context.Context, clusterName string
9088// Parameter 'clusterName' is the name of the cluster as presented to kube-controller-manager
9189// EnsureLoadBalancerDeleted must not return ImplementedElsewhere to ensure
9290// proper teardown of resources that were allocated by the ServiceController.
93- func (l loadbalancer ) EnsureLoadBalancerDeleted (ctx context.Context , clusterName string , service * v1.Service ) error {
91+ func (l loadbalancer ) EnsureLoadBalancerDeleted (ctx context.Context , _ string , service * v1.Service ) error {
9492 klog .Infof ("ensureLoadBalancerDeleted (service %s/%s)" , service .Namespace , service .Name )
9593
9694 if len (service .Status .LoadBalancer .Ingress ) > 0 {
@@ -130,7 +128,7 @@ func (l loadbalancer) deleteLoadBalancerFromNode(ctx context.Context, loadBalanc
130128 return nil
131129}
132130
133- func (l loadbalancer ) syncLoadBalancer (ctx context.Context , clusterName string , service * v1.Service , nodes []* v1.Node ) (* v1.LoadBalancerStatus , error ) {
131+ func (l loadbalancer ) syncLoadBalancer (ctx context.Context , _ string , service * v1.Service , nodes []* v1.Node ) (* v1.LoadBalancerStatus , error ) {
134132 klog .Infof ("syncLoadBalancer (service %s/%s, nodes %s)" , service .Namespace , service .Name , nodes )
135133
136134 if len (service .Status .LoadBalancer .Ingress ) > 0 && service .Status .LoadBalancer .Ingress [0 ].IP != service .Spec .LoadBalancerIP {
@@ -192,7 +190,7 @@ func (l loadbalancer) syncLoadBalancer(ctx context.Context, clusterName string,
192190 }
193191 }
194192
195- klog .Infof ("Could not attach ip %s to any node" , service .Spec .LoadBalancerIP )
193+ klog .Infof ("could not attach ip %s to any node" , service .Spec .LoadBalancerIP )
196194 return nil , nil
197195}
198196
@@ -215,8 +213,7 @@ func (l loadbalancer) GetLoadBalancerNode(nodes []*v1.Node) *v1.Node {
215213 if candidates == nil && len (candidates ) == 0 {
216214 return nil
217215 }
218- rand .Seed (time .Now ().UnixNano ())
219- randomIndex := rand .Intn (len (candidates ))
216+ randomIndex := l .r .Intn (len (candidates ))
220217 return candidates [randomIndex ]
221218}
222219
0 commit comments