Skip to content

Conversation

@bseto
Copy link
Contributor

@bseto bseto commented Apr 30, 2025

This PR addresses #214 somewhat.

From my understanding the current flow in the controller is:

# Step 1
clusterx migrate <slot range> <ID>  # to trigger a migration
# Step 2 - eventually after migration is over
clusterx setslot <slot range> <ID>  # to set the topology

These changes do not allow for:

  1. The input parameter to accept multiple ranges
  2. The range to stretch across multiple source shards.

This way, the controller does not need to be modified to perform multiple step 1s followed by step 2s

The main change is that MigrateSlotRequest accepts a SlotRange instead of a int.
slot = -1 used to mean no migration is happening. Now slot = nil is the equivalent.

// from
type MigrateSlotRequest struct {
	Target   int  `json:"target" validate:"required"`
	Slot     int  `json:"slot" validate:"required"`
	SlotOnly bool `json:"slot_only"`
}
// to
type MigrateSlotRequest struct {
	Target   int             `json:"target" validate:"required"`
	Slot     store.SlotRange `json:"slot" validate:"required"`
	SlotOnly bool            `json:"slot_only"`
}

@codecov-commenter
Copy link

codecov-commenter commented May 1, 2025

Codecov Report

❌ Patch coverage is 57.94393% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.11%. Comparing base (6c56470) to head (ef36d24).
⚠️ Report is 79 commits behind head on unstable.

Files with missing lines Patch % Lines
store/slot.go 77.46% 14 Missing and 2 partials ⚠️
controller/cluster.go 0.00% 14 Missing ⚠️
cmd/client/command/migrate.go 0.00% 5 Missing ⚠️
store/cluster.go 37.50% 4 Missing and 1 partial ⚠️
cmd/client/command/helper.go 0.00% 2 Missing ⚠️
store/cluster_node.go 33.33% 2 Missing ⚠️
store/cluster_shard.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #304      +/-   ##
============================================
+ Coverage     43.38%   46.11%   +2.73%     
============================================
  Files            37       45       +8     
  Lines          2971     4341    +1370     
============================================
+ Hits           1289     2002     +713     
- Misses         1544     2131     +587     
- Partials        138      208      +70     
Flag Coverage Δ
unittests 46.11% <57.94%> (+2.73%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@git-hulk
Copy link
Member

git-hulk commented May 1, 2025

@bseto Thanks for your contribution.

@git-hulk git-hulk requested review from Copilot, git-hulk and torwig and removed request for git-hulk May 1, 2025 07:39
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 refactors the migration functionality so that slot migration now works via slot ranges instead of individual slot IDs. The key changes include updating the MigrateSlotRequest type and its usage, refactoring various slot range functions (e.g., ParseSlotRange, AddSlotToSlotRanges, RemoveSlotFromSlotRanges), and adjusting associated tests and logging throughout the controller and client layers.

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
store/slot_test.go Updated tests for ParseSlotRange and slot range addition/removal logic
store/slot.go Refactored slot range operations, including parsing and merging
store/cluster_shard.go Updated Shard type to use pointer SlotRange for migrating slot
store/cluster_node.go Changed MigrateSlot signature to use SlotRange
store/cluster.go Updated shard lookup and migration logic to work with SlotRange
server/api/.go & controller/.go Adjusted API endpoints, logging, and tests to operate on slot ranges
cmd/client/command/*.go Modified CLI migration command to use string slot range input
consts/errors.go Added error definitions relevant to new slot range migration

@git-hulk
Copy link
Member

git-hulk commented May 1, 2025

@bseto Thank you! Looks good to me. I will give a shot on my side.

@git-hulk git-hulk changed the title adds ability to migrate by slot, or slot range Add support of migrating with slot range May 1, 2025
Co-authored-by: hulk <hulk.website@gmail.com>
@git-hulk git-hulk merged commit a6334b3 into apache:unstable May 3, 2025
4 checks passed
@git-hulk
Copy link
Member

git-hulk commented May 3, 2025

@bseto Thank you!

@bseto
Copy link
Contributor Author

bseto commented May 3, 2025

@bseto Thank you!

No problem!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants