Skip to content

Commit

Permalink
hciClusterUuid mismatch for hypervisor cluster
Browse files Browse the repository at this point in the history
Handle the case where the system id unexpectedly changes.

Return an error like this:

```
│ Error: error reading hypervisor cluster 298a299e-78f5-5acb-86ce-4e9fdc290ab7
│
│   with hpegl_pc_hypervisor_cluster.my_hypervisor_cluster,
│   on main.tf line 45, in resource "hpegl_pc_hypervisor_cluster" "my_hypervisor_cluster":
│   45: resource "hpegl_pc_hypervisor_cluster" "my_hypervisor_cluster" {
│
│ 'hciClusterUuid' mismatch: 126fd201-9e6e-5e31-9ffb-a766265b1fd3 != 226fd201-9e6e-5e31-9ffb-a766265b1fd3
```
  • Loading branch information
stuart-mclaren-hpe committed Aug 29, 2024
1 parent a5ca83b commit 7e439fc
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions internal/resources/hypervisorcluster/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,28 +116,39 @@ func doRead(
return
}

if getResp.GetName() == nil {
if getResp.GetHciClusterUuid() == nil {
(*diagsP).AddError(
"error reading hypervisor cluster "+hypervisorClusterID,
"'name' is nil",
"'hciClusterUuid' is nil",
)

return
}

(*dataP).Name = types.StringValue(*(getResp.GetName()))

if getResp.GetHciClusterUuid() == nil {
systemID := (*dataP).HciClusterUuid.ValueString()
if *(getResp.GetHciClusterUuid()) != systemID {
(*diagsP).AddError(
"error reading hypervisor cluster "+hypervisorClusterID,
"'hciClusterUuid' is nil",
fmt.Sprintf("'hciClusterUuid' mismatch: %s != %s",
*(getResp.GetHciClusterUuid()), systemID),
)

return
}

(*dataP).HciClusterUuid = types.StringValue(*(getResp.GetHciClusterUuid()))

if getResp.GetName() == nil {
(*diagsP).AddError(
"error reading hypervisor cluster "+hypervisorClusterID,
"'name' is nil",
)

return
}

(*dataP).Name = types.StringValue(*(getResp.GetName()))

if getResp.GetAppInfo() == nil {
(*diagsP).AddError(
"error reading hypervisor cluster "+hypervisorClusterID,
Expand Down

0 comments on commit 7e439fc

Please sign in to comment.