@@ -45,7 +45,6 @@ import (
45
45
"k8s.io/cloud-provider-openstack/pkg/util"
46
46
"k8s.io/cloud-provider-openstack/pkg/util/errors"
47
47
"k8s.io/cloud-provider-openstack/pkg/util/metadata"
48
- "k8s.io/cloud-provider-openstack/pkg/util/openstack"
49
48
)
50
49
51
50
// Instances encapsulates an implementation of Instances for OpenStack.
@@ -641,9 +640,9 @@ func nodeAddresses(srv *servers.Server, ports []ports.Port, networkingOpts Netwo
641
640
}
642
641
643
642
// Add the private addresses that are not directly connected
644
- if len (addresses ) < len (allPrivates ) && networkingOpts . TrunkSupportEnabled {
643
+ if len (addresses ) < len (allPrivates ) {
645
644
numExtraPrivates := addExtraNodeAddresses (addresses , allPrivates )
646
- klog .V (5 ).Infof ("Node '%s' is added %d extra private interfaces '%s' " , srv .Name , numExtraPrivates , addresses )
645
+ klog .V (5 ).Infof ("Node '%s' is added %d extra private interfaces" , srv .Name , numExtraPrivates )
647
646
}
648
647
649
648
var networks []string
@@ -754,56 +753,47 @@ func getAttachedPorts(client *gophercloud.ServiceClient, networkingOpts Networki
754
753
DeviceOwner : "compute:nova" ,
755
754
}
756
755
757
- interfaces , err := openstack .GetPorts (client , listOpts )
756
+ type portWithTrunkDetails struct {
757
+ ports.Port
758
+ trunk_details.TrunkDetailsExt
759
+ }
760
+
761
+ var interfaces []ports.Port
762
+ var allPorts []portWithTrunkDetails
763
+
764
+ allPages , err := ports .List (client , listOpts ).AllPages ()
758
765
if err != nil {
759
766
return interfaces , err
760
767
}
761
- if networkingOpts .TrunkSupportEnabled {
762
- subInterfaces , err := getSubInterfaces (client , interfaces )
763
- if err != nil {
764
- return interfaces , err
765
- }
766
- interfaces = append (interfaces , subInterfaces ... )
768
+ err = ports .ExtractPortsInto (allPages , & allPorts )
769
+ if err != nil {
770
+ return interfaces , err
767
771
}
768
772
769
- return interfaces , nil
770
- }
771
-
772
- // getSubInterfaces returns the sub-interfaces attached via trunks to the specified interfaces
773
- func getSubInterfaces (client * gophercloud.ServiceClient , interfaces []ports.Port ) ([]ports.Port , error ) {
774
- var subports []ports.Port
775
- var portExt struct {
776
- ports.Port
777
- trunk_details.TrunkDetailsExt
778
- }
779
- for _ , iface := range interfaces {
780
- // Check if trunk is attached to the interface
781
- err := ports .Get (client , iface .ID ).ExtractInto (& portExt )
782
- if err != nil {
783
- klog .Errorf ("Failed to get port %s trunk_details: %v" , iface .ID , err )
784
- return subports , nil
785
- }
773
+ for _ , portExt := range allPorts {
774
+ interfaces = append (interfaces , portExt .Port )
775
+ // Check if trunk is attached to the port
786
776
if portExt .TrunkDetails .TrunkID == "" {
787
777
continue
788
778
}
789
- // Get subports attached to the trunk
779
+ // Get subport addresses
790
780
for _ , subport := range portExt .TrunkDetails .SubPorts {
791
781
p , err := ports .Get (client , subport .PortID ).Extract ()
792
782
if err != nil {
793
783
klog .Errorf ("Failed to get subport %s details: %v" , subport .PortID , err )
794
- return subports , nil
784
+ continue
795
785
}
796
786
n , err := networks .Get (client , p .NetworkID ).Extract ()
797
787
if err != nil {
798
788
klog .Errorf ("Failed to get subport %s network details: %v" , subport .PortID , err )
799
- return subports , nil
789
+ continue
800
790
}
801
791
p .Status = "ACTIVE"
802
792
p .NetworkID = n .Name
803
- subports = append (subports , * p )
793
+ interfaces = append (interfaces , * p )
804
794
}
805
- klog .V (5 ).Infof ("Node interface %s has %d sub-interfaces '%v'" , iface .Name , len (subports ), subports )
806
-
807
795
}
808
- return subports , nil
796
+
797
+ klog .V (5 ).Infof ("Node %s has %d interfaces '%v'" , serverID , len (interfaces ), interfaces )
798
+ return interfaces , nil
809
799
}
0 commit comments