Skip to content

Commit

Permalink
handle nil situation
Browse files Browse the repository at this point in the history
  • Loading branch information
zetaab committed Jun 23, 2019
1 parent 9cf0b45 commit 57baa72
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions upup/pkg/fi/cloudup/openstack/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,24 +419,26 @@ func NewOpenstackCloud(tags map[string]string, spec *kops.ClusterSpec) (Openstac
}
c.useOctavia = octavia
var lbClient *gophercloud.ServiceClient
if spec.CloudConfig.Openstack.Loadbalancer != nil && octavia {
klog.V(2).Infof("Openstack using Octavia lbaasv2 api")
lbClient, err = os.NewLoadBalancerV2(provider, gophercloud.EndpointOpts{
Region: region,
})
if err != nil {
return nil, fmt.Errorf("error building lb client: %v", err)
}
} else if spec.CloudConfig.Openstack.Loadbalancer != nil {
klog.V(2).Infof("Openstack using deprecated lbaasv2 api")
lbClient, err = os.NewNetworkV2(provider, gophercloud.EndpointOpts{
Region: region,
})
if err != nil {
return nil, fmt.Errorf("error building lb client: %v", err)
if spec != nil && spec.CloudConfig != nil && spec.CloudConfig.Openstack != nil {
if spec.CloudConfig.Openstack.Loadbalancer != nil && octavia {
klog.V(2).Infof("Openstack using Octavia lbaasv2 api")
lbClient, err = os.NewLoadBalancerV2(provider, gophercloud.EndpointOpts{
Region: region,
})
if err != nil {
return nil, fmt.Errorf("error building lb client: %v", err)
}
} else if spec.CloudConfig.Openstack.Loadbalancer != nil {
klog.V(2).Infof("Openstack using deprecated lbaasv2 api")
lbClient, err = os.NewNetworkV2(provider, gophercloud.EndpointOpts{
Region: region,
})
if err != nil {
return nil, fmt.Errorf("error building lb client: %v", err)
}
} else {
klog.V(2).Infof("Openstack disabled loadbalancer support")
}
} else {
klog.V(2).Infof("Openstack disabled loadbalancer support")
}
c.lbClient = lbClient
return c, nil
Expand Down

0 comments on commit 57baa72

Please sign in to comment.