From 02a7e50d5ec5e7b7b947ccb7909fd53dd22333e5 Mon Sep 17 00:00:00 2001 From: Kagashino Date: Fri, 5 Nov 2021 10:29:21 +0800 Subject: [PATCH] FIX clb listener deregister --- tencentcloud/resource_tc_clb_attachment.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tencentcloud/resource_tc_clb_attachment.go b/tencentcloud/resource_tc_clb_attachment.go index 6e2c9a13a3..f64a8411e7 100644 --- a/tencentcloud/resource_tc_clb_attachment.go +++ b/tencentcloud/resource_tc_clb_attachment.go @@ -185,6 +185,8 @@ func resourceTencentCloudClbServerAttachmentDelete(d *schema.ResourceData, meta defer clbActionMu.Unlock() logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + clbService := ClbService{client: meta.(*TencentCloudClient).apiV3Conn} attachmentId := d.Id() @@ -204,7 +206,10 @@ func resourceTencentCloudClbServerAttachmentDelete(d *schema.ResourceData, meta request.LocationId = helper.String(locationId) } - insList := d.Get("targets").(*schema.Set).List() + //insList := d.Get("targets").(*schema.Set).List() + + // filter target group which cvm not existed + insList := getRemoveCandidates(ctx, clbService, clbId, listenerId, locationId, d.Get("targets").(*schema.Set).List()) insLen := len(insList) for count := 0; count < insLen; count += 20 { //this request only support 20 targets at most once time