@@ -43,19 +43,20 @@ func newLoadBalancer(kubeClient kubernetes.Interface, ns, cm string) cloudprovid
43
43
return k
44
44
}
45
45
46
- func (k * kubevipLoadBalancerManager ) EnsureLoadBalancer (ctx context.Context , clusterName string , service * v1.Service , nodes []* v1.Node ) (lbs * v1.LoadBalancerStatus , err error ) {
46
+ func (k * kubevipLoadBalancerManager ) EnsureLoadBalancer (ctx context.Context , _ string , service * v1.Service , _ []* v1.Node ) (lbs * v1.LoadBalancerStatus , err error ) {
47
47
return k .syncLoadBalancer (ctx , service )
48
48
}
49
- func (k * kubevipLoadBalancerManager ) UpdateLoadBalancer (ctx context.Context , clusterName string , service * v1.Service , nodes []* v1.Node ) (err error ) {
49
+
50
+ func (k * kubevipLoadBalancerManager ) UpdateLoadBalancer (ctx context.Context , _ string , service * v1.Service , _ []* v1.Node ) (err error ) {
50
51
_ , err = k .syncLoadBalancer (ctx , service )
51
52
return err
52
53
}
53
54
54
- func (k * kubevipLoadBalancerManager ) EnsureLoadBalancerDeleted (ctx context.Context , clusterName string , service * v1.Service ) error {
55
+ func (k * kubevipLoadBalancerManager ) EnsureLoadBalancerDeleted (ctx context.Context , _ string , service * v1.Service ) error {
55
56
return k .deleteLoadBalancer (ctx , service )
56
57
}
57
58
58
- func (k * kubevipLoadBalancerManager ) GetLoadBalancer (ctx context.Context , clusterName string , service * v1.Service ) (status * v1.LoadBalancerStatus , exists bool , err error ) {
59
+ func (k * kubevipLoadBalancerManager ) GetLoadBalancer (_ context.Context , _ string , service * v1.Service ) (status * v1.LoadBalancerStatus , exists bool , err error ) {
59
60
if service .Labels [implementationLabelKey ] == implementationLabelValue {
60
61
return & service .Status .LoadBalancer , true , nil
61
62
}
@@ -64,7 +65,7 @@ func (k *kubevipLoadBalancerManager) GetLoadBalancer(ctx context.Context, cluste
64
65
65
66
// GetLoadBalancerName returns the name of the load balancer. Implementations must treat the
66
67
// *v1.Service parameter as read-only and not modify it.
67
- func (k * kubevipLoadBalancerManager ) GetLoadBalancerName (_ context.Context , clusterName string , service * v1.Service ) string {
68
+ func (k * kubevipLoadBalancerManager ) GetLoadBalancerName (_ context.Context , _ string , service * v1.Service ) string {
68
69
return getDefaultLoadBalancerName (service )
69
70
}
70
71
@@ -116,32 +117,32 @@ func (k *kubevipLoadBalancerManager) syncLoadBalancer(ctx context.Context, servi
116
117
}
117
118
}
118
119
return & service .Status .LoadBalancer , nil
119
- } else {
120
- if v , ok := service .Annotations [loadbalancerIPsAnnotations ]; ok && len (v ) != 0 {
121
- klog .Infof ("service '%s/%s' annotations '%s' is defined but service.Spec.LoadBalancerIP is not. Assume it's not legacy service" , service .Namespace , service .Name , loadbalancerIPsAnnotations )
122
- // Set Label for service lookups
123
- if service .Labels == nil || service .Labels [implementationLabelKey ] != implementationLabelValue {
124
- klog .Infof ("service '%s/%s' created with pre-defined ip '%s'" , service .Namespace , service .Name , v )
125
- err := retry .RetryOnConflict (retry .DefaultRetry , func () error {
126
- recentService , getErr := k .kubeClient .CoreV1 ().Services (service .Namespace ).Get (ctx , service .Name , metav1.GetOptions {})
127
- if getErr != nil {
128
- return getErr
129
- }
130
- if recentService .Labels == nil {
131
- // Just because ..
132
- recentService .Labels = make (map [string ]string )
133
- }
134
- recentService .Labels [implementationLabelKey ] = implementationLabelValue
135
- // Update the actual service with the annotations
136
- _ , updateErr := k .kubeClient .CoreV1 ().Services (recentService .Namespace ).Update (ctx , recentService , metav1.UpdateOptions {})
137
- return updateErr
138
- })
139
- if err != nil {
140
- return nil , fmt .Errorf ("error updating Service Spec [%s] : %v" , service .Name , err )
120
+ }
121
+
122
+ if v , ok := service .Annotations [loadbalancerIPsAnnotations ]; ok && len (v ) != 0 {
123
+ klog .Infof ("service '%s/%s' annotations '%s' is defined but service.Spec.LoadBalancerIP is not. Assume it's not legacy service" , service .Namespace , service .Name , loadbalancerIPsAnnotations )
124
+ // Set Label for service lookups
125
+ if service .Labels == nil || service .Labels [implementationLabelKey ] != implementationLabelValue {
126
+ klog .Infof ("service '%s/%s' created with pre-defined ip '%s'" , service .Namespace , service .Name , v )
127
+ err := retry .RetryOnConflict (retry .DefaultRetry , func () error {
128
+ recentService , getErr := k .kubeClient .CoreV1 ().Services (service .Namespace ).Get (ctx , service .Name , metav1.GetOptions {})
129
+ if getErr != nil {
130
+ return getErr
141
131
}
132
+ if recentService .Labels == nil {
133
+ // Just because ..
134
+ recentService .Labels = make (map [string ]string )
135
+ }
136
+ recentService .Labels [implementationLabelKey ] = implementationLabelValue
137
+ // Update the actual service with the annotations
138
+ _ , updateErr := k .kubeClient .CoreV1 ().Services (recentService .Namespace ).Update (ctx , recentService , metav1.UpdateOptions {})
139
+ return updateErr
140
+ })
141
+ if err != nil {
142
+ return nil , fmt .Errorf ("error updating Service Spec [%s] : %v" , service .Name , err )
142
143
}
143
- return & service .Status .LoadBalancer , nil
144
144
}
145
+ return & service .Status .LoadBalancer , nil
145
146
}
146
147
147
148
// Get the clound controller configuration map
@@ -157,7 +158,6 @@ func (k *kubevipLoadBalancerManager) syncLoadBalancer(ctx context.Context, servi
157
158
158
159
// Get ip pool from configmap and determine if it is namespace specific or global
159
160
pool , global , err := discoverPool (controllerCM , service .Namespace , k .cloudConfigMap )
160
-
161
161
if err != nil {
162
162
return nil , err
163
163
}
0 commit comments