Skip to content

feat(tikv): add worker ref#6624

Merged
ti-chi-bot[bot] merged 3 commits intopingcap:mainfrom
liubog2008:liubo02/add-worker-ref
Dec 24, 2025
Merged

feat(tikv): add worker ref#6624
ti-chi-bot[bot] merged 3 commits intopingcap:mainfrom
liubog2008:liubo02/add-worker-ref

Conversation

@liubog2008
Copy link
Member

@liubog2008 liubog2008 commented Dec 24, 2025

Support ref worker in tikv

Signed-off-by: liubo02 <liubo02@pingcap.com>
@ti-chi-bot ti-chi-bot bot requested a review from howardlau1999 December 24, 2025 02:29
@github-actions github-actions bot added the v2 for operator v2 label Dec 24, 2025
@ti-chi-bot ti-chi-bot bot added the size/XL label Dec 24, 2025
@fgksgf fgksgf requested a review from Copilot December 24, 2025 02:30
@ti-chi-bot ti-chi-bot bot added the lgtm label Dec 24, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 24, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-12-24 02:31:40.408892974 +0000 UTC m=+2217845.222670546: ☑️ agreed by srstack.

@ti-chi-bot ti-chi-bot bot added the approved label Dec 24, 2025
@codecov-commenter
Copy link

codecov-commenter commented Dec 24, 2025

Codecov Report

❌ Patch coverage is 4.28571% with 67 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.42%. Comparing base (d6eb797) to head (fbd912d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6624      +/-   ##
==========================================
- Coverage   39.53%   39.42%   -0.12%     
==========================================
  Files         351      351              
  Lines       20659    20722      +63     
==========================================
+ Hits         8167     8169       +2     
- Misses      12492    12553      +61     
Flag Coverage Δ
unittest 39.42% <4.28%> (-0.12%) ⬇️

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for referencing remote workers in TiKV configurations, allowing TiKV instances to delegate work to separate worker groups for coprocessor, compactor, and worker operations. This is a feature specifically designed for the "nextgen" architecture.

Key Changes

  • Added new API types for worker references (CoprocessorReference, CompactorReference, WorkerReference) to the TiKV spec
  • Implemented TiKV configuration generation to connect to remote worker services via internal ClusterIP services
  • Created an internal service for TiKVWorkerGroup to enable service-based communication (in addition to the existing headless service)

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
api/core/v1alpha1/tikv_types.go Defines RemoteWorkers field and reference types for TiKV template spec
api/core/v1alpha1/zz_generated.deepcopy.go Auto-generated deepcopy methods for new worker reference types
manifests/crd/core.pingcap.com_tikvs.yaml CRD schema additions for remoteWorkers field in TiKV spec
manifests/crd/core.pingcap.com_tikvgroups.yaml CRD schema additions for remoteWorkers field in TiKVGroup spec
pkg/configs/tikv/config.go Configures TiKV to connect to remote worker URLs based on references
pkg/apiutil/core/v1alpha1/tikv_worker.go Helper functions to generate worker service URLs with appropriate paths
pkg/apiutil/core/v1alpha1/group.go Added InternalServiceName helper for generating worker service names
pkg/controllers/tikvworkergroup/tasks/svc.go Creates both headless and internal services for TiKV worker groups
tests/e2e/framework/desc/options.go Added EnableTiKVWorkers option for E2E tests
tests/e2e/framework/desc/patch.go Applies worker configuration patches when option is enabled
tests/e2e/data/tikv.go Test helper to configure all three worker references for TiKV
tests/e2e/suite/cluster/tls.go Enables worker configuration in TLS test scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

PreStop *TiKVPreStop `json:"preStop,omitempty"`

// RemoteWorkers defines remote workers used by this tikv
// It's only worked for nextgen
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

Grammatical error in the comment. It should be "It only works for nextgen" instead of "It's only worked for nextgen".

Suggested change
// It's only worked for nextgen
// It only works for nextgen

Copilot uses AI. Check for mistakes.
}
name := tikv.Spec.RemoteWorkers.Coprocessor.Name
c.KVEngine.RemoteCoprocessorAddr = coreutil.TiKVWorkerCoprocessorURL(name, tikv.Namespace, tls)
c.KVEngine.RemoteWorkerAddr = coreutil.TiKVWorkerCoprocessorURL(name, tikv.Namespace, tls)
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The RemoteWorkerAddr is incorrectly set to TiKVWorkerCoprocessorURL which includes a "/coprocessor" path suffix. When both Coprocessor and Worker references point to the same worker group, RemoteWorkerAddr should either use a different URL path or the base URL without the "/coprocessor" suffix. This assignment appears redundant with line 108 and may cause the worker configuration to be incorrect.

Suggested change
c.KVEngine.RemoteWorkerAddr = coreutil.TiKVWorkerCoprocessorURL(name, tikv.Namespace, tls)

Copilot uses AI. Check for mistakes.
c.KVEngine = &KVEngine{}
}
name := tikv.Spec.RemoteWorkers.Worker.Name
c.KVEngine.RemoteWorkerAddr = coreutil.TiKVWorkerCoprocessorURL(name, tikv.Namespace, tls)
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The RemoteWorkerAddr is set using TiKVWorkerCoprocessorURL which includes a "/coprocessor" path suffix. This appears incorrect for a Worker reference configuration. The function should either be renamed or a separate TiKVWorkerURL function should be created to provide the appropriate endpoint for worker configuration.

Suggested change
c.KVEngine.RemoteWorkerAddr = coreutil.TiKVWorkerCoprocessorURL(name, tikv.Namespace, tls)
c.KVEngine.RemoteWorkerAddr = coreutil.TiKVWorkerURL(name, tikv.Namespace, tls)

Copilot uses AI. Check for mistakes.
Ports: []corev1.ServicePort{
{
Name: v1alpha1.TiKVWorkerPortNameAPI,
Port: v1alpha1.DefaultTiKVWorkerPortAPI,
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The internal service uses a hardcoded default port instead of respecting custom port configuration. This is inconsistent with other components like PDGroup and TiDBGroup, which use dynamic port helper functions. The port should be retrieved using coreutil.TiKVWorkerGroupAPIPort(wg) to respect custom port configurations if specified.

Suggested change
Port: v1alpha1.DefaultTiKVWorkerPortAPI,
Port: coreutil.TiKVWorkerGroupAPIPort(wg),

Copilot uses AI. Check for mistakes.
return task.Fail().With(fmt.Sprintf("can't create internal service of tikv worker: %v", err))
}

return task.Complete().With("services of tikv worker has been applied")
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The success message has a grammatical error. It should be "services of tikv worker have been applied" (plural "have" to agree with plural "services").

Suggested change
return task.Complete().With("services of tikv worker has been applied")
return task.Complete().With("services of tikv worker have been applied")

Copilot uses AI. Check for mistakes.
Signed-off-by: liubo02 <liubo02@pingcap.com>
Signed-off-by: liubo02 <liubo02@pingcap.com>
@fgksgf
Copy link
Member

fgksgf commented Dec 24, 2025

/lgtm

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 24, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fgksgf, srstack

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:

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

@liubog2008
Copy link
Member Author

/test pull-e2e

@ti-chi-bot ti-chi-bot bot merged commit 0b281f7 into pingcap:main Dec 24, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants