-
Notifications
You must be signed in to change notification settings - Fork 728
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
resource_manager/client: introduce watch resource group #6510
resource_manager/client: introduce watch resource group #6510
Conversation
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
[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. |
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com> add watch resource group Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
76a5cbf
to
3d9535d
Compare
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #6510 +/- ##
==========================================
- Coverage 74.69% 74.69% -0.01%
==========================================
Files 415 415
Lines 42494 42556 +62
==========================================
+ Hits 31740 31786 +46
- Misses 7966 7974 +8
- Partials 2788 2796 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
@@ -158,7 +163,12 @@ func (c *client) Get(ctx context.Context, key []byte, opts ...OpOption) (*meta_s | |||
Revision: options.revision, | |||
} | |||
ctx = grpcutil.BuildForwardContext(ctx, c.GetLeaderAddr()) | |||
resp, err := c.metaStorageClient().Get(ctx, req) | |||
cli := c.metaStorageClient() |
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 help take a look here, thx. @rleungx @binshi-bing
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
GetResourceGroup(ctx context.Context, resourceGroupName string) (*rmpb.ResourceGroup, error) | ||
AddResourceGroup(ctx context.Context, metaGroup *rmpb.ResourceGroup) (string, error) | ||
ModifyResourceGroup(ctx context.Context, metaGroup *rmpb.ResourceGroup) (string, error) | ||
DeleteResourceGroup(ctx context.Context, resourceGroupName string) (string, error) | ||
AcquireTokenBuckets(ctx context.Context, request *rmpb.TokenBucketsRequest) ([]*rmpb.TokenBucketResponse, error) | ||
LoadGlobalConfig(ctx context.Context, names []string, configPath string) ([]pd.GlobalConfigItem, int64, error) | ||
LoadResourcrGroups(ctx context.Context) ([]*rmpb.ResourceGroup, int64, error) | ||
Watch(ctx context.Context, key []byte, opts ...pd.OpOption) (chan []*meta_storagepb.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.
Do we need to keep consistent with ResourceGroupClient?
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.
Can we can add the Watch
into ResourceGroupClient interface?
} | ||
return groups, resp.Header.Revision, nil | ||
} | ||
|
||
// WatchResourceGroup [just for TEST] watches resource groups changes. |
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.
Can remove [just for TEST]
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 function is still used for testing purposes
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
GetResourceGroup(ctx context.Context, resourceGroupName string) (*rmpb.ResourceGroup, error) | ||
AddResourceGroup(ctx context.Context, metaGroup *rmpb.ResourceGroup) (string, error) | ||
ModifyResourceGroup(ctx context.Context, metaGroup *rmpb.ResourceGroup) (string, error) | ||
DeleteResourceGroup(ctx context.Context, resourceGroupName string) (string, error) | ||
AcquireTokenBuckets(ctx context.Context, request *rmpb.TokenBucketsRequest) ([]*rmpb.TokenBucketResponse, error) | ||
LoadGlobalConfig(ctx context.Context, names []string, configPath string) ([]pd.GlobalConfigItem, int64, error) | ||
LoadResourcrGroups(ctx context.Context) ([]*rmpb.ResourceGroup, int64, 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.
Resourcr -> Resource
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.
LGTM
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
for _, group := range groups { | ||
latestGroups[group.GetName()] = struct{}{} | ||
} | ||
func (c *ResourceGroupsController) cleanUpResourceGroup() { |
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.
help add a GetResourceGrouup()
by the way
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.
rest LGTM!
@@ -732,7 +773,7 @@ func (gc *groupCostController) updateAvgRUPerSec() { | |||
if !gc.calcAvg(counter, getRUValueFromConsumption(gc.run.consumption, typ)) { | |||
continue | |||
} | |||
log.Debug("[resource group controller] update avg ru per sec", zap.String("name", gc.Name), zap.String("type", rmpb.RequestUnitType_name[int32(typ)]), zap.Float64("avgRUPerSec", counter.avgRUPerSec)) | |||
log.Debug("[resource group controller] update avg ru per sec", zap.String("name", gc.name), zap.String("type", rmpb.RequestUnitType_name[int32(typ)]), zap.Float64("avgRUPerSec", counter.avgRUPerSec)) |
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.
ditto
@@ -718,7 +759,7 @@ func (gc *groupCostController) updateAvgRaWResourcePerSec() { | |||
if !gc.calcAvg(counter, getRawResourceValueFromConsumption(gc.run.consumption, typ)) { | |||
continue | |||
} | |||
log.Debug("[resource group controller] update avg raw resource per sec", zap.String("name", gc.Name), zap.String("type", rmpb.RawResourceType_name[int32(typ)]), zap.Float64("avgRUPerSec", counter.avgRUPerSec)) | |||
log.Debug("[resource group controller] update avg raw resource per sec", zap.String("name", gc.name), zap.String("type", rmpb.RawResourceType_name[int32(typ)]), zap.Float64("avgRUPerSec", counter.avgRUPerSec)) |
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.
log.Debug("[resource group controller] update avg raw resource per sec", zap.String("name", gc.name), zap.String("type", rmpb.RawResourceType_name[int32(typ)]), zap.Float64("avgRUPerSec", counter.avgRUPerSec)) | |
log.Debug("[resource group controller] update avg raw resource per sec", zap.String("name", gc.name), zap.String("type", rmpb.RawResourceType_name[int32(typ)]), zap.Float64("avg-ru-per-sec", counter.avgRUPerSec)) |
Do we need to keep consistent with this https://github.com/tikv/pd/pull/6450/files#diff-ed72d626078622ff5c8e9b3f7d1876c4b3d6c648a4bc833785ca312da718aa07R319
@@ -837,7 +878,7 @@ func (gc *groupCostController) applyBasicConfigForRUTokenCounters() { | |||
cfg.NewRate = 99999999 | |||
}) | |||
counter.limiter.Reconfigure(gc.run.now, cfg, resetLowProcess()) | |||
log.Info("[resource group controller] resource token bucket enter degraded mode", zap.String("resource group", gc.Name), zap.String("type", rmpb.RequestUnitType_name[int32(typ)])) | |||
log.Info("[resource group controller] resource token bucket enter degraded mode", zap.String("resource group", gc.name), zap.String("type", rmpb.RequestUnitType_name[int32(typ)])) |
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.
log.Info("[resource group controller] resource token bucket enter degraded mode", zap.String("resource group", gc.name), zap.String("type", rmpb.RequestUnitType_name[int32(typ)])) | |
log.Info("[resource group controller] resource token bucket enter degraded mode", zap.String("resource-group", gc.name), zap.String("type", rmpb.RequestUnitType_name[int32(typ)])) |
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
/merge |
@CabinfeverB: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests 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: d2f90ea
|
@CabinfeverB: 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. |
ref tikv#6509 Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
What problem does this PR solve?
Issue Number: ref #6509
What is changed and how does it work?
In the past, we didn't need to update the configuration of the group in a timely manner because when we only had the token bucket function, we only needed to get tokens from the server. But after joining the runaway query, we need to get a new configuration in time.
Check List
Tests
Code changes
Side effects
Related changes
pingcap/docs
/pingcap/docs-cn
:pingcap/tiup
:Release note