Skip to content

http client: support update keyspce config#10717

Merged
ti-chi-bot[bot] merged 4 commits into
tikv:masterfrom
ystaticy:pd_http_client
Jun 1, 2026
Merged

http client: support update keyspce config#10717
ti-chi-bot[bot] merged 4 commits into
tikv:masterfrom
ystaticy:pd_http_client

Conversation

@ystaticy
Copy link
Copy Markdown
Contributor

@ystaticy ystaticy commented May 26, 2026

What problem does this PR solve?

Issue Number: Close #10718

What is changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

Release note

None.

Summary by CodeRabbit

  • New Features

    • Add ability to update keyspace configuration with optional preconditions for conditional modifications.
    • Support clearing configuration keys by setting values to null; added an explicit operation to patch keyspace settings.
  • Bug Fixes

    • Improve handling of conflicting updates so precondition failures return conflict and are not retried.
  • Tests

    • Add integration tests covering config updates, precondition validation, conflict handling, and clearing config keys.

Review Change Stack

Signed-off-by: ystaticy <y_static_y@sina.com>
@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. dco-signoff: yes Indicates the PR's author has signed the dco. contribution This PR is from a community contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels May 26, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented May 26, 2026

Hi @ystaticy. Thanks for your PR.

I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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-sigs/prow repository.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 55b05b51-ef48-4a1e-80e8-6ff27eeb0c46

📥 Commits

Reviewing files that changed from the base of the PR and between 3761025 and ec75116.

📒 Files selected for processing (1)
  • client/http/client.go

📝 Walkthrough

Walkthrough

Adds HTTP-client support to patch keyspace configuration: new UpdateKeyspaceConfig method and helper, UpdateKeyspaceConfigParams with pointer-valued maps and optional preconditions, a request-name constant, centralized PB conversion, request-aware retry behavior, and an integration test exercising set, precondition failure, and clear flows.

Changes

Keyspace Config Update

Layer / File(s) Summary
Data contract and request constant
client/http/types.go, client/http/request_info.go
UpdateKeyspaceConfigParams uses map[string]*string for Config and optional Preconditions to preserve JSON null vs empty-string semantics. UpdateKeyspaceConfigName constant added.
HTTP client implementation
client/http/interface.go
Client gains UpdateKeyspaceConfig. Internal patchKeyspaceConfig helper marshals params and sends HTTP PATCH to the keyspace update URL. Public UpdateKeyspaceConfig delegates to the helper. UpdateKeyspaceGCManagementType refactored to reuse the helper. GetKeyspaceMetaByName/ID now return PB via toPB().
Request-aware retry handling
client/http/client.go
Replaces status-only retry checks with noNeedRetryForRequest(reqInfo, statusCode) and treats HTTP 409 for UpdateKeyspaceConfigName as non-retriable; backoff retryable checker updated accordingly.
Integration test coverage
tests/integrations/client/http_client_test.go
TestUpdateKeyspaceConfig exercises set-with-absent-precondition, verifies precondition-mismatch returns 409, and clears the config via nil value with matching precondition; validates persisted keyspace metadata.

Sequence Diagram

sequenceDiagram
  participant Caller
  participant UpdateKeyspaceConfig
  participant patchKeyspaceConfig
  participant HTTPClient

  Caller->>UpdateKeyspaceConfig: UpdateKeyspaceConfig(ctx, keyspaceName, params)
  UpdateKeyspaceConfig->>patchKeyspaceConfig: delegate (ctx, keyspaceName, params)
  patchKeyspaceConfig->>patchKeyspaceConfig: Marshal params to JSON
  patchKeyspaceConfig->>HTTPClient: PATCH GetUpdateKeyspaceConfigURL(keyspaceName)
  HTTPClient-->>patchKeyspaceConfig: response (updated keyspace meta) or error
  patchKeyspaceConfig-->>UpdateKeyspaceConfig: return PB or error
  UpdateKeyspaceConfig-->>Caller: return KeyspaceMeta or error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A patch hops softly through the night,
Pointers whisper whether nil or bright,
Preconditions guard the garden gate,
Tests chew conflicts, small and great,
Meta returns — tidy, just right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'http client: support update keyspce config' is directly related to the main change (adding UpdateKeyspaceConfig API to HTTP client), though it contains a typo ('keyspce' instead of 'keyspace').
Description check ✅ Passed The PR description follows the repository template and includes an issue reference (Close #10718), though the commit-message block is empty.
Linked Issues check ✅ Passed The code changes implement the objective from issue #10718 to support updating keyspace config in the HTTP interface, with a new UpdateKeyspaceConfig API and integration tests.
Out of Scope Changes check ✅ Passed All changes are within scope: new UpdateKeyspaceConfig API, supporting types/constants, refactoring of existing keyspace methods, and integration tests—all directly related to the linked issue objective.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@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 May 26, 2026
@bufferflies bufferflies added the ok-to-test Indicates a PR is ready to be tested. label May 26, 2026
@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels May 26, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 92.10526% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.09%. Comparing base (c313b99) to head (ec75116).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10717      +/-   ##
==========================================
+ Coverage   79.07%   79.09%   +0.01%     
==========================================
  Files         536      536              
  Lines       73307    73690     +383     
==========================================
+ Hits        57971    58287     +316     
- Misses      11233    11285      +52     
- Partials     4103     4118      +15     
Flag Coverage Δ
unittests 79.09% <92.10%> (+0.01%) ⬆️

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ystaticy
Copy link
Copy Markdown
Contributor Author

/retest

@ti-chi-bot ti-chi-bot Bot removed the needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. label May 26, 2026
@bufferflies
Copy link
Copy Markdown
Contributor

/retest

Comment thread client/http/interface.go Outdated

// UpdateKeyspaceConfig patches the keyspace config.
func (c *client) UpdateKeyspaceConfig(ctx context.Context, keyspaceName string, params *UpdateKeyspaceConfigParams) error {
return c.updateKeyspaceConfig(ctx, UpdateKeyspaceConfigName, keyspaceName, params)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please consider the retry semantics for 409 Conflict here. A keyspace config precondition failure is returned by the server as 409, and this is a deterministic CAS failure, so it should not be retried against other PD members. The current HTTP client noNeedRetry only includes 400/403/404, so this PATCH will continue to be sent to subsequent endpoints after a 409. That can duplicate the same failed semantic request and logs. I suggest either disabling 409 retry for this API, or adding http.StatusConflict to noNeedRetry after confirming no other API relies on retrying 409.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@lhy1024 Modifying noNeedRetry requires further discussion; it's better not to include it in this PR.

Comment thread client/http/interface.go Outdated
Signed-off-by: ystaticy <y_static_y@sina.com>
@ystaticy ystaticy changed the title add update keyspce config http client: support update keyspce config May 29, 2026
ystaticy added 2 commits May 29, 2026 16:58
Signed-off-by: ystaticy <y_static_y@sina.com>
Signed-off-by: ystaticy <y_static_y@sina.com>
@ystaticy
Copy link
Copy Markdown
Contributor Author

/retest-required

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 1, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Jun 1, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bufferflies, lhy1024

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [bufferflies,lhy1024]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Jun 1, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-05-26 10:26:37.159089163 +0000 UTC m=+347867.129254219: ☑️ agreed by bufferflies.
  • 2026-06-01 02:50:45.604525123 +0000 UTC m=+150746.674842503: ☑️ agreed by lhy1024.

@bufferflies
Copy link
Copy Markdown
Contributor

/retest

@lhy1024
Copy link
Copy Markdown
Member

lhy1024 commented Jun 1, 2026

/retest

@ystaticy
Copy link
Copy Markdown
Contributor Author

ystaticy commented Jun 1, 2026

/test pull-unit-test-next-gen-3

@bufferflies
Copy link
Copy Markdown
Contributor

/retest

@ti-chi-bot ti-chi-bot Bot merged commit 3ef6a3b into tikv:master Jun 1, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved contribution This PR is from a community contributor. dco-signoff: yes Indicates the PR's author has signed the dco. lgtm ok-to-test Indicates a PR is ready to be tested. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support update keyspce config in http interface

3 participants