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

Feature:support configuring PodManagementPolicy in TidbCluster CR #4211

Merged

Conversation

mianhk
Copy link
Contributor

@mianhk mianhk commented Sep 30, 2021

What problem does this PR solve?

Close: #3228

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

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.

Feature: support configuring PodManagementPolicy in TidbCluster CR

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 30, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • csuzhangxc
  • july2993

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 Sep 30, 2021

Codecov Report

Merging #4211 (059a158) into master (26b6a1e) will increase coverage by 0.00%.
The diff coverage is 77.77%.

@@           Coverage Diff           @@
##           master    #4211   +/-   ##
=======================================
  Coverage   61.78%   61.79%           
=======================================
  Files         181      181           
  Lines       19273    19277    +4     
=======================================
+ Hits        11908    11912    +4     
  Misses       6217     6217           
  Partials     1148     1148           
Flag Coverage Δ
unittest 61.79% <77.77%> (+<0.01%) ⬆️

@mianhk mianhk changed the title [WIP]Feature:support configuring PodManagementPolicy in TidbCluster CR Feature:support configuring PodManagementPolicy in TidbCluster CR Oct 9, 2021
policy = a.ComponentSpec.PodManagementPolicy
}
// unified podManagementPolicy check to avoid check everywhere
if len(policy) == 0 || policy == apps.OrderedReadyPodManagement {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I add the check of PodManagementPolicyType here to avoid check it everywhere, is this OK?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's OK

@@ -696,7 +696,7 @@ func getNewMasterSetForDMCluster(dc *v1alpha1.DMCluster, cm *corev1.ConfigMap) (
},
},
ServiceName: controller.DMMasterPeerMemberName(dcName),
PodManagementPolicy: apps.ParallelPodManagement,
PodManagementPolicy: apps.OrderedReadyPodManagement,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not support configuring DM master&worker cause StatefulSetUpdateStrategy is not supported too.

UpdateStrategy: apps.StatefulSetUpdateStrategy{
Type: apps.RollingUpdateStatefulSetStrategyType,
RollingUpdate: &apps.RollingUpdateStatefulSetStrategy{
Partition: pointer.Int32Ptr(dc.Spec.Master.Replicas + int32(failureReplicas) + deleteSlotsNumber),
}},

I'll add them if need.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's needed, but you can added them later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, will add them in another PR.

Copy link
Contributor

@july2993 july2993 left a comment

Choose a reason for hiding this comment

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

rest LGTM

// unified podManagementPolicy check to avoid check everywhere
if policy == apps.OrderedReadyPodManagement {
return apps.OrderedReadyPodManagement
}
Copy link
Contributor

Choose a reason for hiding this comment

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

some unknown value will be treated as ParallelPodManagement silently? at least log for unknown config item?

Copy link
Contributor

Choose a reason for hiding this comment

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

how about just passing the value to set in sts spec, make it error to let the user know setting wrong item?

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, Refer to StatefulSetUpdateStrategy:

updateStrategy := apps.StatefulSetUpdateStrategy{}
if basePDSpec.StatefulSetUpdateStrategy() == apps.OnDeleteStatefulSetStrategyType {
updateStrategy.Type = apps.OnDeleteStatefulSetStrategyType
} else {
updateStrategy.Type = apps.RollingUpdateStatefulSetStrategyType
updateStrategy.RollingUpdate = &apps.RollingUpdateStatefulSetStrategy{
Partition: pointer.Int32Ptr(tc.PDStsDesiredReplicas() + deleteSlotsNumber),
}
}

pkg/apis/pingcap/v1alpha1/tidbcluster_component.go Outdated Show resolved Hide resolved

## PodManagementPolicy default Parallel.
## Ref: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-management-policies
podManagementPolicy: Parallel
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to change the default value as OrderedReady?
@DanielZhangQD

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to keep the current behavior for the default configuration.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, for pump it is not keep the current behavior for the default configuration, it does not set the value before

@DanielZhangQD
Copy link
Contributor

/run-all-tests

@DanielZhangQD
Copy link
Contributor

/test pull-e2e-kind

@@ -470,6 +470,7 @@ func getNewPumpStatefulSet(tc *v1alpha1.TidbCluster, cm *corev1.ConfigMap) (*app

Template: podTemplate,
VolumeClaimTemplates: volumeClaims,
PodManagementPolicy: spec.PodManagementPolicy(),
Copy link
Contributor

Choose a reason for hiding this comment

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

The podManagementPolicy is not set before as @july2993 has said in another comment, so the default value is OrderedReady for pump, and this field is not allowed to update after the sts is created, so we have to set to OrderedReady for pump if it's not set explicitly.

Co-authored-by: DanielZhangQD <36026334+DanielZhangQD@users.noreply.github.com>
Copy link
Contributor

@DanielZhangQD DanielZhangQD left a comment

Choose a reason for hiding this comment

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

LGTM

@DanielZhangQD
Copy link
Contributor

/run-all-tests

@DanielZhangQD
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: eb41a1b

@DanielZhangQD
Copy link
Contributor

/run-all-tests

@DanielZhangQD
Copy link
Contributor

/test pull-e2e-kind

1 similar comment
@DanielZhangQD
Copy link
Contributor

/test pull-e2e-kind

@DanielZhangQD DanielZhangQD merged commit afa5a3d into pingcap:master Nov 10, 2021
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.

It's dangerous to set the "PodManagementPolicy" of Statefulset to "Parallel"
6 participants