Skip to content

Commit 5579be3

Browse files
authored
fix error about update db instance (#86)
1 parent ce17a05 commit 5579be3

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
## 1.25.0 (Unreleased)
1+
## 1.24.1 (Unreleased)
2+
3+
BUG FIXES:
4+
5+
* resource/ucloud_db_instance: Fix the error about updating only one of `instance_storage` and `instance_type`. [GH-86]
6+
27
## 1.24.0 (2020-10-23)
38

49
ENHANCEMENTS:

ucloud/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (c *Config) Client() (*UCloudClient, error) {
6262
// enable auto retry with http/connection error
6363
cfg.MaxRetries = c.MaxRetries
6464
cfg.LogLevel = log.PanicLevel
65-
cfg.UserAgent = "Terraform-UCloud/1.24.0"
65+
cfg.UserAgent = "Terraform-UCloud/1.24.1"
6666
cfg.BaseUrl = c.BaseURL
6767

6868
cred := auth.NewCredential()

ucloud/resource_ucloud_db_instance.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,16 @@ func resourceUCloudDBInstanceUpdate(d *schema.ResourceData, meta interface{}) er
429429
newDbType, _ := parseDBInstanceType(newType.(string))
430430
if oldDbType.Memory != newDbType.Memory {
431431
sizeReq.MemoryLimit = ucloud.Int(newDbType.Memory * 1000)
432+
sizeReq.DiskSpace = ucloud.Int(d.Get("instance_storage").(int))
432433
isSizeChanged = true
433434
}
434435
}
435436

436437
if d.HasChange("instance_storage") && !d.IsNewResource() {
437438
dbType, _ := parseDBInstanceType(d.Get("instance_type").(string))
438-
instanceStorage := d.Get("instance_storage").(int)
439-
sizeReq.DiskSpace = ucloud.Int(instanceStorage)
439+
sizeReq.DiskSpace = ucloud.Int(d.Get("instance_storage").(int))
440440
sizeReq.InstanceType = ucloud.String(dbTypeCvt.convert(dbType.Type))
441+
sizeReq.MemoryLimit = ucloud.Int(dbType.Memory * 1000)
441442
isSizeChanged = true
442443
}
443444

0 commit comments

Comments
 (0)