Validate `resources.request.storage` for each item in `spec.tiflash.storageClaims`
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`
[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.
/merge
This pull request has been accepted and is ready to merge.
Codecov Report
Merging #4635 (b351275) into master (b004b9a) will decrease coverage by
0.01%. The diff coverage isn/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: |
/run-all-tests
/test pull-e2e-kind-across-kubernetes
/run-all-tests
/run-all-tests
/test pull-e2e-kind pull-e2e-kind-serial
Merge canceled because a new commit is pushed.
Hi @KanShiori I just rebased it, is it possible for you to take a look and merge this fix?