apecloud / kubeblocks

KubeBlocks is an open-source control plane software that runs and manages databases, message queues and other stateful applications on K8s.
https://kubeblocks.io
GNU Affero General Public License v3.0
2.06k stars 167 forks source link

[BUG] kbcli connect cluster with shardingSpecs panic #6638

Open JashBook opened 7 months ago

JashBook commented 7 months ago

Describe the bug A clear and concise description of what the bug is.

kbcli version
Kubernetes: v1.26.3
KubeBlocks: 0.8.2-beta.8
kbcli: 0.8.2-beta.1

To Reproduce Steps to reproduce the behavior:

  1. create cluster with shardingSpecs
    apiVersion: apps.kubeblocks.io/v1alpha1
    kind: Cluster
    metadata:
    name: redis-chwmrc
    namespace: default
    spec:
    clusterDefinitionRef: redis
    clusterVersionRef: redis-7.0.6
    terminationPolicy: DoNotTerminate
    shardingSpecs:
    - name: shard
      shards: 3
      template:
        name: redis
        componentDef: redis-cluster
        replicas: 2
        resources:
          limits:
            cpu: 100m
            memory: 0.5Gi
          requests:
            cpu: 100m
            memory: 0.5Gi
        volumeClaimTemplates:
          - name: data
            spec:
              accessModes:
                - ReadWriteOnce
              resources:
                 requests:
                  storage: 1Gi
    kubectl get cluster
    NAME           CLUSTER-DEFINITION   VERSION       TERMINATION-POLICY   STATUS    AGE
    redis-chwmrc   redis                redis-7.0.6   DoNotTerminate       Running   2m23s
  2. See error
    
    kbcli cluster connect redis-chwmrc
    panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]: github.com/apecloud/kbcli/pkg/cmd/cluster.(ConnectOptions).Complete(0x14000baa9c0) /home/runner/work/kbcli/kbcli/pkg/cmd/cluster/connect.go:242 +0x4b0 github.com/apecloud/kbcli/pkg/cmd/cluster.NewConnectCmd.func1(0x14000a68d00?, {0x140000809b0?, 0x1?, 0x1?}) /home/runner/work/kbcli/kbcli/pkg/cmd/cluster/connect.go:126 +0x34 github.com/spf13/cobra.(Command).execute(0x14000bcc600, {0x14000080820, 0x1, 0x1}) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944 +0x654 github.com/spf13/cobra.(Command).ExecuteC(0x140011e4f00) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x320 github.com/spf13/cobra.(Command).Execute(...) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992 k8s.io/component-base/cli.run(0x140011e4f00) /home/runner/go/pkg/mod/k8s.io/component-base@v0.28.2/cli/run.go:146 +0x264 k8s.io/component-base/cli.RunNoErrOutput(...) /home/runner/go/pkg/mod/k8s.io/component-base@v0.28.2/cli/run.go:84 main.main() /home/runner/work/kbcli/kbcli/cmd/cli/main.go:31 +0x20



**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
 - OS: [e.g. iOS]
 - Browser [e.g. chrome, safari]
 - Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
github-actions[bot] commented 6 months ago

This issue has been marked as stale because it has been open for 30 days with no activity

Y-Rookie commented 2 months ago

kbcli currently does not support the sharding API.