Skip to content

Commit

Permalink
Merge pull request #856 from ioito/hotfix/qx-qcloud-query-cache
Browse files Browse the repository at this point in the history
fix(qcloud): remove cache from qcloud
  • Loading branch information
ioito authored Apr 7, 2024
2 parents bac128c + f96a13d commit c86e783
Show file tree
Hide file tree
Showing 9 changed files with 199 additions and 337 deletions.
6 changes: 0 additions & 6 deletions pkg/multicloud/qcloud/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ func (self *SHost) _createVM(name, hostname string, imgId string, sysDisk cloudp
publicIpBw int, publicIpChargeType cloudprovider.TElasticipChargeType,
tags map[string]string, osType string,
) (string, error) {
net := self.zone.getNetworkById(networkId)
if net == nil {
return "", fmt.Errorf("invalid network ID %s", networkId)
}

var err error

keypair := ""
if len(publicKey) > 0 {
keypair, err = self.zone.region.syncKeypair(publicKey)
Expand Down
2 changes: 1 addition & 1 deletion pkg/multicloud/qcloud/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (self *SInstance) GetInstanceType() string {
}

func (self *SInstance) getVpc() (*SVpc, error) {
return self.host.zone.region.getVpc(self.VirtualPrivateCloud.VpcId)
return self.host.zone.region.GetVpc(self.VirtualPrivateCloud.VpcId)
}

func (self *SInstance) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
Expand Down
18 changes: 10 additions & 8 deletions pkg/multicloud/qcloud/qcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -436,11 +436,11 @@ func (client *SQcloudClient) getSdkClient(regionId string) (*common.Client, erro
httpClient := client.cpcfg.AdaptiveTimeoutHttpClient()
ts, _ := httpClient.Transport.(*http.Transport)
cli.WithHttpTransport(cloudprovider.GetCheckTransport(ts, func(req *http.Request) (func(resp *http.Response) error, error) {
body, err := ioutil.ReadAll(req.Body)
body, err := io.ReadAll(req.Body)
if err != nil {
return nil, errors.Wrapf(err, "ioutil.ReadAll")
}
req.Body = ioutil.NopCloser(bytes.NewBuffer(body))
req.Body = io.NopCloser(bytes.NewBuffer(body))
params, err := url.ParseQuery(string(body))
if err != nil {
return nil, errors.Wrapf(err, "ParseQuery(%s)", string(body))
Expand Down Expand Up @@ -807,7 +807,7 @@ func (client *SQcloudClient) fetchBuckets() error {
}
name := bInfo.Name[:slashPos]
region, err := client.getIRegionByRegionId(bInfo.Region)
var zone cloudprovider.ICloudZone
var zone *SZone = nil
if err != nil {
log.Errorf("fail to find region %s", bInfo.Region)
// possibly a zone, try zone
Expand All @@ -824,10 +824,12 @@ func (client *SQcloudClient) fetchBuckets() error {
continue
}
zoneId := bInfo.Region
zone, _ = region.(*SRegion).getZoneById(bInfo.Region)
if zone != nil {
zoneId = zone.GetId()
zone, err = region.(*SRegion).getZoneById(bInfo.Region)
if err != nil {
log.Errorf("fail to find zone %s", zoneId)
continue
}
zoneId = zone.GetId()
log.Debugf("find zonal bucket %s", zoneId)
}
b := SBucket{
Expand All @@ -838,7 +840,7 @@ func (client *SQcloudClient) fetchBuckets() error {
CreateDate: createAt,
}
if zone != nil {
b.zone = zone.(*SZone)
b.zone = zone
}
ret = append(ret, &b)
}
Expand Down
Loading

0 comments on commit c86e783

Please sign in to comment.