Skip to content

Commit 64a047b

Browse files
committed
fix(kafka/instance): fix an error when updating storage_space
1 parent 71e59ae commit 64a047b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

huaweicloud/services/kafka/resource_huaweicloud_dms_kafka_instance.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,9 +1727,24 @@ func resizeKafkaInstance(ctx context.Context, d *schema.ResourceData, meta inter
17271727
if _, err = stateConf.WaitForStateContext(ctx); err != nil {
17281728
return err
17291729
}
1730+
17301731
}
17311732

1733+
// `storage_space` equals `broker_num` multiplied by the storage space of each broker.
1734+
// The `storage_space` value is related to the `broker_num` value.
1735+
// After broker_num changes, we need to obtain the latest storage_space and compare it with the current storage_space.
17321736
if d.HasChanges("storage_space") {
1737+
resp, err := instances.Get(client, d.Id()).Extract()
1738+
if err != nil {
1739+
return fmt.Errorf("error getting Kafka instance: %s", err)
1740+
}
1741+
1742+
newStorageSpace := d.Get("storage_space").(int)
1743+
if resp.TotalStorageSpace >= newStorageSpace {
1744+
log.Printf("[WARN] The new storage space is less than or equal to the current storage space, no need to resize")
1745+
return nil
1746+
}
1747+
17331748
if err = resizeKafkaInstanceStorage(ctx, d, client); err != nil {
17341749
return err
17351750
}

0 commit comments

Comments
 (0)