pingcap / tidb-operator

TiDB operator creates and manages TiDB clusters running in Kubernetes.
https://docs.pingcap.com/tidb-in-kubernetes/
Apache License 2.0
1.23k stars 498 forks source link

TidbCluster cannot be deployed when config is nil #3827

Open dragonly opened 3 years ago

dragonly commented 3 years ago

Bug Report

What version of Kubernetes are you using?

client: v1.19.4 server: v1.18.2

What version of TiDB Operator are you using?

master branch

What storage classes exist in the Kubernetes cluster and what are used for PD/TiKV pods?

not related

What's the status of the TiDB cluster pods?

pd pod status is Pending

What did you do?

apply tc with definition:

apiVersion: pingcap.com/v1alpha1
kind: TidbCluster
metadata:
  name: basic
spec:
  version: v4.0.10
  timezone: UTC
  pvReclaimPolicy: Delete
  configUpdateStrategy: RollingUpdate
  discovery: {}
  pd:
    baseImage: pingcap/pd
    replicas: 1
    requests:
      storage: "1Gi"
  tikv:
    baseImage: pingcap/tikv
    replicas: 1
    requests:
      storage: "1Gi"
    config: {}
  tidb:
    baseImage: pingcap/tidb
    replicas: 1
    config: {}

What did you expect to see? pd pod event

Events:
  Type     Reason       Age                 From               Message
  ----     ------       ----                ----               -------
  Normal   Scheduled    106s                default-scheduler  Successfully assigned default/basic-pd-0 to kind-control-plane
  Warning  FailedMount  43s (x8 over 106s)  kubelet            MountVolume.SetUp failed for volume "startup-script" : configmap "basic-pd" not found
  Warning  FailedMount  43s (x8 over 106s)  kubelet            MountVolume.SetUp failed for volume "config" : configmap "basic-pd" not found

What did you see instead? tidb cluster deployed.

dragonly commented 3 years ago

Seems like https://github.com/pingcap/tidb-operator/blob/master/pkg/manager/member/pd_member_manager.go#L408-L411 will refuse to create ConfigMap when config is nil. Maybe we could create a ConfigMap with normal startup-script and empty config-file?