Skip to content

Commit 6c401b8

Browse files
committed
roachprod: improve instances filtering when listing on IBM
Cloud instance listing on IBM was previously filtering out VMs that lacked the `roachprod` tag. However, the IBM API occasionally returns a successful response for tagging requests without actually acting on it. This inconsistency resulted in some VMs being skipped in the garbage colelction process because lacking the required tags. This PR removes the dependency on the `roachprod` tag, and all resources within the `roachprod` resource group are now considered game for garbage collection. Epic: none Release note: None
1 parent 76d4f47 commit 6c401b8

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

pkg/roachprod/vm/ibm/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ func (p *Provider) listRegion(l *logger.Logger, r string, opts vm.ListOptions) (
833833
}
834834
}
835835

836-
valid, reason := i.isRoachprodAndValidStatus()
836+
valid, reason := i.isValidStatus()
837837
if !valid {
838838
l.Printf("WARN: discarding instance %s in region %s (%s)", *i.instance.CRN, r, reason)
839839
continue

pkg/roachprod/vm/ibm/ibm_extended_types.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -485,25 +485,11 @@ func (i *instance) getPrimaryNetworkInterface() (*vpcv1NetworkInterface, error)
485485
return i.networkInterface, nil
486486
}
487487

488-
// isRoachprodAndValidStatus checks if a roahcprod instance in valid status.
489-
func (i *instance) isRoachprodAndValidStatus() (bool, string) {
488+
// isValidStatus checks if an instance has a valid status.
489+
func (i *instance) isValidStatus() (bool, string) {
490490
if i == nil || i.instance == nil || i.instance.Status == nil {
491491
return false, InstanceNotInitialized
492492
}
493-
494-
tags, err := i.getTagsAsMap()
495-
if err != nil {
496-
return false, InstanceInvalidTags
497-
}
498-
499-
if tags[vm.TagRoachprod] != "true" {
500-
return false, InstanceNotRochprod
501-
}
502-
503-
// if *i.instance.Status != "pending" && *i.instance.Status != "running" {
504-
// return false, InstanceInvalidStatus
505-
// }
506-
507493
return true, ""
508494
}
509495

@@ -585,6 +571,11 @@ func (i *instance) toVM() vm.VM {
585571
vpcID = i.provider.config.regions[region].vpcID
586572
}
587573

574+
// Check if the instance is in a valid state.
575+
if core.StringNilMapper(i.instance.Status) == "failed" {
576+
vmErrors = append(vmErrors, errors.New("instance is in failed state"))
577+
}
578+
588579
// Gather tags
589580
tags, err := i.getTagsAsMap()
590581
if err != nil {

0 commit comments

Comments
 (0)