@@ -97,31 +97,32 @@ func (cp *CloudProvider) extractNodeAddresses(ctx context.Context, instanceID st
97
97
}
98
98
addresses = append (addresses , api.NodeAddress {Type : api .NodeExternalIP , Address : ip .String ()})
99
99
}
100
+ if cp .checkOpenShiftISCSIBootVolumeByInstance (ctx , instanceID ) {
101
+ secondaryVnic , err := cp .client .Compute ().GetSecondaryVNICForInstance (ctx , compartmentID , instanceID )
102
+ if err != nil {
103
+ return nil , errors .Wrap (err , "GetSecondaryVNICForInstance" )
104
+ }
100
105
101
- secondaryVnic , err := cp .client .Compute ().GetSecondaryVNICForInstance (ctx , compartmentID , instanceID )
102
- if err != nil {
103
- return nil , errors .Wrap (err , "GetSecondaryVNICForInstance" )
104
- }
105
-
106
- if secondaryVnic == nil {
107
- return addresses , nil
108
- }
106
+ if secondaryVnic == nil {
107
+ return addresses , nil
108
+ }
109
109
110
- if cp .checkOpenShiftISCSIBootVolumeByVnic (ctx , secondaryVnic ) {
111
- if (secondaryVnic .IsPrimary == nil || ! * secondaryVnic .IsPrimary ) && secondaryVnic .PrivateIp != nil && * secondaryVnic .PrivateIp != "" {
112
- ip := net .ParseIP (* secondaryVnic .PrivateIp )
113
- if ip == nil {
114
- return nil , fmt .Errorf ("instance has invalid private address: %q" , * secondaryVnic .PrivateIp )
110
+ if cp .checkOpenShiftISCSIBootVolumeByVnic (ctx , secondaryVnic ) {
111
+ if (secondaryVnic .IsPrimary == nil || ! * secondaryVnic .IsPrimary ) && secondaryVnic .PrivateIp != nil && * secondaryVnic .PrivateIp != "" {
112
+ ip := net .ParseIP (* secondaryVnic .PrivateIp )
113
+ if ip == nil {
114
+ return nil , fmt .Errorf ("instance has invalid private address: %q" , * secondaryVnic .PrivateIp )
115
+ }
116
+ addresses = append (addresses , api.NodeAddress {Type : api .NodeInternalIP , Address : ip .String ()})
115
117
}
116
- addresses = append (addresses , api.NodeAddress {Type : api .NodeInternalIP , Address : ip .String ()})
117
- }
118
118
119
- if (secondaryVnic .IsPrimary == nil || ! * secondaryVnic .IsPrimary ) && secondaryVnic .PublicIp != nil && * secondaryVnic .PublicIp != "" {
120
- ip := net .ParseIP (* secondaryVnic .PublicIp )
121
- if ip == nil {
122
- return nil , errors .Errorf ("instance has invalid public address: %q" , * secondaryVnic .PublicIp )
119
+ if (secondaryVnic .IsPrimary == nil || ! * secondaryVnic .IsPrimary ) && secondaryVnic .PublicIp != nil && * secondaryVnic .PublicIp != "" {
120
+ ip := net .ParseIP (* secondaryVnic .PublicIp )
121
+ if ip == nil {
122
+ return nil , errors .Errorf ("instance has invalid public address: %q" , * secondaryVnic .PublicIp )
123
+ }
124
+ addresses = append (addresses , api.NodeAddress {Type : api .NodeExternalIP , Address : ip .String ()})
123
125
}
124
- addresses = append (addresses , api.NodeAddress {Type : api .NodeExternalIP , Address : ip .String ()})
125
126
}
126
127
}
127
128
// Changing this can have wide reaching impact.
@@ -350,3 +351,18 @@ func (cp *CloudProvider) checkOpenShiftISCSIBootVolumeByVnic(ctx context.Context
350
351
}
351
352
return false
352
353
}
354
+
355
+ func (cp * CloudProvider ) checkOpenShiftISCSIBootVolumeByInstance (ctx context.Context , instanceID string ) bool {
356
+ instance , err := cp .client .Compute ().GetInstance (ctx , instanceID )
357
+ if err != nil {
358
+ return false
359
+ }
360
+ for namespace := range instance .DefinedTags {
361
+ if strings .HasPrefix (namespace , "openshift" ) {
362
+ if bootVolume , exist := instance .DefinedTags [namespace ]["boot-volume-type" ]; exist && bootVolume == "ISCSI" {
363
+ return true
364
+ }
365
+ }
366
+ }
367
+ return false
368
+ }
0 commit comments