Skip to content

Commit

Permalink
Merge branch 'master' of github.com:tencentcloudstack/terraform-provi…
Browse files Browse the repository at this point in the history
…der-tencentcloud into feat/csip
  • Loading branch information
SevenEarth committed Jan 30, 2024
2 parents a382007 + 57cf580 commit 5edd558
Show file tree
Hide file tree
Showing 15 changed files with 179 additions and 168 deletions.
3 changes: 3 additions & 0 deletions .changelog/2500.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
datasource/tencentcloud_ssl_certificates: Filter out invalid certificates without reporting errors directly
```
4 changes: 4 additions & 0 deletions .changelog/2503.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:enhancement
resource/tencentcloud_instance: wait cvm private ip release when instance destroyed
```

3 changes: 3 additions & 0 deletions .changelog/2504.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_private_dns_zone: Increase the waiting time for instance creation
```
3 changes: 3 additions & 0 deletions .changelog/2506.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_dnspod_record: fix modify dnspod record weight
```
4 changes: 4 additions & 0 deletions .changelog/2507.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:enhancement
resource/tencentcloud_ccn_attachment: support tke cluster addon modify
```

4 changes: 2 additions & 2 deletions .github/workflows/sync-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ jobs:
git branch -r --list "origin/coding-test/*" | grep -v HEAD | grep -v master | xargs -I {} git checkout -t {}
git branch -r --list "origin/pipeline/*" | grep -v HEAD | grep -v master | xargs -I {} git checkout -t {}
git remote add tgit_origin https://${{ secrets.USERNAME }}:${{ secrets.PASSWORD }}@git.code.tencent.com/tencentcloudstack/terraform-provider-tencentcloud.git
git push -u tgit_origin --all
git push -u tgit_origin -f --all
git push -u tgit_origin master:main
git push -u tgit_origin --tags
git push -u tgit_origin --tags
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 1.81.71 (January 26, 2024)

ENHANCEMENTS:

* datasource/tencentcloud_ssl_certificates: Filter out invalid certificates without reporting errors directly ([#2500](https://github.com/tencentcloudstack/terraform-provider-tencentcloud/pull/2500))
* resource/tencentcloud_dnspod_record: fix modify dnspod record weight ([#2506](https://github.com/tencentcloudstack/terraform-provider-tencentcloud/pull/2506))
* resource/tencentcloud_instance: wait cvm private ip release when instance destroyed ([#2503](https://github.com/tencentcloudstack/terraform-provider-tencentcloud/pull/2503))
* resource/tencentcloud_private_dns_zone: Increase the waiting time for instance creation ([#2504](https://github.com/tencentcloudstack/terraform-provider-tencentcloud/pull/2504))

## 1.81.70 (January 24, 2024)

FEATURES:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ resource tencentcloud_ccn main {
name = "ci-temp-test-ccn"
description = "ci-temp-test-ccn-des"
qos = "AG"
charge_type = "PREPAID"
bandwidth_limit_type = "INTER_REGION_LIMIT"
}
data tencentcloud_ccn_instances id_instances {
Expand Down
4 changes: 4 additions & 0 deletions tencentcloud/services/ccn/resource_tc_ccn_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ resource tencentcloud_ccn main {
name = "ci-temp-test-ccn"
description = "ci-temp-test-ccn-des"
qos = "AG"
charge_type = "PREPAID"
bandwidth_limit_type = "INTER_REGION_LIMIT"
}
resource tencentcloud_ccn_attachment attachment {
Expand Down Expand Up @@ -155,6 +157,8 @@ resource tencentcloud_ccn vpngw_ccn_main {
name = "ci-temp-test-vpngw-ccn"
description = "ci-temp-test-vpngw-ccn-des"
qos = "AG"
charge_type = "PREPAID"
bandwidth_limit_type = "INTER_REGION_LIMIT"
}
resource tencentcloud_ccn_attachment vpngw_ccn_attachment {
Expand Down
34 changes: 30 additions & 4 deletions tencentcloud/services/ccn/service_tencentcloud_ccn.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,37 @@ func (me *VpcService) DescribeCcnAttachedInstance(ctx context.Context, ccnId,
func (me *VpcService) DescribeCcnAttachedInstances(ctx context.Context, ccnId string) (infos []CcnAttachedInstanceInfo, errRet error) {

logId := tccommon.GetLogId(ctx)
request := vpc.NewDescribeCcnAttachedInstancesRequest()
var (
request = vpc.NewDescribeCcnAttachedInstancesRequest()
response = vpc.NewDescribeCcnAttachedInstancesResponse()
result []*vpc.CcnAttachedInstance
err error
limit uint64 = 20
offset uint64 = 0
)

request.CcnId = &ccnId

ratelimit.Check(request.GetAction())
response, err := me.client.UseVpcClient().DescribeCcnAttachedInstances(request)

for {
request.Limit = &limit
request.Offset = &offset
response, err = me.client.UseVpcClient().DescribeCcnAttachedInstances(request)
if err != nil {
errRet = err
return
}

if response == nil || len(response.Response.InstanceSet) < 1 {
break
}
result = append(result, response.Response.InstanceSet...)
if len(response.Response.InstanceSet) < int(limit) {
break
}
offset += limit
}
defer func() {
if errRet != nil {
responseStr := ""
Expand All @@ -420,9 +446,9 @@ func (me *VpcService) DescribeCcnAttachedInstances(ctx context.Context, ccnId st
request.ToJsonString(),
response.ToJsonString())

infos = make([]CcnAttachedInstanceInfo, 0, len(response.Response.InstanceSet))
infos = make([]CcnAttachedInstanceInfo, 0, len(result))

for _, item := range response.Response.InstanceSet {
for _, item := range result {

var info CcnAttachedInstanceInfo

Expand Down
31 changes: 30 additions & 1 deletion tencentcloud/services/cvm/resource_tc_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
svccbs "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/cbs"
svctag "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/tag"
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/vpc"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -1415,7 +1416,12 @@ func resourceTencentCloudInstanceDelete(d *schema.ResourceData, meta interface{}
client: meta.(tccommon.ProviderMeta).GetAPIV3Conn(),
}

err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
instance, err := cvmService.DescribeInstanceById(ctx, instanceId)
if err != nil {
return err
}

err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
errRet := cvmService.DeleteInstance(ctx, instanceId)
if errRet != nil {
return tccommon.RetryError(errRet)
Expand Down Expand Up @@ -1449,6 +1455,29 @@ func resourceTencentCloudInstanceDelete(d *schema.ResourceData, meta interface{}
return err
}

// wait ip release
if len(instance.PrivateIpAddresses) > 0 {
vpcService := vpc.NewVpcService(meta.(tccommon.ProviderMeta).GetAPIV3Conn())
params := make(map[string]interface{})
params["VpcId"] = instance.VirtualPrivateCloud.VpcId
params["SubnetId"] = instance.VirtualPrivateCloud.SubnetId
params["IpAddresses"] = instance.PrivateIpAddresses
err := resource.Retry(5*tccommon.ReadRetryTimeout, func() *resource.RetryError {
usedIpAddress, errRet := vpcService.DescribeVpcUsedIpAddressByFilter(ctx, params)
if errRet != nil {
return tccommon.RetryError(errRet, tccommon.InternalError)
}
if len(usedIpAddress) > 0 {
return resource.RetryableError(fmt.Errorf("wait cvm private ip release..."))
}

return nil
})
if err != nil {
return err
}
}

if notExist || !forceDelete {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/dnspod/resource_tc_dnspod_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func resourceTencentCloudDnspodRecordUpdate(d *schema.ResourceData, meta interfa
}
if d.HasChange("weight") {
weight := d.Get("weight").(int)
request.TTL = helper.IntUint64(weight)
request.Weight = helper.IntUint64(weight)
}
d.Partial(true)
err = resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
Expand Down
47 changes: 32 additions & 15 deletions tencentcloud/services/privatedns/resource_tc_private_dns_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ func resourceTencentCloudDPrivateDnsZoneCreate(d *schema.ResourceData, meta inte
defer tccommon.LogElapsed("resource.tencentcloud_private_dns_zone.create")()

var (
logId = tccommon.GetLogId(tccommon.ContextNil)
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
request = privatedns.NewCreatePrivateZoneRequest()
logId = tccommon.GetLogId(tccommon.ContextNil)
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
request = privatedns.NewCreatePrivateZoneRequest()
response = privatedns.NewCreatePrivateZoneResponse()
)

domain := d.Get("domain").(string)
request.Domain = &domain
if v, ok := d.GetOk("domain"); ok {
request.Domain = helper.String(v.(string))
}

if v, ok := d.GetOk("tag_set"); ok {
tagSet := make([]*privatedns.TagInfo, 0, 10)
Expand All @@ -151,8 +153,10 @@ func resourceTencentCloudDPrivateDnsZoneCreate(d *schema.ResourceData, meta inte
TagKey: helper.String(m["tag_key"].(string)),
TagValue: helper.String(m["tag_value"].(string)),
}

tagSet = append(tagSet, &tagInfo)
}

request.TagSet = tagSet
}

Expand All @@ -164,19 +168,19 @@ func resourceTencentCloudDPrivateDnsZoneCreate(d *schema.ResourceData, meta inte
UniqVpcId: helper.String(m["uniq_vpc_id"].(string)),
Region: helper.String(m["region"].(string)),
}

vpcSet = append(vpcSet, &vpcInfo)
}

request.VpcSet = vpcSet
}

if v, ok := d.GetOk("remark"); ok {
remark := v.(string)
request.Remark = helper.String(remark)
request.Remark = helper.String(v.(string))
}

if v, ok := d.GetOk("dns_forward_status"); ok {
dnsForwardStatus := v.(string)
request.DnsForwardStatus = helper.String(dnsForwardStatus)
request.DnsForwardStatus = helper.String(v.(string))
}

if v, ok := d.GetOk("account_vpc_set"); ok {
Expand All @@ -189,32 +193,45 @@ func resourceTencentCloudDPrivateDnsZoneCreate(d *schema.ResourceData, meta inte
Region: helper.String(m["region"].(string)),
VpcName: helper.String(m["vpc_name"].(string)),
}

accountVpcSet = append(accountVpcSet, &accountVpcInfo)
}

request.AccountVpcSet = accountVpcSet
}

if v, ok := d.GetOk("cname_speedup_status"); ok {
cnameSpeedupStatus := v.(string)
request.CnameSpeedupStatus = helper.String(cnameSpeedupStatus)
request.CnameSpeedupStatus = helper.String(v.(string))
}

result, err := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UsePrivateDnsClient().CreatePrivateZone(request)
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UsePrivateDnsClient().CreatePrivateZone(request)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
}

if result == nil {
e = fmt.Errorf("create PrivateDns failed")
return resource.NonRetryableError(e)
}

response = result
return nil
})

if err != nil {
log.Printf("[CRITAL]%s create PrivateDns failed, reason:%s\n", logId, err.Error())
return err
}

response := result

id := *response.Response.ZoneId
d.SetId(id)

client := meta.(tccommon.ProviderMeta).GetAPIV3Conn()
tagService := svctag.NewTagService(client)
region := client.Region

if tags := helper.GetTags(d, "tags"); len(tags) > 0 {
resourceName := tccommon.BuildTagResourceName("privatedns", "zone", region, id)
if err := tagService.ModifyTags(ctx, resourceName, tags, nil); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions tencentcloud/services/ssl/data_source_tc_ssl_certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ssl

import (
"context"
"fmt"
"log"
"strconv"

Expand Down Expand Up @@ -193,7 +192,8 @@ func dataSourceTencentCloudSslCertificatesRead(d *schema.ResourceData, m interfa
"CertEndTime": "end time",
"InsertTime": "create time",
}); len(nilNames) > 0 {
return fmt.Errorf("certificate %v are nil", nilNames)
log.Printf("the certificate is invalid, certificate %v are nil", nilNames)
continue
}

ids = append(ids, *certificate.CertificateId)
Expand Down
Loading

0 comments on commit 5edd558

Please sign in to comment.