-
Notifications
You must be signed in to change notification settings - Fork 720
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
mcs: watch rule change with txn #7550
Conversation
Signed-off-by: lhy1024 <admin@liudos.us>
[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. |
Skipping CI for Draft Pull Request. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #7550 +/- ##
==========================================
- Coverage 74.80% 74.73% -0.08%
==========================================
Files 457 457
Lines 50351 50388 +37
==========================================
- Hits 37667 37658 -9
- Misses 9351 9396 +45
- Partials 3333 3334 +1
Flags with carried forward coverage won't be shown. Click here to find out more. |
Signed-off-by: lhy1024 <admin@liudos.us>
} | ||
// Try to add the rule to the patch or directly update the rule manager. | ||
err = func() error { | ||
if rw.patch == 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.
When will this happen?
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.
In this pr, it will not use patch when loading data.
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.
Maybe we can only use patch in the all time
Signed-off-by: lhy1024 <admin@liudos.us>
f3123be
to
9c0a7f2
Compare
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.
The rest LGTM
Signed-off-by: lhy1024 <admin@liudos.us>
rule, err := placement.NewRuleFromJSON([]byte(ruleJSON)) | ||
if err != nil { | ||
} | ||
postFn := func(events []*clientv3.Event) error { |
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.
The postFn may not be executed when calling load.
Signed-off-by: lhy1024 <admin@liudos.us>
log.Error("run pre event failed in watch loop", zap.String("name", lw.name), | ||
zap.String("key", lw.key), zap.Error(err)) | ||
} | ||
defer func() { |
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.
Will it affect the keyspace related logic?
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.
I will check it
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.
This PR will also call postEventsFn
when meeting failures in loading data.
After my check, keyspace-watcher will call postEventsFn
to retry, keyspace-server-watcher will call postEventsFn
to send keyspaces.
So I modify a little about it.
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.
The return error also changes, right?
Signed-off-by: lhy1024 <admin@liudos.us>
return err | ||
} | ||
// Try to add the rule change to the patch. | ||
if err := rw.ruleManager.AdjustRule(rule, ""); 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.
Do we need to parser the group ID and use it for this function?
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.
This pr has used rule.GroupID
in value
@@ -865,6 +865,16 @@ func (lw *LoopWatcher) load(ctx context.Context) (nextRevision int64, err error) | |||
if limit != 0 { | |||
limit++ | |||
} | |||
if err := lw.preEventsFn([]*clientv3.Event{}); 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 there is no implemented function using the param.
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 is used to judge whether is called by watch
or by load
.
if isLoading && rw.patch.IsRuleExist(rule) { | ||
log.Error("duplicated rule key", zap.String("rule-key", key), zap.ByteString("rule-value", kv.Value), | ||
errs.ZapError(errs.ErrLoadRule)) | ||
return errs.ErrLoadRule |
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 we return error, the cluster can not be created. Is it expected?
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 should be deleted I think.
@@ -129,6 +132,11 @@ func (rw *Watcher) initializeRuleWatcher() error { | |||
if err := rw.ruleManager.AdjustRule(rule, ""); err != nil { | |||
return err | |||
} | |||
if isLoading && rw.patch.IsRuleExist(rule) { |
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.
Do we need to check the store key?
5d9cfae
to
969b737
Compare
Signed-off-by: lhy1024 <admin@liudos.us>
/merge |
@lhy1024: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger
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 ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: acacc02
|
@lhy1024: Your PR was out of date, I have automatically updated it for you. If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. 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 ti-community-infra/tichi repository. |
What problem does this PR solve?
Issue Number: Close #7418
What is changed and how does it work?
Check List
Tests
Release note