Skip to content

Commit 99d1beb

Browse files
authored
chore: support reconfigure for kb 1.0 api (#590)
Co-authored-by: sophon-zt <sophon-zt@users.noreply.github.com>
1 parent 0d27765 commit 99d1beb

26 files changed

+525
-1294
lines changed

Makefile

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ GOPROXY := https://proxy.golang.org
4848
endif
4949
export GOPROXY
5050

51-
# build tags
52-
BUILD_TAGS="containers_image_openpgp"
53-
54-
5551
TAG_LATEST ?= false
5652
BUILDX_ENABLED ?= ""
5753
ifeq ($(BUILDX_ENABLED), "")
@@ -104,7 +100,7 @@ fmt: ## Run go fmt against code.
104100

105101
.PHONY: vet
106102
vet: ## Run go vet against code.
107-
GOOS=$(GOOS) $(GO) vet -tags $(BUILD_TAGS) -mod=mod ./...
103+
GOOS=$(GOOS) $(GO) vet -mod=mod ./...
108104

109105
.PHONY: cue-fmt
110106
cue-fmt: cuetool ## Run cue fmt against code.
@@ -124,7 +120,7 @@ golangci-lint: golangci generate ## Run golangci-lint against code.
124120

125121
.PHONY: staticcheck
126122
staticcheck: staticchecktool generate ## Run staticcheck against code.
127-
$(STATICCHECK) -tags $(BUILD_TAGS) ./...
123+
$(STATICCHECK) ./...
128124

129125
.PHONY: build-checks
130126
build-checks: generate fmt vet goimports lint-fast ## Run build checks.
@@ -143,11 +139,11 @@ TEST_PACKAGES ?= ./pkg/... ./cmd/...
143139
OUTPUT_COVERAGE=-coverprofile cover.out
144140
.PHONY: test
145141
test: generate ## Run operator controller tests with current $KUBECONFIG context. if existing k8s cluster is k3d or minikube, specify EXISTING_CLUSTER_TYPE.
146-
$(GO) test -tags $(BUILD_TAGS) -p 1 $(TEST_PACKAGES) $(OUTPUT_COVERAGE)
142+
$(GO) test -p 1 $(TEST_PACKAGES) $(OUTPUT_COVERAGE)
147143

148144
.PHONY: test-fast
149145
test-fast:
150-
$(GO) test -tags $(BUILD_TAGS) -short $(TEST_PACKAGES) $(OUTPUT_COVERAGE)
146+
$(GO) test -short $(TEST_PACKAGES) $(OUTPUT_COVERAGE)
151147

152148
.PHONY: cover-report
153149
cover-report: ## Generate cover.html from cover.out
@@ -179,7 +175,7 @@ CLI_LD_FLAGS ="-s -w \
179175
-X github.com/apecloud/kbcli/version.DefaultKubeBlocksVersion=$(VERSION)"
180176

181177
bin/kbcli.%: ## Cross build bin/kbcli.$(OS).$(ARCH).
182-
GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO) build -tags $(BUILD_TAGS) -ldflags=${CLI_LD_FLAGS} -o $@ cmd/cli/main.go
178+
GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) $(GO) build -ldflags=${CLI_LD_FLAGS} -o $@ cmd/cli/main.go
183179

184180
.PHONY: fetch-addons
185181
fetch-addons: ## update addon submodule
@@ -249,7 +245,7 @@ clean-kbcli: ## Clean bin/kbcli*.
249245
.PHONY: kbcli-doc
250246
kbcli-doc: ## generate CLI command reference manual.
251247

252-
$(GO) run -tags $(BUILD_TAGS) ./hack/docgen/cli/main.go ./docs/user_docs/cli
248+
$(GO) run ./hack/docgen/cli/main.go ./docs/user_docs/cli
253249

254250
.PHONY: install-docker-buildx
255251
install-docker-buildx: ## Create `docker buildx` builder.

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
3939
RUN --mount=type=bind,target=. \
4040
--mount=type=cache,target=/root/.cache/go-build \
4141
--mount=type=cache,target=/go/pkg/mod \
42-
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="${LD_FLAGS}" -tags="containers_image_openpgp" -a -o /out/kbcli cmd/cli/main.go
42+
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="${LD_FLAGS}" -a -o /out/kbcli cmd/cli/main.go
4343

4444
# Use alpine with tag 20230329 is corresponding to "edge" tag (latest release to date is 3.18) as of 20230625
4545
FROM docker.io/alpine:edge as dist

docs/user_docs/cli/cli.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ Cluster command.
5252
* [kbcli cluster describe-config](kbcli_cluster_describe-config.md) - Show details of a specific reconfiguring.
5353
* [kbcli cluster describe-ops](kbcli_cluster_describe-ops.md) - Show details of a specific OpsRequest.
5454
* [kbcli cluster describe-restore](kbcli_cluster_describe-restore.md) - Describe a restore
55-
* [kbcli cluster diff-config](kbcli_cluster_diff-config.md) - Show the difference in parameters between the two submitted OpsRequest.
5655
* [kbcli cluster edit-backup-policy](kbcli_cluster_edit-backup-policy.md) - Edit backup policy
5756
* [kbcli cluster edit-config](kbcli_cluster_edit-config.md) - Edit the config file of the component.
5857
* [kbcli cluster explain-config](kbcli_cluster_explain-config.md) - List the constraint for supported configuration params.

docs/user_docs/cli/kbcli_cluster.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ Cluster command.
5353
* [kbcli cluster describe-config](kbcli_cluster_describe-config.md) - Show details of a specific reconfiguring.
5454
* [kbcli cluster describe-ops](kbcli_cluster_describe-ops.md) - Show details of a specific OpsRequest.
5555
* [kbcli cluster describe-restore](kbcli_cluster_describe-restore.md) - Describe a restore
56-
* [kbcli cluster diff-config](kbcli_cluster_diff-config.md) - Show the difference in parameters between the two submitted OpsRequest.
5756
* [kbcli cluster edit-backup-policy](kbcli_cluster_edit-backup-policy.md) - Edit backup policy
5857
* [kbcli cluster edit-config](kbcli_cluster_edit-config.md) - Edit the config file of the component.
5958
* [kbcli cluster explain-config](kbcli_cluster_explain-config.md) - List the constraint for supported configuration params.

docs/user_docs/cli/kbcli_cluster_describe-config.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ kbcli cluster describe-config [flags]
3131
--config-file strings Specify the name of the configuration file to be describe (e.g. for mysql: --config-file=my.cnf). If unset, all files.
3232
--config-specs strings Specify the name of the configuration template to describe. (e.g. for apecloud-mysql: --config-specs=mysql-3node-tpl)
3333
-h, --help help for describe-config
34-
--show-detail If true, the content of the files specified by config-file will be printed.
3534
```
3635

3736
### Options inherited from parent commands

go.mod

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/Masterminds/semver/v3 v3.3.0
99
github.com/NimbleMarkets/ntcharts v0.1.2
1010
github.com/apecloud/dbctl v0.0.0-20240827084000-68a1980b1a46
11-
github.com/apecloud/kubeblocks v1.0.0-beta.29
11+
github.com/apecloud/kubeblocks v1.0.0-beta.35
1212
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
1313
github.com/briandowns/spinner v1.23.0
1414
github.com/chaos-mesh/chaos-mesh/api v0.0.0-20230912020346-a5d89c1c90ad
@@ -118,8 +118,8 @@ require (
118118
github.com/cloudflare/circl v1.3.7 // indirect
119119
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
120120
github.com/containerd/cgroups/v3 v3.0.3 // indirect
121-
github.com/containerd/containerd v1.7.19 // indirect
122-
github.com/containerd/errdefs v0.1.0 // indirect
121+
github.com/containerd/containerd v1.7.27 // indirect
122+
github.com/containerd/errdefs v0.3.0 // indirect
123123
github.com/containerd/log v0.1.0 // indirect
124124
github.com/containerd/platforms v0.2.1 // indirect
125125
github.com/containers/image/v5 v5.32.2 // indirect
@@ -250,7 +250,8 @@ require (
250250
github.com/moby/spdystream v0.4.0 // indirect
251251
github.com/moby/sys/mountinfo v0.7.2 // indirect
252252
github.com/moby/sys/sequential v0.5.0 // indirect
253-
github.com/moby/sys/user v0.2.0 // indirect
253+
github.com/moby/sys/user v0.3.0 // indirect
254+
github.com/moby/sys/userns v0.1.0 // indirect
254255
github.com/moby/term v0.5.0 // indirect
255256
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
256257
github.com/modern-go/reflect2 v1.0.2 // indirect
@@ -355,7 +356,7 @@ require (
355356
gopkg.in/warnings.v0 v0.1.2 // indirect
356357
gopkg.in/yaml.v3 v3.0.1 // indirect
357358
k8s.io/apiserver v0.31.1 // indirect
358-
k8s.io/component-helpers v0.29.2 // indirect
359+
k8s.io/component-helpers v0.29.14 // indirect
359360
oras.land/oras-go v1.2.5 // indirect
360361
periph.io/x/host/v3 v3.8.0 // indirect
361362
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect

go.sum

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,8 @@ github.com/apache/arrow/go/v11 v11.0.0/go.mod h1:Eg5OsL5H+e299f7u5ssuXsuHQVEGC4x
677677
github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU=
678678
github.com/apecloud/dbctl v0.0.0-20240827084000-68a1980b1a46 h1:+Jcc7IjDGxPgIfIkGX2Q5Yxj35U65zgcfjh0B9rDhjo=
679679
github.com/apecloud/dbctl v0.0.0-20240827084000-68a1980b1a46/go.mod h1:eksJtZ7z1nVcVLqDzAdcN5EfpHwXllIAvHZEks2zWys=
680-
github.com/apecloud/kubeblocks v1.0.0-beta.29 h1:7t1K7mQxjFz1s7OiBG8XQ8MkP1aW0yQLeTv73LmM0GM=
681-
github.com/apecloud/kubeblocks v1.0.0-beta.29/go.mod h1:b656nTyvHhwRwOuwNpOPG87Q0Lba3ygGRWoSOacPt5o=
680+
github.com/apecloud/kubeblocks v1.0.0-beta.35 h1:S+Zd3Bzo72lfo/VY3dct1wPHC+rHYVFz1bnHqy79mlo=
681+
github.com/apecloud/kubeblocks v1.0.0-beta.35/go.mod h1:Mk5xRLm2MpxoTNZKEdDcrIY3I1EpokQBU3Q9Zwse8MI=
682682
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
683683
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
684684
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
@@ -790,12 +790,12 @@ github.com/cockroachdb/apd/v3 v3.2.1 h1:U+8j7t0axsIgvQUqthuNm82HIrYXodOV2iWLWtEa
790790
github.com/cockroachdb/apd/v3 v3.2.1/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc=
791791
github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0=
792792
github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0=
793-
github.com/containerd/containerd v1.7.19 h1:/xQ4XRJ0tamDkdzrrBAUy/LE5nCcxFKdBm4EcPrSMEE=
794-
github.com/containerd/containerd v1.7.19/go.mod h1:h4FtNYUUMB4Phr6v+xG89RYKj9XccvbNSCKjdufCrkc=
795-
github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM=
796-
github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ=
797-
github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM=
798-
github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0=
793+
github.com/containerd/containerd v1.7.27 h1:yFyEyojddO3MIGVER2xJLWoCIn+Up4GaHFquP7hsFII=
794+
github.com/containerd/containerd v1.7.27/go.mod h1:xZmPnl75Vc+BLGt4MIfu6bp+fy03gdHAn9bz+FreFR0=
795+
github.com/containerd/continuity v0.4.4 h1:/fNVfTJ7wIl/YPMHjf+5H32uFhl63JucB34PlCpMKII=
796+
github.com/containerd/continuity v0.4.4/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE=
797+
github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4=
798+
github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
799799
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
800800
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
801801
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
@@ -1405,8 +1405,10 @@ github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9Kou
14051405
github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4=
14061406
github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc=
14071407
github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo=
1408-
github.com/moby/sys/user v0.2.0 h1:OnpapJsRp25vkhw8TFG6OLJODNh/3rEwRWtJ3kakwRM=
1409-
github.com/moby/sys/user v0.2.0/go.mod h1:RYstrcWOJpVh+6qzUqp2bU3eaRpdiQeKGlKitaH0PM8=
1408+
github.com/moby/sys/user v0.3.0 h1:9ni5DlcW5an3SvRSx4MouotOygvzaXbaSrc/wGDFWPo=
1409+
github.com/moby/sys/user v0.3.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs=
1410+
github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g=
1411+
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
14101412
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
14111413
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
14121414
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=

pkg/action/template/cluster_operations_template.cue

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -219,23 +219,9 @@ content: {
219219
if options.type == "Reconfiguring" {
220220
reconfigures: [ for _, cName in options.componentNames {
221221
componentName: cName
222-
configurations: [ {
223-
name: options.cfgTemplateName
224-
if options.forceRestart {
225-
policy: "simple"
226-
}
227-
keys: [{
228-
key: options.cfgFile
229-
if options.fileContent != "" {
230-
fileContent: options.fileContent
231-
}
232-
if options.hasPatch {
233-
parameters: [ for k, v in options.keyValues {
234-
key: k
235-
value: v
236-
}]
237-
}
238-
}]
222+
parameters: [ for k, v in options.keyValues {
223+
key: k
224+
value: v
239225
}]
240226
}]
241227
}

pkg/cluster/cluster.go

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,7 @@ func (o *ClusterObjects) GetComponentInfo() []*ComponentInfo {
376376
if ins.Resources != nil {
377377
resources = *ins.Resources
378378
}
379-
vcts := o.getCompTemplateVolumeClaimTemplates(&compSpec, ins)
380-
setComponentInfos(compSpec, resources, vcts, ins.GetReplicas(), clusterCompName, ins.Name, isSharding)
379+
setComponentInfos(compSpec, resources, compSpec.VolumeClaimTemplates, ins.GetReplicas(), clusterCompName, ins.Name, isSharding)
381380
}
382381
setComponentInfos(compSpec, compSpec.Resources, compSpec.VolumeClaimTemplates,
383382
compSpec.Replicas-tplReplicas, clusterCompName, "", isSharding)
@@ -391,27 +390,6 @@ func (o *ClusterObjects) GetComponentInfo() []*ComponentInfo {
391390
return comps
392391
}
393392

394-
// getCompTemplateVolumeClaimTemplates merges volume claim for instance template
395-
func (o *ClusterObjects) getCompTemplateVolumeClaimTemplates(compSpec *kbappsv1.ClusterComponentSpec,
396-
template kbappsv1.InstanceTemplate) []kbappsv1.ClusterComponentVolumeClaimTemplate {
397-
var vcts []kbappsv1.ClusterComponentVolumeClaimTemplate
398-
for i := range compSpec.VolumeClaimTemplates {
399-
insVctIndex := -1
400-
for j := range template.VolumeClaimTemplates {
401-
if template.VolumeClaimTemplates[j].Name == compSpec.VolumeClaimTemplates[i].Name {
402-
insVctIndex = j
403-
break
404-
}
405-
}
406-
if insVctIndex != -1 {
407-
vcts = append(vcts, template.VolumeClaimTemplates[insVctIndex])
408-
} else {
409-
vcts = append(vcts, compSpec.VolumeClaimTemplates[i])
410-
}
411-
}
412-
return vcts
413-
}
414-
415393
func (o *ClusterObjects) GetInstanceInfo() []*InstanceInfo {
416394
var instances []*InstanceInfo
417395
for _, pod := range o.Pods.Items {
@@ -441,18 +419,7 @@ func (o *ClusterObjects) GetInstanceInfo() []*InstanceInfo {
441419
}
442420
}
443421
}
444-
templateName := kbappsv1.GetInstanceTemplateName(o.Cluster.Name, componentName, pod.Name)
445-
template := kbappsv1.InstanceTemplate{}
446-
if templateName != "" {
447-
for _, v := range componentSpec.Instances {
448-
if v.Name == templateName {
449-
template = v
450-
break
451-
}
452-
}
453-
}
454-
vcts := o.getCompTemplateVolumeClaimTemplates(componentSpec, template)
455-
instance.Storage = o.getStorageInfo(vcts, pod.Labels[constant.KBAppComponentLabelKey])
422+
instance.Storage = o.getStorageInfo(componentSpec.VolumeClaimTemplates, pod.Labels[constant.KBAppComponentLabelKey])
456423
instance.ServiceVersion = componentSpec.ServiceVersion
457424
getInstanceNodeInfo(o.Nodes, &pod, instance)
458425
instance.CPU, instance.Memory = getResourceInfo(resource.PodRequestsAndLimits(&pod))

pkg/cmd/cluster/cluster.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ func NewClusterCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra
7878
NewEditConfigureCmd(f, streams),
7979
NewDescribeReconfigureCmd(f, streams),
8080
NewExplainReconfigureCmd(f, streams),
81-
NewDiffConfigureCmd(f, streams),
8281
},
8382
},
8483
{

0 commit comments

Comments
 (0)