Skip to content

Commit

Permalink
improve instance tagging logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yutpeng committed Jul 26, 2024
1 parent 0c43650 commit e3bc230
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/cloudprovider/providers/oci/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (cp *CloudProvider) extractNodeAddresses(ctx context.Context, instanceID st
}
addresses = append(addresses, api.NodeAddress{Type: api.NodeExternalIP, Address: ip.String()})
}
if cp.checkOpenShiftISCSIBootVolumeByInstance(ctx, instanceID) {
if cp.checkOpenShiftInstance(ctx, instanceID) {
secondaryVnic, err := cp.client.Compute().GetSecondaryVNICForInstance(ctx, compartmentID, instanceID)
if err != nil {
return nil, errors.Wrap(err, "GetSecondaryVNICForInstance")
Expand Down Expand Up @@ -352,16 +352,14 @@ func (cp *CloudProvider) checkOpenShiftISCSIBootVolumeByVnic(ctx context.Context
return false
}

func (cp *CloudProvider) checkOpenShiftISCSIBootVolumeByInstance(ctx context.Context, instanceID string) bool {
func (cp *CloudProvider) checkOpenShiftInstance(ctx context.Context, instanceID string) bool {
instance, err := cp.client.Compute().GetInstance(ctx, instanceID)
if err != nil {
return false
}
for namespace := range instance.DefinedTags {
if strings.HasPrefix(namespace, "openshift") {
if bootVolume, exist := instance.DefinedTags[namespace]["boot-volume-type"]; exist && bootVolume == "ISCSI" {
return true
}
return true
}
}
return false
Expand Down

0 comments on commit e3bc230

Please sign in to comment.