Skip to content

tke支持cluster_version升级时携带历史cluster_extra_args记录 #616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
## 1.56.2 (Unreleased)
## 1.56.3 (Unreleased)
## 1.56.2 (April 19, 2021)

BUG FIXES:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注意格式 空行


* Remove `ResourceInsufficient` from `retryableErrorCode`.

ENHANCEMENTS:

* Resource: `tencentcloud_kubernetes_cluster` upgrade `cluster_version` will send old `cluster_extra_args` to tke.

## 1.56.1 (April 6,2021)

BUG FIXES:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/tencentcloud/tencentcloud-sdk-go v1.0.123
github.com/tencentcloud/tencentcloud-sdk-go v1.0.137
github.com/yangwenmai/ratelimit v0.0.0-20180104140304-44221c2292e1
github.com/zclconf/go-cty v1.4.2 // indirect
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 h1:Xr9gkxfOP0K
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
github.com/tencentcloud/tencentcloud-sdk-go v1.0.123 h1:6yOMrmTuKtW1Y8VtWgN5Jt3jUcWnWtRX0gZfD1LxRcc=
github.com/tencentcloud/tencentcloud-sdk-go v1.0.123/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
github.com/tencentcloud/tencentcloud-sdk-go v1.0.137 h1:NEV2Dp7NofwDsyT0OpY5W0fEqsgsbKETD5gWI7/Nn/s=
github.com/tencentcloud/tencentcloud-sdk-go v1.0.137/go.mod h1:asUz5BPXxgoPGaRgZaVm1iGcUAuHyYUo1nXqKa83cvI=
github.com/tetafro/godot v0.3.7 h1:+mecr7RKrUKB5UQ1gwqEMn13sDKTyDR8KNIquB9mm+8=
github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e h1:RumXZ56IrCj4CL+g1b9OL/oH0QnsF976bC8xQFYUD5Q=
Expand Down
1 change: 0 additions & 1 deletion tencentcloud/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ var retryableErrorCode = []string{
"TradeUnknownError",
"RequestLimitExceeded",
"ResourceInUse",
"ResourceInsufficient",
"ResourceUnavailable",
// cbs
"ResourceBusy",
Expand Down
7 changes: 5 additions & 2 deletions tencentcloud/resource_tc_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2124,9 +2124,12 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface
if !isOk {
return fmt.Errorf("version %s is unsupported", newVersion)
}

extraArgs, ok := d.GetOk("cluster_extra_args")
if !ok {
extraArgs = nil
}
err = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
inErr := tkeService.ModifyClusterVersion(ctx, id, newVersion)
inErr := tkeService.ModifyClusterVersion(ctx, id, newVersion, extraArgs)
if inErr != nil {
return retryError(inErr)
}
Expand Down
40 changes: 39 additions & 1 deletion tencentcloud/service_tencentcloud_tke.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,14 +825,52 @@ func (me *TkeService) ModifyClusterAttribute(ctx context.Context, id string, pro
return
}

func (me *TkeService) ModifyClusterVersion(ctx context.Context, id string, clusterVersion string) (errRet error) {
func (me *TkeService) ModifyClusterVersion(ctx context.Context, id string, clusterVersion string, extraArgs interface{}) (errRet error) {
logId := getLogId(ctx)
request := tke.NewUpdateClusterVersionRequest()
defer func() {
if errRet != nil {
log.Printf("[CRITAL]%s api[%s] fail, reason[%s]\n", logId, request.GetAction(), errRet.Error())
}
}()

if extraArgs != nil && len(extraArgs.([]interface{})) > 0 {
// the first elem is in use
extraInterface := extraArgs.([]interface{})
extraMap := extraInterface[0].(map[string]interface{})

kas := make([]*string, 0)
if kaArgs, exist := extraMap["kube_apiserver"]; exist {
args := kaArgs.([]interface{})
for index := range args {
str := args[index].(string)
kas = append(kas, &str)
}
}
kcms := make([]*string, 0)
if kcmArgs, exist := extraMap["kube_controller_manager"]; exist {
args := kcmArgs.([]interface{})
for index := range args {
str := args[index].(string)
kcms = append(kcms, &str)
}
}
kss := make([]*string, 0)
if ksArgs, exist := extraMap["kube_scheduler"]; exist {
args := ksArgs.([]interface{})
for index := range args {
str := args[index].(string)
kss = append(kss, &str)
}
}

request.ExtraArgs = &tke.ClusterExtraArgs{
KubeAPIServer: kas,
KubeControllerManager: kcms,
KubeScheduler: kss,
}
}

request.ClusterId = &id
request.DstVersion = &clusterVersion

Expand Down