From 5cd628517a8b82de86a99e5a5483400bda2de3fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Wed, 25 Oct 2023 19:24:32 +0800 Subject: [PATCH] fix(region): vendor update (#18428) --- go.mod | 2 +- go.sum | 4 +- pkg/compute/guestdrivers/aliyun.go | 2 +- vendor/modules.txt | 2 +- .../pkg/multicloud/aliyun/instance.go | 38 +++++++++++++++---- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 11b2bc04af..d3d63f09a3 100644 --- a/go.mod +++ b/go.mod @@ -83,7 +83,7 @@ require ( k8s.io/client-go v0.19.3 k8s.io/cluster-bootstrap v0.19.3 moul.io/http2curl/v2 v2.3.0 - yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231025100130-8c9943d8b3f3 + yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231025105622-cf5e0c639c66 yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 yunion.io/x/jsonutils v1.0.1-0.20230613121553-0f3b41e2ef19 yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361 diff --git a/go.sum b/go.sum index efa368dd40..ddc40bb52e 100644 --- a/go.sum +++ b/go.sum @@ -1179,8 +1179,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231025100130-8c9943d8b3f3 h1:MAxOjOujD0ggie96x7QyrDWR6hIasiiusAC2QP5lOkY= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231025100130-8c9943d8b3f3/go.mod h1:McRjoG2gaOUisB+Qa41kLCNZhr0lsCu4apEjTiphXVY= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231025105622-cf5e0c639c66 h1:DEC+eK0UYuuNbql/ugyrszLsUy88ItnLcrSo+5uJZE8= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231025105622-cf5e0c639c66/go.mod h1:McRjoG2gaOUisB+Qa41kLCNZhr0lsCu4apEjTiphXVY= yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug= yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws= yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634= diff --git a/pkg/compute/guestdrivers/aliyun.go b/pkg/compute/guestdrivers/aliyun.go index a954de0eb9..79485d607d 100644 --- a/pkg/compute/guestdrivers/aliyun.go +++ b/pkg/compute/guestdrivers/aliyun.go @@ -168,7 +168,7 @@ func (self *SAliyunGuestDriver) ValidateCreateData(ctx context.Context, userCred } func (self *SAliyunGuestDriver) GetGuestInitialStateAfterCreate() string { - return api.VM_READY + return api.VM_RUNNING } func (self *SAliyunGuestDriver) GetGuestInitialStateAfterRebuild() string { diff --git a/vendor/modules.txt b/vendor/modules.txt index 60ce8d51e6..cd0d9d8ab4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1438,7 +1438,7 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.2.0 ## explicit; go 1.12 sigs.k8s.io/yaml -# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231025100130-8c9943d8b3f3 +# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231025105622-cf5e0c639c66 ## explicit; go 1.18 yunion.io/x/cloudmux/pkg/apis yunion.io/x/cloudmux/pkg/apis/billing diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/instance.go index 463ebe7be9..7d84777d98 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/instance.go @@ -580,10 +580,9 @@ func (self *SRegion) CreateInstance(name, hostname string, imageId string, insta } params["Description"] = desc params["InternetChargeType"] = "PayByTraffic" - params["InternetMaxBandwidthIn"] = "200" - params["InternetMaxBandwidthOut"] = "100" if publicIp.PublicIpBw > 0 { params["InternetMaxBandwidthOut"] = fmt.Sprintf("%d", publicIp.PublicIpBw) + params["InternetMaxBandwidthIn"] = "200" } if publicIp.PublicIpChargeType == cloudprovider.ElasticipChargeTypeByBandwidth { params["InternetChargeType"] = "PayByBandwidth" @@ -614,6 +613,9 @@ func (self *SRegion) CreateInstance(name, hostname string, imageId string, insta params["SystemDisk.Category"] = api.STORAGE_CLOUD_ESSD params["SystemDisk.PerformanceLevel"] = "PL3" } + if d.Category == api.STORAGE_CLOUD_AUTO { + params["SystemDisk.BurstingEnabled"] = "true" + } params["SystemDisk.Size"] = fmt.Sprintf("%d", d.Size) params["SystemDisk.DiskName"] = d.GetName() params["SystemDisk.Description"] = d.Description @@ -632,6 +634,9 @@ func (self *SRegion) CreateInstance(name, hostname string, imageId string, insta params[fmt.Sprintf("DataDisk.%d.Category", i)] = api.STORAGE_CLOUD_ESSD params[fmt.Sprintf("DataDisk.%d..PerformanceLevel", i)] = "PL3" } + if d.Category == api.STORAGE_CLOUD_AUTO { + params[fmt.Sprintf("DataDisk.%d.BurstingEnabled", i)] = "true" + } params[fmt.Sprintf("DataDisk.%d.DiskName", i)] = d.GetName() params[fmt.Sprintf("DataDisk.%d.Description", i)] = d.Description params[fmt.Sprintf("DataDisk.%d.Encrypted", i)] = "false" @@ -676,13 +681,32 @@ func (self *SRegion) CreateInstance(name, hostname string, imageId string, insta params["ClientToken"] = utils.GenRequestId(20) - body, err := self.ecsRequest("CreateInstance", params) + resp, err := self.ecsRequest("RunInstances", params) if err != nil { - log.Errorf("CreateInstance fail %s", err) - return "", err + return "", errors.Wrapf(err, "RunInstances") } - instanceId, _ := body.GetString("InstanceId") - return instanceId, nil + ids := []string{} + err = resp.Unmarshal(&ids, "InstanceIdSets", "InstanceIdSet") + if err != nil { + return "", errors.Wrapf(err, "Unmarshal") + } + for _, id := range ids { + err = cloudprovider.Wait(time.Second*3, time.Minute, func() (bool, error) { + _, err := self.GetInstance(id) + if err != nil { + if errors.Cause(err) == cloudprovider.ErrNotFound { + return false, nil + } + return false, err + } + return true, nil + }) + if err != nil { + return "", errors.Wrapf(cloudprovider.ErrNotFound, "after vm %s created", id) + } + return id, nil + } + return "", errors.Wrapf(cloudprovider.ErrNotFound, "after created") } func (self *SRegion) AllocatePublicIpAddress(instanceId string) (string, error) {