@@ -53,9 +53,9 @@ const (
5353 defaultTimeOut = 60 * time .Second
5454)
5555
56- var ErrNotFound = errors .New ("Failed to find object" )
57- var ErrMultipleResults = errors .New ("Multiple results where only one expected" )
58- var ErrNoAddressFound = errors .New ("No address found for host" )
56+ var ErrNotFound = errors .New ("failed to find object" )
57+ var ErrMultipleResults = errors .New ("multiple results where only one expected" )
58+ var ErrNoAddressFound = errors .New ("no address found for host" )
5959
6060// encoding.TextUnmarshaler interface for time.Duration
6161type MyDuration struct {
@@ -78,10 +78,11 @@ type LoadBalancer struct {
7878}
7979
8080type LoadBalancerOpts struct {
81- LBVersion string `gcfg:"lb-version"` // overrides autodetection. v1 or v2
81+ LBVersion string `gcfg:"lb-version"` // overrides autodetection. Only support v2.
8282 SubnetId string `gcfg:"subnet-id"` // overrides autodetection.
8383 FloatingNetworkId string `gcfg:"floating-network-id"` // If specified, will create floating ip for loadbalancer, or do not create floating ip.
8484 LBMethod string `gcfg:"lb-method"` // default to ROUND_ROBIN.
85+ LBProvider string `gcfg:"lb-provider"`
8586 CreateMonitor bool `gcfg:"create-monitor"`
8687 MonitorDelay MyDuration `gcfg:"monitor-delay"`
8788 MonitorTimeout MyDuration `gcfg:"monitor-timeout"`
@@ -179,8 +180,7 @@ func (cfg Config) toAuth3Options() tokens3.AuthOptions {
179180
180181func readConfig (config io.Reader ) (Config , error ) {
181182 if config == nil {
182- err := fmt .Errorf ("no OpenStack cloud provider config file given" )
183- return Config {}, err
183+ return Config {}, fmt .Errorf ("no OpenStack cloud provider config file given" )
184184 }
185185
186186 var cfg Config
@@ -507,39 +507,17 @@ func (os *OpenStack) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
507507 return nil , false
508508 }
509509
510+ // LBaaS v1 is deprecated in the OpenStack Liberty release.
511+ // Currently kubernetes OpenStack cloud provider just support LBaaS v2.
510512 lbVersion := os .lbOpts .LBVersion
511- if lbVersion == "" {
512- // No version specified, try newest supported by server
513- netExts , err := networkExtensions (network )
514- if err != nil {
515- glog .Warningf ("Failed to list neutron extensions: %v" , err )
516- return nil , false
517- }
518-
519- if netExts ["lbaasv2" ] {
520- lbVersion = "v2"
521- } else if netExts ["lbaas" ] {
522- lbVersion = "v1"
523- } else {
524- glog .Warningf ("Failed to find neutron LBaaS extension (v1 or v2)" )
525- return nil , false
526- }
527- glog .V (3 ).Infof ("Using LBaaS extension %v" , lbVersion )
513+ if lbVersion != "" && lbVersion != "v2" {
514+ glog .Warningf ("Config error: currently only support LBaaS v2, unrecognised lb-version \" %v\" " , lbVersion )
515+ return nil , false
528516 }
529517
530518 glog .V (1 ).Info ("Claiming to support LoadBalancer" )
531519
532- if lbVersion == "v2" {
533- return & LbaasV2 {LoadBalancer {network , compute , os .lbOpts }}, true
534- } else if lbVersion == "v1" {
535- // Since LBaaS v1 is deprecated in the OpenStack Liberty release, so deprecate LBaaSV1 at V1.8, then remove LBaaSV1 after V1.9.
536- // Reference OpenStack doc: https://docs.openstack.org/mitaka/networking-guide/config-lbaas.html
537- glog .Warningf ("The LBaaS v1 of OpenStack cloud provider has been deprecated, Please use LBaaS v2" )
538- return & LbaasV1 {LoadBalancer {network , compute , os .lbOpts }}, true
539- } else {
540- glog .Warningf ("Config error: unrecognised lb-version \" %v\" " , lbVersion )
541- return nil , false
542- }
520+ return & LbaasV2 {LoadBalancer {network , compute , os .lbOpts }}, true
543521}
544522
545523func isNotFound (err error ) bool {
@@ -549,7 +527,6 @@ func isNotFound(err error) bool {
549527
550528func (os * OpenStack ) Zones () (cloudprovider.Zones , bool ) {
551529 glog .V (1 ).Info ("Claiming to support Zones" )
552-
553530 return os , true
554531}
555532
@@ -563,8 +540,7 @@ func (os *OpenStack) GetZone() (cloudprovider.Zone, error) {
563540 FailureDomain : md .AvailabilityZone ,
564541 Region : os .region ,
565542 }
566- glog .V (1 ).Infof ("Current zone is %v" , zone )
567-
543+ glog .V (4 ).Infof ("Current zone is %v" , zone )
568544 return zone , nil
569545}
570546
@@ -592,7 +568,6 @@ func (os *OpenStack) GetZoneByProviderID(providerID string) (cloudprovider.Zone,
592568 Region : os .region ,
593569 }
594570 glog .V (4 ).Infof ("The instance %s in zone %v" , srv .Name , zone )
595-
596571 return zone , nil
597572}
598573
@@ -618,7 +593,6 @@ func (os *OpenStack) GetZoneByNodeName(nodeName types.NodeName) (cloudprovider.Z
618593 Region : os .region ,
619594 }
620595 glog .V (4 ).Infof ("The instance %s in zone %v" , srv .Name , zone )
621-
622596 return zone , nil
623597}
624598
@@ -653,7 +627,6 @@ func (os *OpenStack) Routes() (cloudprovider.Routes, bool) {
653627 }
654628
655629 glog .V (1 ).Info ("Claiming to support Routes" )
656-
657630 return r , true
658631}
659632
@@ -703,19 +676,18 @@ func (os *OpenStack) volumeService(forceVersion string) (volumeService, error) {
703676 }
704677 default :
705678 err_txt := fmt .Sprintf ("Config error: unrecognised bs-version \" %v\" " , os .bsOpts .BSVersion )
706- glog .Warningf (err_txt )
707679 return nil , errors .New (err_txt )
708680 }
709681}
710682
711683func checkMetadataSearchOrder (order string ) error {
712684 if order == "" {
713- return errors .New ("Invalid value in section [Metadata] with key `search-order`. Value cannot be empty" )
685+ return errors .New ("invalid value in section [Metadata] with key `search-order`. Value cannot be empty" )
714686 }
715687
716688 elements := strings .Split (order , "," )
717689 if len (elements ) > 2 {
718- return errors .New ("Invalid value in section [Metadata] with key `search-order`. Value cannot contain more than 2 elements" )
690+ return errors .New ("invalid value in section [Metadata] with key `search-order`. Value cannot contain more than 2 elements" )
719691 }
720692
721693 for _ , id := range elements {
@@ -724,9 +696,8 @@ func checkMetadataSearchOrder(order string) error {
724696 case configDriveID :
725697 case metadataID :
726698 default :
727- errTxt := "Invalid element '%s' found in section [Metadata] with key `search-order`." +
728- "Supported elements include '%s' and '%s'"
729- return fmt .Errorf (errTxt , id , configDriveID , metadataID )
699+ return fmt .Errorf ("invalid element %q found in section [Metadata] with key `search-order`." +
700+ "Supported elements include %q and %q" , id , configDriveID , metadataID )
730701 }
731702 }
732703
0 commit comments