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: avoid silent rejection to invalid podManagementPolicy #4650

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hoyhbx
Copy link
Contributor

@hoyhbx hoyhbx commented Jul 27, 2022

What problem does this PR solve?

This PR solves the problem mentioned in #4649. Basically, we believe an invalid podManagementPolicy should not be silently replaced by some default values without explicitly telling the user that the input is invalid.

What is changed and how does it work?

We added a warning to explicitly tell the user that podManagement is invalid and the operator will use Parallel instead.

Code changes

  • Has Go code change
  • Has CI related scripts change

Tests

  • 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.

NONE

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

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.

@hoyhbx hoyhbx changed the title avoid silent rejection to invalid podManagementPolicy fix: avoid silent rejection to invalid podManagementPolicy Jul 27, 2022
}
klog.Warningf("PodManagementPolicy \"%s\" is invalid. Fall back to use \"Parallel\" instead\n", policy)
Copy link
Contributor

Choose a reason for hiding this comment

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

Usually, we do not add log in this file, as you can see, no klog imported in this file, each function will be called repeatedly during each sync which will flood too many logs, what about adding descriptions in types.go to describe this behavior clearly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DanielZhangQD Thank you for your reply. Yes, I think it makes sense not to put the log in this file. But I suppose we can add an enum for kubebuilder in types.go to prevent invalid input. I updated the code in the latest commit.

@@ -118,6 +118,8 @@ func (a *componentAccessorImpl) PodManagementPolicy() apps.PodManagementPolicyTy
// unified podManagementPolicy check to avoid check everywhere
if policy == apps.OrderedReadyPodManagement {
return apps.OrderedReadyPodManagement
} else if policy == apps.ParallelPodManagement {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not necessary, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if we use enum then this is not necessary. I have removed it in the latest commit.

@DanielZhangQD
Copy link
Contributor

@hoyhbx Please rebase this PR, thanks!

@hoyhbx hoyhbx force-pushed the FixPodManagementPolicy branch from b5ca120 to 5b41895 Compare August 3, 2022 18:09
@hoyhbx hoyhbx closed this Aug 3, 2022
@hoyhbx hoyhbx force-pushed the FixPodManagementPolicy branch from 5b41895 to 5c7e1a4 Compare August 3, 2022 19:22
@codecov-commenter
Copy link

codecov-commenter commented Aug 3, 2022

Codecov Report

Merging #4650 (0fce0aa) into master (5c7e1a4) will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #4650   +/-   ##
=======================================
  Coverage   62.64%   62.65%           
=======================================
  Files         186      186           
  Lines       20853    20853           
=======================================
+ Hits        13064    13066    +2     
+ Misses       6592     6591    -1     
+ Partials     1197     1196    -1     
Flag Coverage Δ
unittest 62.65% <ø> (+<0.01%) ⬆️

@hoyhbx
Copy link
Contributor Author

hoyhbx commented Aug 3, 2022

@hoyhbx Please rebase this PR, thanks!

@DanielZhangQD It's done now.

@@ -324,6 +324,7 @@ type TidbClusterSpec struct {
StatefulSetUpdateStrategy apps.StatefulSetUpdateStrategyType `json:"statefulSetUpdateStrategy,omitempty"`

// PodManagementPolicy of TiDB cluster StatefulSets
// +kubebuilder:validation:Enum=OrderedReady;Parallel
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work if this field is not set explicitly?

Copy link
Contributor Author

@hoyhbx hoyhbx Aug 4, 2022

Choose a reason for hiding this comment

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

@DanielZhangQD Do you mean we need a default value for this field? If so, what should be the default value?
If we want a default value when the field is not set explicitly, we can also specify the default value through this kubebuilder tag

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jul 18, 2023

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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.

4 participants