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

client/http: add more API for lightning's usage, and don't use body io.Reader #7534

Merged
merged 6 commits into from
Dec 13, 2023

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Dec 12, 2023

What problem does this PR solve?

Issue Number: ref #7300

What is changed and how does it work?

Check List

Tests

  • Unit test

Code changes

Side effects

Related changes

Release note

None.

Copy link
Contributor

ti-chi-bot bot commented Dec 12, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • rleungx

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.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. labels Dec 12, 2023
@ti-chi-bot ti-chi-bot bot requested review from HunDunDM and JmPotato December 12, 2023 08:04
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/needs-linked-issue labels Dec 12, 2023
Copy link

codecov bot commented Dec 12, 2023

Codecov Report

Merging #7534 (58aee20) into master (1eed494) will increase coverage by 0.16%.
Report is 2 commits behind head on master.
The diff coverage is 83.33%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7534      +/-   ##
==========================================
+ Coverage   74.48%   74.64%   +0.16%     
==========================================
  Files         453      454       +1     
  Lines       50079    50142      +63     
==========================================
+ Hits        37300    37428     +128     
+ Misses       9439     9382      -57     
+ Partials     3340     3332       -8     
Flag Coverage Δ
unittests 74.64% <83.33%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@lance6716
Copy link
Contributor Author

/auto-cc

@ti-chi-bot ti-chi-bot bot requested review from nolouch and rleungx December 12, 2023 08:27
@@ -271,7 +275,7 @@ func (c *client) request(
zap.String("caller-id", c.callerID),
}
log.Debug("[pd] request the http url", logFields...)
req, err := http.NewRequestWithContext(ctx, method, url, body)
req, err := http.NewRequestWithContext(ctx, method, url, bytes.NewBuffer(body))
Copy link
Member

Choose a reason for hiding this comment

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

If body is nil, is it OK to pass it into the bytes.NewBuffer? Should we add a check to use http.NoBody like before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nil is OK, IDE shows other packages uses bytes.NewBuffer(nil) safely.

@lance6716 lance6716 changed the title http: add more API for lightning's usage, and don't use body io.Reader client/http: add more API for lightning's usage, and don't use body io.Reader Dec 12, 2023
@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 13, 2023
}

// PostSchedulerDelay changes the delay of given scheduler.
func (c *client) PostSchedulerDelay(ctx context.Context, scheduler string, delaySec int64) error {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need tests for these two interfaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry currently I don't know how to create the scheduler in http client tests so they can not be covered.

Copy link
Member

Choose a reason for hiding this comment

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

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 can wait #7516 merge first and then add a test covering these new functions. @rleungx please help review that PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated. PTAL

@@ -44,6 +44,7 @@ const (
// Client is a PD (Placement Driver) HTTP client.
type Client interface {
/* Meta-related interfaces */
GetClusterVersion(context.Context) (string, error)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it's better to move it into the config-related section.

@@ -65,6 +67,7 @@ type Client interface {
/* Scheduler-related interfaces */
GetSchedulers(context.Context) ([]string, error)
CreateScheduler(ctx context.Context, name string, storeID uint64) error
PostSchedulerDelay(context.Context, string, int64) error
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
PostSchedulerDelay(context.Context, string, int64) error
SetSchedulerDelay(context.Context, string, int64) error

Signed-off-by: lance6716 <[email protected]>
@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 13, 2023
@lance6716
Copy link
Contributor Author

/merge

Copy link
Contributor

ti-chi-bot bot commented Dec 13, 2023

@lance6716: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and 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.

If you have any questions about the PR merge process, please refer to pr process.

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.

Copy link
Contributor

ti-chi-bot bot commented Dec 13, 2023

@lance6716: /merge is only allowed for the committers, you can assign this pull request to the committer in list by filling /assign @committer in the comment to help merge this pull request.

In response to this:

/merge

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.

@lance6716
Copy link
Contributor Author

/assign @JmPotato @rleungx

please help merge it

@JmPotato
Copy link
Member

/merge

Copy link
Contributor

ti-chi-bot bot commented Dec 13, 2023

@JmPotato: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and 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.

If you have any questions about the PR merge process, please refer to pr process.

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.

Copy link
Contributor

ti-chi-bot bot commented Dec 13, 2023

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

Commit hash: c89be3a

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 13, 2023
@lance6716
Copy link
Contributor Author

/build

@lance6716
Copy link
Contributor Author

/retest

Copy link
Contributor

ti-chi-bot bot commented Dec 13, 2023

@lance6716: 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.

@ti-chi-bot ti-chi-bot bot merged commit e26a4f7 into tikv:master Dec 13, 2023
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants