Skip to content
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
16 changes: 6 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ GOPROXY := https://proxy.golang.org
endif
export GOPROXY

# build tags
BUILD_TAGS="containers_image_openpgp"


TAG_LATEST ?= false
BUILDX_ENABLED ?= ""
ifeq ($(BUILDX_ENABLED), "")
Expand Down Expand Up @@ -104,7 +100,7 @@ fmt: ## Run go fmt against code.

.PHONY: vet
vet: ## Run go vet against code.
GOOS=$(GOOS) $(GO) vet -tags $(BUILD_TAGS) -mod=mod ./...
GOOS=$(GOOS) $(GO) vet -mod=mod ./...

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

.PHONY: staticcheck
staticcheck: staticchecktool generate ## Run staticcheck against code.
$(STATICCHECK) -tags $(BUILD_TAGS) ./...
$(STATICCHECK) ./...

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

.PHONY: test-fast
test-fast:
$(GO) test -tags $(BUILD_TAGS) -short $(TEST_PACKAGES) $(OUTPUT_COVERAGE)
$(GO) test -short $(TEST_PACKAGES) $(OUTPUT_COVERAGE)

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

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

.PHONY: fetch-addons
fetch-addons: ## update addon submodule
Expand Down Expand Up @@ -249,7 +245,7 @@ clean-kbcli: ## Clean bin/kbcli*.
.PHONY: kbcli-doc
kbcli-doc: ## generate CLI command reference manual.

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

.PHONY: install-docker-buildx
install-docker-buildx: ## Create `docker buildx` builder.
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
RUN --mount=type=bind,target=. \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="${LD_FLAGS}" -tags="containers_image_openpgp" -a -o /out/kbcli cmd/cli/main.go
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="${LD_FLAGS}" -a -o /out/kbcli cmd/cli/main.go

# Use alpine with tag 20230329 is corresponding to "edge" tag (latest release to date is 3.18) as of 20230625
FROM docker.io/alpine:edge as dist
Expand Down
1 change: 0 additions & 1 deletion docs/user_docs/cli/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ Cluster command.
* [kbcli cluster describe-config](kbcli_cluster_describe-config.md) - Show details of a specific reconfiguring.
* [kbcli cluster describe-ops](kbcli_cluster_describe-ops.md) - Show details of a specific OpsRequest.
* [kbcli cluster describe-restore](kbcli_cluster_describe-restore.md) - Describe a restore
* [kbcli cluster diff-config](kbcli_cluster_diff-config.md) - Show the difference in parameters between the two submitted OpsRequest.
* [kbcli cluster edit-backup-policy](kbcli_cluster_edit-backup-policy.md) - Edit backup policy
* [kbcli cluster edit-config](kbcli_cluster_edit-config.md) - Edit the config file of the component.
* [kbcli cluster explain-config](kbcli_cluster_explain-config.md) - List the constraint for supported configuration params.
Expand Down
1 change: 0 additions & 1 deletion docs/user_docs/cli/kbcli_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Cluster command.
* [kbcli cluster describe-config](kbcli_cluster_describe-config.md) - Show details of a specific reconfiguring.
* [kbcli cluster describe-ops](kbcli_cluster_describe-ops.md) - Show details of a specific OpsRequest.
* [kbcli cluster describe-restore](kbcli_cluster_describe-restore.md) - Describe a restore
* [kbcli cluster diff-config](kbcli_cluster_diff-config.md) - Show the difference in parameters between the two submitted OpsRequest.
* [kbcli cluster edit-backup-policy](kbcli_cluster_edit-backup-policy.md) - Edit backup policy
* [kbcli cluster edit-config](kbcli_cluster_edit-config.md) - Edit the config file of the component.
* [kbcli cluster explain-config](kbcli_cluster_explain-config.md) - List the constraint for supported configuration params.
Expand Down
1 change: 0 additions & 1 deletion docs/user_docs/cli/kbcli_cluster_describe-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ kbcli cluster describe-config [flags]
--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.
--config-specs strings Specify the name of the configuration template to describe. (e.g. for apecloud-mysql: --config-specs=mysql-3node-tpl)
-h, --help help for describe-config
--show-detail If true, the content of the files specified by config-file will be printed.
```

### Options inherited from parent commands
Expand Down
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/Masterminds/semver/v3 v3.3.0
github.com/NimbleMarkets/ntcharts v0.1.2
github.com/apecloud/dbctl v0.0.0-20240827084000-68a1980b1a46
github.com/apecloud/kubeblocks v1.0.0-beta.29
github.com/apecloud/kubeblocks v1.0.0-beta.35
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
github.com/briandowns/spinner v1.23.0
github.com/chaos-mesh/chaos-mesh/api v0.0.0-20230912020346-a5d89c1c90ad
Expand Down Expand Up @@ -118,8 +118,8 @@ require (
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/containerd/cgroups/v3 v3.0.3 // indirect
github.com/containerd/containerd v1.7.19 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/containerd v1.7.27 // indirect
github.com/containerd/errdefs v0.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/containers/image/v5 v5.32.2 // indirect
Expand Down Expand Up @@ -250,7 +250,8 @@ require (
github.com/moby/spdystream v0.4.0 // indirect
github.com/moby/sys/mountinfo v0.7.2 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.2.0 // indirect
github.com/moby/sys/user v0.3.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down Expand Up @@ -355,7 +356,7 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiserver v0.31.1 // indirect
k8s.io/component-helpers v0.29.2 // indirect
k8s.io/component-helpers v0.29.14 // indirect
oras.land/oras-go v1.2.5 // indirect
periph.io/x/host/v3 v3.8.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
22 changes: 12 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,8 @@ github.com/apache/arrow/go/v11 v11.0.0/go.mod h1:Eg5OsL5H+e299f7u5ssuXsuHQVEGC4x
github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU=
github.com/apecloud/dbctl v0.0.0-20240827084000-68a1980b1a46 h1:+Jcc7IjDGxPgIfIkGX2Q5Yxj35U65zgcfjh0B9rDhjo=
github.com/apecloud/dbctl v0.0.0-20240827084000-68a1980b1a46/go.mod h1:eksJtZ7z1nVcVLqDzAdcN5EfpHwXllIAvHZEks2zWys=
github.com/apecloud/kubeblocks v1.0.0-beta.29 h1:7t1K7mQxjFz1s7OiBG8XQ8MkP1aW0yQLeTv73LmM0GM=
github.com/apecloud/kubeblocks v1.0.0-beta.29/go.mod h1:b656nTyvHhwRwOuwNpOPG87Q0Lba3ygGRWoSOacPt5o=
github.com/apecloud/kubeblocks v1.0.0-beta.35 h1:S+Zd3Bzo72lfo/VY3dct1wPHC+rHYVFz1bnHqy79mlo=
github.com/apecloud/kubeblocks v1.0.0-beta.35/go.mod h1:Mk5xRLm2MpxoTNZKEdDcrIY3I1EpokQBU3Q9Zwse8MI=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
Expand Down Expand Up @@ -790,12 +790,12 @@ github.com/cockroachdb/apd/v3 v3.2.1 h1:U+8j7t0axsIgvQUqthuNm82HIrYXodOV2iWLWtEa
github.com/cockroachdb/apd/v3 v3.2.1/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc=
github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0=
github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0=
github.com/containerd/containerd v1.7.19 h1:/xQ4XRJ0tamDkdzrrBAUy/LE5nCcxFKdBm4EcPrSMEE=
github.com/containerd/containerd v1.7.19/go.mod h1:h4FtNYUUMB4Phr6v+xG89RYKj9XccvbNSCKjdufCrkc=
github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM=
github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ=
github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM=
github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0=
github.com/containerd/containerd v1.7.27 h1:yFyEyojddO3MIGVER2xJLWoCIn+Up4GaHFquP7hsFII=
github.com/containerd/containerd v1.7.27/go.mod h1:xZmPnl75Vc+BLGt4MIfu6bp+fy03gdHAn9bz+FreFR0=
github.com/containerd/continuity v0.4.4 h1:/fNVfTJ7wIl/YPMHjf+5H32uFhl63JucB34PlCpMKII=
github.com/containerd/continuity v0.4.4/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE=
github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4=
github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
Expand Down Expand Up @@ -1405,8 +1405,10 @@ github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9Kou
github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4=
github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc=
github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo=
github.com/moby/sys/user v0.2.0 h1:OnpapJsRp25vkhw8TFG6OLJODNh/3rEwRWtJ3kakwRM=
github.com/moby/sys/user v0.2.0/go.mod h1:RYstrcWOJpVh+6qzUqp2bU3eaRpdiQeKGlKitaH0PM8=
github.com/moby/sys/user v0.3.0 h1:9ni5DlcW5an3SvRSx4MouotOygvzaXbaSrc/wGDFWPo=
github.com/moby/sys/user v0.3.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs=
github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g=
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
20 changes: 3 additions & 17 deletions pkg/action/template/cluster_operations_template.cue
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,9 @@ content: {
if options.type == "Reconfiguring" {
reconfigures: [ for _, cName in options.componentNames {
componentName: cName
configurations: [ {
name: options.cfgTemplateName
if options.forceRestart {
policy: "simple"
}
keys: [{
key: options.cfgFile
if options.fileContent != "" {
fileContent: options.fileContent
}
if options.hasPatch {
parameters: [ for k, v in options.keyValues {
key: k
value: v
}]
}
}]
parameters: [ for k, v in options.keyValues {
key: k
value: v
}]
}]
}
Expand Down
37 changes: 2 additions & 35 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,7 @@ func (o *ClusterObjects) GetComponentInfo() []*ComponentInfo {
if ins.Resources != nil {
resources = *ins.Resources
}
vcts := o.getCompTemplateVolumeClaimTemplates(&compSpec, ins)
setComponentInfos(compSpec, resources, vcts, ins.GetReplicas(), clusterCompName, ins.Name, isSharding)
setComponentInfos(compSpec, resources, compSpec.VolumeClaimTemplates, ins.GetReplicas(), clusterCompName, ins.Name, isSharding)
}
setComponentInfos(compSpec, compSpec.Resources, compSpec.VolumeClaimTemplates,
compSpec.Replicas-tplReplicas, clusterCompName, "", isSharding)
Expand All @@ -391,27 +390,6 @@ func (o *ClusterObjects) GetComponentInfo() []*ComponentInfo {
return comps
}

// getCompTemplateVolumeClaimTemplates merges volume claim for instance template
func (o *ClusterObjects) getCompTemplateVolumeClaimTemplates(compSpec *kbappsv1.ClusterComponentSpec,
template kbappsv1.InstanceTemplate) []kbappsv1.ClusterComponentVolumeClaimTemplate {
var vcts []kbappsv1.ClusterComponentVolumeClaimTemplate
for i := range compSpec.VolumeClaimTemplates {
insVctIndex := -1
for j := range template.VolumeClaimTemplates {
if template.VolumeClaimTemplates[j].Name == compSpec.VolumeClaimTemplates[i].Name {
insVctIndex = j
break
}
}
if insVctIndex != -1 {
vcts = append(vcts, template.VolumeClaimTemplates[insVctIndex])
} else {
vcts = append(vcts, compSpec.VolumeClaimTemplates[i])
}
}
return vcts
}

func (o *ClusterObjects) GetInstanceInfo() []*InstanceInfo {
var instances []*InstanceInfo
for _, pod := range o.Pods.Items {
Expand Down Expand Up @@ -441,18 +419,7 @@ func (o *ClusterObjects) GetInstanceInfo() []*InstanceInfo {
}
}
}
templateName := kbappsv1.GetInstanceTemplateName(o.Cluster.Name, componentName, pod.Name)
template := kbappsv1.InstanceTemplate{}
if templateName != "" {
for _, v := range componentSpec.Instances {
if v.Name == templateName {
template = v
break
}
}
}
vcts := o.getCompTemplateVolumeClaimTemplates(componentSpec, template)
instance.Storage = o.getStorageInfo(vcts, pod.Labels[constant.KBAppComponentLabelKey])
instance.Storage = o.getStorageInfo(componentSpec.VolumeClaimTemplates, pod.Labels[constant.KBAppComponentLabelKey])
instance.ServiceVersion = componentSpec.ServiceVersion
getInstanceNodeInfo(o.Nodes, &pod, instance)
instance.CPU, instance.Memory = getResourceInfo(resource.PodRequestsAndLimits(&pod))
Expand Down
1 change: 0 additions & 1 deletion pkg/cmd/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func NewClusterCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra
NewEditConfigureCmd(f, streams),
NewDescribeReconfigureCmd(f, streams),
NewExplainReconfigureCmd(f, streams),
NewDiffConfigureCmd(f, streams),
},
},
{
Expand Down
Loading