@@ -542,7 +542,7 @@ func (s *Service) GetManagementPort(openStackCluster *infrav1.OpenStackCluster,
542542 return & allPorts [0 ], nil
543543}
544544
545- func (s * Service ) DeleteInstance (eventObject runtime.Object , instanceStatus * InstanceStatus , instanceName string , rootVolume * infrav1. RootVolume ) error {
545+ func (s * Service ) DeleteInstance (openStackCluster * infrav1. OpenStackCluster , eventObject runtime.Object , instanceStatus * InstanceStatus , instanceSpec * InstanceSpec ) error {
546546 if instanceStatus == nil {
547547 /*
548548 We create a boot-from-volume instance in 2 steps:
@@ -562,8 +562,8 @@ func (s *Service) DeleteInstance(eventObject runtime.Object, instanceStatus *Ins
562562 Note that we don't need to separately delete the root volume when deleting the instance because
563563 DeleteOnTermination will ensure it is deleted in that case.
564564 */
565- if hasRootVolume (rootVolume ) {
566- name := rootVolumeName (instanceName )
565+ if hasRootVolume (instanceSpec . RootVolume ) {
566+ name := rootVolumeName (instanceSpec . Name )
567567 volume , err := s .getVolumeByName (name )
568568 if err != nil {
569569 return err
@@ -612,7 +612,12 @@ func (s *Service) DeleteInstance(eventObject runtime.Object, instanceStatus *Ins
612612
613613 // delete port of error instance
614614 if instanceStatus .State () == infrav1 .InstanceStateError {
615- if err := networkingService .GarbageCollectErrorInstancesPort (eventObject , instanceStatus .Name ()); err != nil {
615+ portOpts , err := s .constructPorts (openStackCluster , instanceSpec )
616+ if err != nil {
617+ return err
618+ }
619+
620+ if err := networkingService .GarbageCollectErrorInstancesPort (eventObject , instanceSpec .Name , portOpts ); err != nil {
616621 return err
617622 }
618623 }
0 commit comments