@@ -18,6 +18,7 @@ import (
18
18
"context"
19
19
"fmt"
20
20
"net"
21
+ "strings"
21
22
22
23
"github.com/oracle/oci-go-sdk/v65/core"
23
24
"k8s.io/apimachinery/pkg/labels"
@@ -97,17 +98,16 @@ func (cp *CloudProvider) extractNodeAddresses(ctx context.Context, instanceID st
97
98
addresses = append (addresses , api.NodeAddress {Type : api .NodeExternalIP , Address : ip .String ()})
98
99
}
99
100
100
- useSecondaryVnic , err := cp .checkOpenShiftNodesSecondaryVnicByInstance (instanceID )
101
- if useSecondaryVnic {
102
- secondaryVnic , err := cp .client .Compute ().GetSecondaryVNICForInstance (ctx , compartmentID , instanceID )
103
- if err != nil {
104
- return nil , errors .Wrap (err , "GetSecondaryVNICForInstance" )
105
- }
101
+ secondaryVnic , err := cp .client .Compute ().GetSecondaryVNICForInstance (ctx , compartmentID , instanceID )
102
+ if err != nil {
103
+ return nil , errors .Wrap (err , "GetSecondaryVNICForInstance" )
104
+ }
106
105
107
- if secondaryVnic == nil {
108
- return addresses , nil
109
- }
106
+ if secondaryVnic == nil {
107
+ return addresses , nil
108
+ }
110
109
110
+ if cp .checkOpenShiftISCSIBootVolumeByVnic (ctx , secondaryVnic ) {
111
111
if (secondaryVnic .IsPrimary == nil || ! * secondaryVnic .IsPrimary ) && secondaryVnic .PrivateIp != nil && * secondaryVnic .PrivateIp != "" {
112
112
ip := net .ParseIP (* secondaryVnic .PrivateIp )
113
113
if ip == nil {
@@ -340,24 +340,13 @@ func (cp *CloudProvider) getCompartmentIDByNodeName(nodeName string) (string, er
340
340
return "" , errors .New ("compartmentID annotation missing in the node. Would retry" )
341
341
}
342
342
343
- func (cp * CloudProvider ) checkOpenShiftNodesSecondaryVnicByInstance (instanceID string ) (bool , error ) {
344
- var SecondaryVnicUsageInstances = []string {"BM.Standard3.64" }
345
- nodeList , err := cp .NodeLister .List (labels .Everything ())
346
- if err != nil {
347
- return false , errors .Wrap (err , "error listing all the nodes using node informer" )
348
- }
349
- for _ , node := range nodeList {
350
- providerID , err := MapProviderIDToResourceID (node .Spec .ProviderID )
351
- if err != nil {
352
- return false , errors .New ("Failed to map providerID to instanceID." )
353
- }
354
- if providerID == instanceID {
355
- if _ , ok := node .Labels [OpenShiftNodeIdentifierLabel ]; ok {
356
- if instanceType , ok := node .Labels [api .LabelInstanceTypeStable ]; ok && contains (SecondaryVnicUsageInstances , instanceType ) {
357
- return true , nil
358
- }
343
+ func (cp * CloudProvider ) checkOpenShiftISCSIBootVolumeByVnic (ctx context.Context , vnic * core.Vnic ) bool {
344
+ for namespace := range vnic .DefinedTags {
345
+ if strings .HasPrefix (namespace , "openshift" ) {
346
+ if bootVolume , exist := vnic .DefinedTags [namespace ]["boot-volume-type" ]; exist && bootVolume == "ISCSI" {
347
+ return true
359
348
}
360
349
}
361
350
}
362
- return false , errors . New ( "Failed to check OpenShift node using node lables. Returning false" )
351
+ return false
363
352
}
0 commit comments