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

Add support to stop TiDB gracefully (#2810) #2848

Closed

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #2810 to release-1.1


What problem does this PR solve?

This pr add terminationGracePeriodSeconds and lifecycle to TidbCluster spec.tidb attribute.

User can use these two attributes to stop TiDB server gracefully:

  1. set spec.tidb.terminationGracePeriodSeconds to a proper value, for exmaple: 600 (10 minutes).
  2. set spec.tidb.lifecycle to: kill -QUIT 1;
# IT IS NOT SUITABLE FOR PRODUCTION USE.
# This YAML describes a basic TiDB cluster with minimum resource requirements,
# which should be able to run in any Kubernetes cluster with storage support.
apiVersion: pingcap.com/v1alpha1
kind: TidbCluster
metadata:
  name: basic
spec:
  version: v4.0.0
  timezone: UTC
  pvReclaimPolicy: Delete
  discovery: {}
  pd:
    baseImage: pingcap/pd
    replicas: 1
    # if storageClassName is not set, the default Storage Class of the Kubernetes cluster will be used
    # storageClassName: local-storage
    requests:
      storage: "1Gi"
    config: {}
  tikv:
    baseImage: pingcap/tikv
    replicas: 1
    # if storageClassName is not set, the default Storage Class of the Kubernetes cluster will be used
    # storageClassName: local-storage
    requests:
      storage: "1Gi"
    config: {}
  tidb:
    baseImage: pingcap/tidb
    replicas: 1
    service:
      type: ClusterIP
    config: {}
    terminationGracePeriodSeconds: 600
    lifecycle:
      preStop:
        exec:
          command: ["kill", "-QUIT", "1"]

The TiDB server will go graceful shutting down to wait for all clients to close the connection until k8s force kill the TiDB container(10 minutes later).

fixes: #2597

What is changed and how does it work?

Check List

Tests

  • Unit test
  • E2E test
  • Stability test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

  • Has Go code change
  • Has CI related scripts change
  • Has Terraform scripts change

Side effects

  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Does this PR introduce a user-facing change?:

Support configuring container lifecycle hooks and `terminationGracePeriodSeconds` in TiDB spec

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@cofyc
Copy link
Contributor

cofyc commented Jul 1, 2020

@weekface can you cherry-pick this PR manually? we have conflicts in auto-generated files, I guess we need to regenerate them on release-1.1.

@DanielZhangQD
Copy link
Contributor

Close via #2849

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants