Skip to content

Commit 9c5e54d

Browse files
Merge pull request #8029 from hamzy/PowerVS-handle-composite_instance
OCPBUGS-29584: PowerVS: handle composite_instance
2 parents 2bdbd5d + f48b42c commit 9c5e54d

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

pkg/destroy/powervs/powervs.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,11 +751,16 @@ func (o *ClusterUninstaller) ServiceInstanceNameToGUID(ctx context.Context, name
751751
return "", fmt.Errorf("failed to get instance, response is: %v", response)
752752
}
753753

754-
if resourceInstance.Type != nil && *resourceInstance.Type == "service_instance" {
755-
if resourceInstance.GUID != nil && *resourceInstance.Name == name {
756-
return *resourceInstance.GUID, nil
757-
}
754+
if resourceInstance.Type == nil || resourceInstance.GUID == nil {
755+
continue
758756
}
757+
if *resourceInstance.Type != "service_instance" && *resourceInstance.Type != "composite_instance" {
758+
continue
759+
}
760+
if *resourceInstance.Name != name {
761+
continue
762+
}
763+
return *resourceInstance.GUID, nil
759764
}
760765

761766
// Based on: https://cloud.ibm.com/apidocs/resource-controller/resource-controller?code=go#list-resource-instances

pkg/destroy/powervs/serviceinstance.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,24 @@ func (o *ClusterUninstaller) listServiceInstances() (cloudResources, error) {
121121
o.Logger.Debugf("listServiceInstances: type: %v", *resourceInstance.Type)
122122
}
123123

124-
if resourceInstance.Type != nil && *resourceInstance.Type == "service_instance" {
125-
if strings.Contains(*resource.Name, o.InfraID) {
126-
result = append(result, cloudResource{
127-
key: *resource.ID,
128-
name: *resource.Name,
129-
status: *resource.GUID,
130-
typeName: serviceInstanceTypeName,
131-
id: *resource.ID,
132-
})
133-
}
124+
if resourceInstance.Type == nil || resourceInstance.GUID == nil {
125+
continue
126+
}
127+
if *resourceInstance.Type != "service_instance" && *resourceInstance.Type != "composite_instance" {
128+
continue
129+
}
130+
if !strings.Contains(*resource.Name, o.InfraID) {
131+
continue
132+
}
133+
134+
if strings.Contains(*resource.Name, o.InfraID) {
135+
result = append(result, cloudResource{
136+
key: *resource.ID,
137+
name: *resource.Name,
138+
status: *resource.GUID,
139+
typeName: serviceInstanceTypeName,
140+
id: *resource.ID,
141+
})
134142
}
135143
}
136144

0 commit comments

Comments
 (0)