Skip to content

Commit

Permalink
B #469: Fix OneFlow service crashes
Browse files Browse the repository at this point in the history
- correctly parse network IDs
- correctly handle the "recover --delete" cleanup
  • Loading branch information
sk4zuzu committed Dec 8, 2023
1 parent f50ce4f commit ae27e21
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions opennebula/resource_opennebula_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,17 @@ func resourceOpennebulaServiceRead(ctx context.Context, d *schema.ResourceData,
var networks = make(map[string]int)
for _, val := range sv.Template.Body.NetworksVals {
for k, v := range val {
networks[k] = int(v.(map[string]interface{})["id"].(float64))
s := v.(map[string]interface{})["id"].(string)
networkID, err := strconv.ParseUint(s, 10, 0)
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Failed to parse network ID",
Detail: fmt.Sprintf("service (ID: %s): %s", d.Id(), err),
})
return diags
}
networks[k] = int(networkID)
}
}
d.Set("networks", networks)
Expand Down Expand Up @@ -379,10 +389,8 @@ func resourceOpennebulaServiceDelete(ctx context.Context, d *schema.ResourceData
Summary: "Failed to recover",
Detail: fmt.Sprintf("service (ID: %s): %s", d.Id(), err),
})
return diags
}

return diags

}

timeout := d.Timeout(schema.TimeoutDelete)
Expand Down

0 comments on commit ae27e21

Please sign in to comment.