Skip to content
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

[BUG] Instance template's name with dash(-) leads to failure when adding new instance template to Cluster #8773

Closed
leonliao opened this issue Jan 9, 2025 · 0 comments · Fixed by #8774
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@leonliao
Copy link
Contributor

leonliao commented Jan 9, 2025

Describe the bug
When adding instance template to an existing cluster and the template name has dash(-), kubeblocks reports error:
failed to obtain pod ordinal.

To Reproduce
First, create below Cluster using instance template feature.

apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
  labels:
    clusterdefinition.kubeblocks.io/name: mysql
    clusterversion.kubeblocks.io/name: mysql-5.7.44
  name: mysql-demo-leon
spec:
  affinity:
    podAntiAffinity: Preferred
    tenancy: SharedNode
    topologyKeys:
    - kubernetes.io/hostname
  clusterDefinitionRef: mysql
  clusterVersionRef: mysql-5.7.44
  componentSpecs:
  - componentDefRef: mysql
    disableExporter: true
    enabledLogs:
    - error
    - slow
    name: mysql
    replicas: 3
    resources:
      limits:
      requests:
    volumeClaimTemplates:
    - name: data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 2Gi
    instances:
    - name: az1-instances
      replicas: 2
      schedulingPolicy:
        nodeSelector:
          my.com/az: az1
    - name: az2-instances
      replicas: 1
      schedulingPolicy:
        nodeSelector:
          my.com/az: az2
  resources:
    cpu: "0"
    memory: "0"
  storage:
    size: "0"
  terminationPolicy: Delete

Then, apply the update with new yml

apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
  labels:
    clusterdefinition.kubeblocks.io/name: mysql
    clusterversion.kubeblocks.io/name: mysql-5.7.44
  name: mysql-demo-leon
spec:
  affinity:
    podAntiAffinity: Preferred
    tenancy: SharedNode
    topologyKeys:
    - kubernetes.io/hostname
  clusterDefinitionRef: mysql
  clusterVersionRef: mysql-5.7.44
  componentSpecs:
  - componentDefRef: mysql
    disableExporter: true
    enabledLogs:
    - error
    - slow
    name: mysql
    replicas: 4
    resources:
      limits:
      requests:
    volumeClaimTemplates:
    - name: data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 2Gi
    instances:
    - name: az1-instances
      replicas: 2
      schedulingPolicy:
        nodeSelector:
          my.com/az: az1
    - name: az2-instances
      replicas: 1
      schedulingPolicy:
        nodeSelector:
          my.com/az: az2
    - name: az3-instances
      replicas: 1
      schedulingPolicy:
        nodeSelector:
          my.com/az: az3
  resources:
    cpu: "0"
    memory: "0"
  storage:
    size: "0"
  terminationPolicy: Delete

When debugging using 0.9.2, the error stack trace shown as below

github.com/apecloud/kubeblocks/pkg/controller/component.GetTemplateNameAndOrdinal (kubeblocks/pkg/controller/component/workload_utils.go:176)
github.com/apecloud/kubeblocks/controllers/apps.(*baseDataClone).createPVCs (kubeblocks/controllers/apps/component_hscale_volume_populator.go:252)
github.com/apecloud/kubeblocks/controllers/apps.(*dummyDataClone).CloneData (kubeblocks/controllers/apps/component_hscale_volume_populator.go:292)
github.com/apecloud/kubeblocks/controllers/apps.(*componentWorkloadOps).scaleOut (kubeblocks/controllers/apps/transformer_component_workload.go:547)
github.com/apecloud/kubeblocks/controllers/apps.(*componentWorkloadOps).horizontalScale (kubeblocks/controllers/apps/transformer_component_workload.go:431)
github.com/apecloud/kubeblocks/controllers/apps.(*componentWorkloadTransformer).handleWorkloadUpdate (kubeblocks/controllers/apps/transformer_component_workload.go:204)
github.com/apecloud/kubeblocks/controllers/apps.(*componentWorkloadTransformer).handleUpdate (kubeblocks/controllers/apps/transformer_component_workload.go:174)
github.com/apecloud/kubeblocks/controllers/apps.(*componentWorkloadTransformer).Transform (kubeblocks/controllers/apps/transformer_component_workload.go:118)
github.com/apecloud/kubeblocks/pkg/controller/graph.TransformerChain.ApplyTo (kubeblocks/pkg/controller/graph/transformer.go:57)
github.com/apecloud/kubeblocks/controllers/apps.(*componentPlanBuilder).Build (kubeblocks/controllers/apps/component_plan_builder.go:117)
github.com/apecloud/kubeblocks/controllers/apps.(*ComponentReconciler).Reconcile (kubeblocks/controllers/apps/component_controller.go:188)
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile (/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:119)
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler (/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:316)
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem (/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266)
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2 (/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227)
runtime.goexit (/opt/homebrew/Cellar/[email protected]/1.21.12/libexec/src/runtime/asm_arm64.s:1222)

Expected behavior
No error is thrown and new pods for new instance template to be created.

Screenshots
No.

Desktop (please complete the following information):

  • OS: [MacOS14.6.1 (23G93)]
  • Browser [Chrome]
  • Version [0.9.2 and above]
@leonliao leonliao added the kind/bug Something isn't working label Jan 9, 2025
leonliao added a commit to leonliao/kubeblocks that referenced this issue Jan 9, 2025
@github-actions github-actions bot added this to the Release 0.9.2 milestone Jan 10, 2025
apecloud-bot pushed a commit that referenced this issue Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants