Skip to content

Commit 6b7a7ba

Browse files
committed
mantle/platform: handle improperly created azure resource groups
In some cases (especially when Azure infra is having trouble) resource groups can get created without some necessary tags. Let's handle the case when a group doesn't have a "createdAt" tag so we clean that resource group up and don't panic/segfault. Fixes #3057
1 parent 3991e6f commit 6b7a7ba

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

  • mantle/platform/api/azure

mantle/platform/api/azure/api.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,25 @@ func (a *API) GC(gracePeriod time.Duration) error {
158158

159159
for _, l := range *listGroups.Value {
160160
if strings.HasPrefix(*l.Name, "kola-cluster") {
161-
createdAt := *(*l.Tags)["createdAt"]
162-
timeCreated, err := time.Parse(time.RFC3339, createdAt)
163-
if err != nil {
164-
return fmt.Errorf("error parsing time: %v", err)
161+
terminate := false
162+
if l.Tags == nil || (*l.Tags)["createdAt"] == nil {
163+
// If the group name starts with kola-cluster and has
164+
// no tags OR no createdAt then it failed to properly
165+
// get created and we should clean it up.
166+
// https://github.com/coreos/coreos-assembler/issues/3057
167+
terminate = true
168+
} else {
169+
createdAt := *(*l.Tags)["createdAt"]
170+
timeCreated, err := time.Parse(time.RFC3339, createdAt)
171+
if err != nil {
172+
return fmt.Errorf("error parsing time: %v", err)
173+
}
174+
if !timeCreated.After(durationAgo) {
175+
// If the group is older than specified time then gc
176+
terminate = true
177+
}
165178
}
166-
if !timeCreated.After(durationAgo) {
179+
if terminate {
167180
if err = a.TerminateResourceGroup(*l.Name); err != nil {
168181
return err
169182
}

0 commit comments

Comments
 (0)