tidb-operator icon indicating copy to clipboard operation
tidb-operator copied to clipboard

Validate `resources.request.storage` for each item in `spec.tiflash.storageClaims`

Open hoyhbx opened this issue 3 years ago • 11 comments

What problem does this PR solve?

This PR solves the problem that assigning empty objects under storageClaims of tiflash can bypass the validation of the operator.

We found that when we specified tiflash spec with some empty objects under storageClaims, we got rejection from the events saying that storage is a required field. However, we did not get error messages or alerts from the operator indicating that storage is required.

Additionally, from the source code of TiDB operator, we discovered that assigning empty objects under storageClaims can bypass the operator's validation code. For details, please refer to the issue we submitted: https://github.com/pingcap/tidb-operator/issues/4613

What is changed and how does it work?

We believed it is necessary to check whether storage is set when specifying storageClaims for tiflash. We added a sanity check in the function validateTiFlashSpec to see whether storage exists in the resource requests.

Code changes

  • [x] Has Go code change
  • [ ] Has CI related scripts change

Tests

  • [x] Unit test
  • [ ] E2E test
  • [ ] Manual test
  • [ ] No code

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.

Validate `resources.request.storage` for each item in `spec.tiflash.storageClaims`

hoyhbx avatar Jul 18 '22 05:07 hoyhbx

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • DanielZhangQD
  • KanShiori

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.

ti-chi-bot avatar Jul 18 '22 05:07 ti-chi-bot

/merge

DanielZhangQD avatar Jul 22 '22 09:07 DanielZhangQD

This pull request has been accepted and is ready to merge.

Commit hash: 6fc27866c0948cbdea5949af417146513ae6b5ec

ti-chi-bot avatar Jul 22 '22 09:07 ti-chi-bot

Codecov Report

Merging #4635 (b351275) into master (b004b9a) will decrease coverage by 0.01%. The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4635      +/-   ##
==========================================
- Coverage   59.01%   59.01%   -0.01%     
==========================================
  Files         227      227              
  Lines       26357    26357              
==========================================
- Hits        15555    15554       -1     
- Misses       9298     9299       +1     
  Partials     1504     1504              
Flag Coverage Δ
unittest 59.01% <ø> (-0.01%) :arrow_down:

codecov-commenter avatar Jul 22 '22 09:07 codecov-commenter

/run-all-tests

DanielZhangQD avatar Jul 24 '22 13:07 DanielZhangQD

/test pull-e2e-kind-across-kubernetes

DanielZhangQD avatar Jul 24 '22 14:07 DanielZhangQD

/run-all-tests

DanielZhangQD avatar Jul 25 '22 01:07 DanielZhangQD

/run-all-tests

DanielZhangQD avatar Jul 25 '22 03:07 DanielZhangQD

/test pull-e2e-kind pull-e2e-kind-serial

DanielZhangQD avatar Jul 25 '22 07:07 DanielZhangQD

Merge canceled because a new commit is pushed.

ti-chi-bot avatar Sep 28 '22 22:09 ti-chi-bot

Hi @KanShiori I just rebased it, is it possible for you to take a look and merge this fix?

hoyhbx avatar Apr 02 '23 02:04 hoyhbx