-
Notifications
You must be signed in to change notification settings - Fork 499
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
[WIP] Optimization for CreateOrUpdateConfigMap #4170
base: master
Are you sure you want to change the base?
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
@mianhk Even with this PR, the function here https://github.com/pingcap/tidb-operator/blob/master/pkg/controller/generic_control.go#L425 will also call the |
…UpdateConfigMap Conflicts: pkg/controller/generic_control.go
Codecov Report
@@ Coverage Diff @@
## master #4170 +/- ##
==========================================
+ Coverage 61.65% 61.67% +0.01%
==========================================
Files 181 181
Lines 19482 19520 +38
==========================================
+ Hits 12011 12038 +27
- Misses 6313 6315 +2
- Partials 1158 1167 +9
|
I fixed this by CheckAndUpdateConfigMap and check the configMap by ConfigMapLister. And if is it necessary to create or upgrade other resources before after checking by Listers. |
/run-all-tests |
pkg/controller/generic_control.go
Outdated
configMapNeedUpdate := false | ||
|
||
if !configMapNotExist { | ||
if err := mergeFn(cm, oldCm); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that mergeFn will never return err!=nil
.
BTW, why set configMapNeedUpdate = true
when err!=nil
?
pkg/controller/generic_control.go
Outdated
} | ||
|
||
if configMapNotExist || configMapNeedUpdate { | ||
result, err := w.GenericControlInterface.CreateOrUpdate(controller, cm, mergeFn, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you call CreateOrUpdate
, it will always call create
first before the update, which is a useless call to the kube-apiserver.
Could you please refer to the StatefulSet sync function https://github.com/pingcap/tidb-operator/blob/master/pkg/manager/member/tidb_member_manager.go#L177, just create if not exist and update if necessary?
Refer to https://github.com/pingcap/tidb-operator/blob/master/pkg/manager/member/config.go#L27 for configmap comparison. And you have to consider the components in the other files of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the comments.
/run-all-tests |
pkg/manager/member/config.go
Outdated
@@ -29,6 +31,8 @@ func updateConfigMap(old, new *corev1.ConfigMap) (bool, error) { | |||
|
|||
// check config | |||
tomlField := []string{"config-file" /*pd,tikv,tidb */, "pump-config", "config_templ.toml" /*tiflash*/, "proxy_templ.toml" /*tiflash*/} | |||
yamlField := []string{"prometheus-config", "prometheus.yml" /*prometheus*/} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prometheus-config
is used as a key for external configmap that can be mounted for Prometheus which is not managed by TiDB Operator, so we can ignore this.
However, dashboards.yaml
should be considered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, fixed.
…' into optimize-CreateOrUpdateConfigMap
/run-all-tests |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 742d0e1
|
/run-all-tests |
1 similar comment
/run-all-tests |
/test pull-e2e-kind-br |
/test pull-e2e-kind |
/run-all-tests |
/test pull-e2e-kind |
/run-all-tests |
1 similar comment
/run-all-tests |
/test pull-e2e-kind |
3 similar comments
/test pull-e2e-kind |
/test pull-e2e-kind |
/test pull-e2e-kind |
Some e2e tests can't pass caused by the tidb-operator/pkg/controller/dependences.go Line 336 in ff10892
This will always filter configmap with the label app.kubernetes.io/managed-by=tidb-operator .
But at the same time, some e2e tests install tidbcluster by Helm with chats: tidb-operator/charts/tidb-cluster/templates/pump-configmap.yaml Lines 7 to 12 in ff10892
Which may create configmaps with the label app.kubernetes.io/managed-by=Helm which will not be cached by the informer.
There are three ways to fix this:
@DanielZhangQD PTAL, which way can be taken? |
@mianhk: 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. |
14a2357
to
f236c8d
Compare
Merge canceled because a new commit is pushed. |
What problem does this PR solve?
Close #3737
What is changed and how does it work?
Code changes
Tests
Side effects
Related changes
Release Notes
Please refer to Release Notes Language Style Guide before writing the release note.