From 015ecf9db4ab5ba1d7bf89856ae4c2f5fbc0596b Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Thu, 13 Feb 2025 20:14:10 +0800 Subject: [PATCH] fix(region): change billing type auto renew --- pkg/multicloud/aliyun/instance.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/multicloud/aliyun/instance.go b/pkg/multicloud/aliyun/instance.go index 44db46e76..2a0a594e5 100644 --- a/pkg/multicloud/aliyun/instance.go +++ b/pkg/multicloud/aliyun/instance.go @@ -1018,7 +1018,18 @@ func (region *SRegion) ModifyInstanceChargeType(vmId string, billingType string) return fmt.Errorf("invalid billing_type %s", billingType) } _, err := region.ecsRequest("ModifyInstanceChargeType", params) - return err + if err != nil { + return err + } + if billingType == billing_api.BILLING_TYPE_PREPAID { + cycle := billing.SBillingCycle{ + AutoRenew: true, + Count: 1, + Unit: billing.BillingCycleMonth, + } + region.SetInstanceAutoRenew(vmId, cycle) + } + return nil } func (self *SInstance) GetCreatedAt() time.Time {