Skip to content

Commit a733ff0

Browse files
committed
Fix logic to init
Signed-off-by: lubronzhan <[email protected]>
1 parent a144a13 commit a733ff0

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pkg/provider/provider.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,19 @@ func newKubeVipCloudProvider(io.Reader) (cloudprovider.Interface, error) {
6969
ns = KubeVipClientConfigNamespace
7070
}
7171

72-
enableLBClass, err := strconv.ParseBool(lbc)
73-
if err != nil {
74-
return nil, fmt.Errorf("error creating kubernetes client config: %s", err.Error())
72+
var (
73+
enableLBClass bool
74+
err error
75+
)
76+
77+
if len(lbc) > 0 {
78+
klog.Infof("Checking if loadbalancerClass is enabled: %s", lbc)
79+
enableLBClass, err = strconv.ParseBool(lbc)
80+
if err != nil {
81+
return nil, fmt.Errorf("error parsing value of %s: %s", EnableLoadbalancerClassEnvKey, err.Error())
82+
}
7583
}
84+
klog.Infof("staring with loadbalancerClass set to: %t", enableLBClass)
7685

7786
klog.Infof("Watching configMap for pool config with name: '%s', namespace: '%s'", cm, ns)
7887

@@ -117,7 +126,8 @@ func (p *KubeVipCloudProvider) Initialize(clientBuilder cloudprovider.Controller
117126
sharedInformer := informers.NewSharedInformerFactory(clientset, 0)
118127

119128
if p.enableLBClass {
120-
klog.V(0).Info("staring controllers to enable service controller that only monitors service with loadbalancerClass")
129+
klog.V(0).Info("staring a seperate service controller that only monitors service with loadbalancerClass")
130+
klog.V(0).Info("default cloud-provider service controller will ignore service with loadbalancerClass")
121131
controller := newLoadbalancerClassServiceController(sharedInformer, p.kubeClient, p.configMapName, p.namespace)
122132
go controller.Run(context.Background().Done())
123133
}

0 commit comments

Comments
 (0)