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

fix backup failed when pod was auto restarted by k8s #4883

Merged
merged 13 commits into from
Feb 22, 2023

Conversation

WizardXiao
Copy link
Contributor

@WizardXiao WizardXiao commented Feb 16, 2023

What problem does this PR solve?

Ref #4805

What is changed and how does it work?

Code changes

  • Has Go code change
  • Has CI related scripts change

Tests

  • Unit test
  • E2E test
  • Manual test
  • No code

k8s may restart backup pod which is not done.

  1. drain node, node's pod will be schedule to other node
  2. delete pod when job still exist.

detail test

drain node test

  1. backup is running at worker2, drain worker2, backup restart at worker3 by k8s.
    image
    image
  2. clean data before run br command to backup data
    image
  3. backup success
    image

delete pod test

  1. backup pod was deleted and then job restart a new pod
    image
  2. clean data before run br command to backup data in the new pod
    image
  3. backup success
    image

Side effects

  • Breaking backward compatibility
  • Other side effects:

Related changes

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

Release Notes

Please refer to Release Notes Language Style Guide before writing the release note.

fix backup failed when pod was auto restarted by k8s

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 16, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • fengou1
  • grovecai

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2023

Codecov Report

Merging #4883 (854305e) into master (c4e1c3a) will decrease coverage by 6.69%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4883      +/-   ##
==========================================
- Coverage   59.43%   52.75%   -6.69%     
==========================================
  Files         226      205      -21     
  Lines       25694    25836     +142     
==========================================
- Hits        15272    13630    -1642     
- Misses       8966    10646    +1680     
- Partials     1456     1560     +104     
Flag Coverage Δ
e2e 52.75% <100.00%> (?)
unittest ?

@WizardXiao WizardXiao changed the title [WIP] support restart when backup pod evicted [WIP] support backup pod auto restart by k8s Feb 17, 2023
@WizardXiao WizardXiao changed the title [WIP] support backup pod auto restart by k8s support backup pod auto restart by k8s Feb 20, 2023
@WizardXiao WizardXiao changed the title support backup pod auto restart by k8s fix backup failed when pod was auto restarted by k8s Feb 20, 2023
@fengou1 fengou1 self-requested a review February 20, 2023 02:08
@WizardXiao
Copy link
Contributor Author

/test pull-e2e-kind pull-e2e-kind-tikv-scale-simultaneously

Copy link
Contributor

@grovecai grovecai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pls add e2e test

@WizardXiao
Copy link
Contributor Author

/test pull-e2e-kind pull-e2e-kind-across-kubernetes pull-e2e-kind-basic pull-e2e-kind-serial pull-e2e-kind-tngm

@WizardXiao
Copy link
Contributor Author

/test pull-e2e-kind pull-e2e-kind-across-kubernetes pull-e2e-kind-basic pull-e2e-kind-serial

@WizardXiao
Copy link
Contributor Author

/test pull-e2e-kind pull-e2e-kind-across-kubernetes

@WizardXiao
Copy link
Contributor Author

/test pull-e2e-kind-across-kubernetes

@WizardXiao WizardXiao merged commit babb7d8 into master Feb 22, 2023
WizardXiao added a commit to WizardXiao/tidb-operator that referenced this pull request Mar 10, 2023
* init code for test

* just clean before backup data

* delete test code

* import pingcap/errors

* add check version

* remove test code

* add running status check

* add restart condition to clarify logic

* fix status update

* fix ut
WizardXiao added a commit that referenced this pull request Mar 11, 2023
* feat: support tiflash backup and restore during volume snapshot (#4812)

* feat: calc the backup size from snapshot storage usage (#4819)

* fix backup failed when pod was auto restarted by k8s (#4883)

* init code for test

* just clean before backup data

* delete test code

* import pingcap/errors

* add check version

* remove test code

* add running status check

* add restart condition to clarify logic

* fix status update

* fix ut

* br: ensure pvc names sequential for ebs restore (#4888)

* BR: Restart backup when backup job/pod unexpected failed by k8s (#4895)

* init code for test

* just clean before backup data

* delete test code

* import pingcap/errors

* add check version

* remove test code

* add running status check

* add restart condition to clarify logic

* fix status update

* fix ut

* init code

* update crd reference

* fix miss update retry count

* add retry limit as constant

* init runnable code

* refine main controller logic

* add some note

* address some comments

* init e2e test code

* add e2e env to extend backup time

* add e2e env for test

* fix complie

* just test kill pod

* refine logic

* use pkill to kill pod

* fix reconcile

* add kill pod log

* add more log

* add more log

* try kill pod only

* wait and kill running backup pod

* add wait for pod failed

* fix wait pod running

* use killall backup to kill pod

* use pkill -9 backup

* kill pod until pod is failed

* add ps to debug

* connect commands by semicolon

* kill pod by signal 15

* use panic simulate kill pod

* test all kill pod test

* remove useless log

* add original reason of job or pod failure

* rename BackupRetryFailed to BackupRetryTheFailed

* BR: Auto truncate log backup in backup schedule (#4904)

* init schedule log backup code

* add run log backup code

* update api

* refine some nodes

* refine cacluate logic

* add ut

* fix make check

* add log backup test

* refine code

* fix notes

* refine function names

* fix conflict

* fix: add a new check for encryption during the volume snapshot restore (#4914)

* br: volume-snapshot may lead to a panic when there is no block change between two snapshot (#4922)

* br: refine BackoffRetryPolicy time format (#4925)

* refine BackoffRetryPolicy time format

* fix some ut

---------

Co-authored-by: fengou1 <85682690+fengou1@users.noreply.github.com>
Co-authored-by: WangLe1321 <wangle1321@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants