Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 16, 2025

Problem

When bug fixes are made to the PD client (which lives in the tikv/pd repository), it's easy to forget to update TiDB's or client-go's dependency on PD. This can result in fixes not taking effect in downstream projects, leading to continued bugs and inconsistent behavior.

Solution

This PR adds a postsubmit job for the tikv/pd repository that automatically creates pull requests in the pingcap/tidb repository when changes are merged to PD.

The job:

  • Triggers on pushes to master and release-* branches in tikv/pd
  • Only triggers when code changes in the client/ folder (using run_if_changed: "^client/.*$")
  • Clones the pingcap/tidb repository with the same target branch as the PD push
  • Updates the github.com/tikv/pd/client dependency to the latest version from that branch
  • Runs go mod tidy to update go.sum
  • Automatically creates a pull request in pingcap/tidb with the updated dependency

Implementation

Created prow-jobs/tikv/pd/common-postsubmits.yaml following the exact same pattern as the existing auto-update-ticdc-gomod job in prow-jobs/pingcap/tiflow/common-postsubmits.yaml. This ensures consistency with established patterns in the codebase.

The job uses:

  • golang:1.23 container image
  • GitHub CLI (gh) for PR creation
  • GitHub token from Kubernetes secrets for authentication
  • Smart skipping when only documentation or image files change
  • Efficient triggering that only runs when the client/ folder is modified

Example Workflow

When a change is merged to the client/ folder in tikv/pd on the release-8.1 branch:

  1. The postsubmit job is triggered
  2. Job clones pingcap/tidb at release-8.1 branch
  3. Job updates the PD client dependency to the latest version from release-8.1
  4. Job creates a PR in pingcap/tidb targeting release-8.1 with the title: chore(deps): bump go mod github.com/tikv/pd/client

This automation ensures that bug fixes and improvements in the PD client are quickly propagated to TiDB, reducing the risk of stale dependencies and ensuring fixes take effect promptly.

Fixes #1074

<issue_title>Automatically update pd client dependency</issue_title>
><issue_description>When we do some bug fixes on the PD client, which is inside the pd repo. It is easy to forget to update TiDB's/client-go's dependency. This might result in the fix not taking effect. So it's better to make it automatically triggered.</issue_description>
>
><agent_instructions>do it like the job we did in file: prow-jobs/pingcap/tiflow/common-postsubmits.yaml
>
> set the post submit job for tikv/pd repo to make it auto create PR to pingcap/tidb repo with the same target branch</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
>
>
>

Fixes #3817

Original prompt

This section details on the original issue you should resolve

<issue_title>Automatically update pd client dependency</issue_title>
<issue_description>When we do some bug fixes on the PD client, which is inside the pd repo. It is easy to forget to update TiDB's/client-go's dependency. This might result in the fix not taking effect. So it's better to make it automatically triggered.</issue_description>

<agent_instructions>do it like the job we did in file: prow-jobs/pingcap/tiflow/common-postsubmits.yaml

set the post submit job for tikv/pd repo to make it auto create PR to pingcap/tidb repo with the same target branch</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #3817


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 16, 2025

Hi @Copilot. Thanks for your PR.

I'm waiting for a PingCAP-QE 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.

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.

Copilot AI changed the title [WIP] Automatically update pd client dependency Add automatic PD client dependency update job for TiDB Oct 16, 2025
Copilot AI requested a review from wuhuizuo October 16, 2025 09:42
Copilot finished work on behalf of wuhuizuo October 16, 2025 09:42
@wuhuizuo
Copy link
Collaborator

@copilot some updates should be made:

  1. the dep module name used in pingcap/tidb is github.com/tikv/pd/client.
  2. maybe we should only trigger the job when the code changed in client folder of tikv/pd repo.

Copy link
Contributor Author

Copilot AI commented Oct 16, 2025

@copilot some updates should be made:

  1. the dep module name used in pingcap/tidb is github.com/tikv/pd/client.
  2. maybe we should only trigger the job when the code changed in client folder o...

Updated in commit 7c8c5d9:

  1. Changed the module name from github.com/tikv/pd to github.com/tikv/pd/client (the actual module used by TiDB)
  2. Added run_if_changed: "^client/.*$" to trigger the job only when code in the client folder of tikv/pd repo changes

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/tikv/pd/contents
    • Triggering command: curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of wuhuizuo October 16, 2025 09:58
@wuhuizuo wuhuizuo marked this pull request as ready for review October 16, 2025 10:19
@wuhuizuo wuhuizuo changed the title Add automatic PD client dependency update job for TiDB feat(prow-jobs/tikv/pd): add automatic PD client dependency update job for TiDB Oct 16, 2025
Copy link

@ti-chi-bot ti-chi-bot bot left a comment

Choose a reason for hiding this comment

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

I have already done a preliminary review for you, and I hope to help you do a better job.

Summary

This pull request adds an automatic PD client dependency update job for TiDB to ensure downstream projects receive bug fixes promptly. The approach involves creating a postsubmit job in the tikv/pd repository that triggers when changes are made to the client/ folder, updating the dependency in pingcap/tidb, and creating a pull request automatically. The implementation follows established patterns and uses efficient triggering mechanisms. Overall, the quality of the changes is good with a clear focus on automation and consistency.

Critical Issues

  • No critical issues found.

Code Improvements

  • prow-jobs/kustomization.yaml:

    • Consider grouping related files together for better organization in the kustomization file.
    • Ensure consistency in the naming convention for added entries.
  • prow-jobs/tikv/pd/common-postsubmits.yaml:

    • Break down the long args section into separate lines for better readability.
    • Separate the logic for installing gh tool into a separate script or command for better maintainability.
    • Refactor the script to handle errors and edge cases more robustly, such as checking for successful commands before proceeding.
    • Consider extracting repetitive parts into functions to reduce duplication and improve maintainability.
    • Enhance the PR description generation by dynamically fetching the issue number instead of hardcoding it.

Best Practices

  • prow-jobs/tikv/pd/common-postsubmits.yaml:
    • Add comments to explain complex or critical sections of the script for better understanding.
    • Ensure consistent indentation and formatting throughout the file.
    • Enhance the error messages and logging to aid in troubleshooting and debugging.
    • Consider adding unit tests for the job logic to ensure its correctness and robustness.
    • Follow naming conventions for variables and functions to maintain code clarity and consistency.
    • Document the environment variables used in the job configuration for better visibility and understanding.

By addressing the code improvements and best practices suggestions, the automation job can be made more maintainable, reliable, and easier to understand for future modifications or enhancements.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 17, 2025

@rleungx: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

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.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 17, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rleungx
Once this PR has been reviewed and has the lgtm label, please ask for approval from wuhuizuo. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

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

Needs approval from an approver in each of these files:

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

@wuhuizuo wuhuizuo marked this pull request as draft October 20, 2025 09:07
@wuhuizuo
Copy link
Collaborator

wuhuizuo commented Oct 20, 2025

We need to consider the updating of bazel files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Automatically update pd client dependency

3 participants