Skip to content

Conversation

@Jitmisra
Copy link
Contributor

implemented cluster slot migration

Monosnap.screencast.2025-08-17.15-22-02.mp4

@PragmaTwice
Copy link
Member

Looks great!

https://github.com/apache/kvrocks-controller/blob/unstable/server/api/cluster.go#L38

Seems currently we support to migrate a "slot range" than a single slot, maybe we can support that in the UI?

@Jitmisra
Copy link
Contributor Author

Looks great!

https://github.com/apache/kvrocks-controller/blob/unstable/server/api/cluster.go#L38

Seems currently we support to migrate a "slot range" than a single slot, maybe we can support that in the UI?

sure done👍🏻

@PragmaTwice PragmaTwice requested a review from Copilot August 19, 2025 11:46
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 implements cluster slot migration functionality in the web UI by adding a new migration dialog component and integrating it with the existing cluster management page. The implementation allows users to migrate slots between shards through a dedicated dialog interface.

Key changes:

  • Added a new MigrationDialog component with comprehensive UI for slot migration configuration
  • Updated the cluster page to handle string-based slot values instead of numeric values for migration tracking
  • Modified the API call to properly handle slot ranges as strings

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
webui/src/app/ui/migrationDialog.tsx New component implementing the slot migration dialog with validation and UI controls
webui/src/app/namespaces/[namespace]/clusters/[cluster]/page.tsx Updated to integrate migration dialog and handle string-based slot values
webui/src/app/lib/api.ts Modified migrateSlot function to accept slot parameter as string instead of number

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


interface Shard {
index: number;
nodes: any[];
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The nodes property uses any[] type which provides no type safety. Consider defining a proper interface for node objects to improve type safety and code maintainability.

Suggested change
nodes: any[];
// Define the Node interface. Update properties as needed to match actual node structure.
interface Node {
// Example properties; replace with actual node properties as appropriate.
id: string;
address: string;
role: string;
[key: string]: any; // Remove or refine as you learn more about node structure.
}
interface Shard {
index: number;
nodes: Node[];

Copilot uses AI. Check for mistakes.
resetForm();
}
} catch (err) {
setError("An unexpected error occurred during migration");
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The generic error message doesn't provide useful information to users. Consider logging the actual error details and providing a more specific error message based on the error type.

Suggested change
setError("An unexpected error occurred during migration");
// Log the actual error for debugging
console.error("Migration error:", err);
// Show a more specific error message if available
if (err && typeof err === "object" && "message" in err && typeof (err as any).message === "string") {
setError((err as any).message);
} else {
setError("An unexpected error occurred during migration");
}

Copilot uses AI. Check for mistakes.
fetchData();
}, [namespace, cluster, router]);

const refreshShardData = async () => {
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The refreshShardData function duplicates the shard data processing logic from the main fetchData function. Consider extracting the common processing logic into a shared helper function to reduce code duplication.

Copilot uses AI. Check for mistakes.
};
}

if (start < 0 || end > 16383 || start > 16383 || end < 0) {
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The condition start > 16383 || end < 0 is redundant as it's already covered by start < 0 || end > 16383. This can be simplified to improve readability.

Suggested change
if (start < 0 || end > 16383 || start > 16383 || end < 0) {
if (start < 0 || end > 16383) {

Copilot uses AI. Check for mistakes.
@PragmaTwice
Copy link
Member

./src/app/ui/formCreation.tsx:372:72
Type error: Argument of type 'number' is not assignable to parameter of type 'string'.

  370 |         }
  371 |
> 372 |         const response = await migrateSlot(namespace, cluster, target, slot, slotOnly);
      |                                                                        ^
  373 |         if (response === "") {
  374 |             window.location.reload();
  375 |         } else {

There is a type error. Could you fix it?

@Jitmisra
Copy link
Contributor Author

Jitmisra commented Aug 19, 2025

./src/app/ui/formCreation.tsx:372:72
Type error: Argument of type 'number' is not assignable to parameter of type 'string'.

  370 |         }
  371 |
> 372 |         const response = await migrateSlot(namespace, cluster, target, slot, slotOnly);
      |                                                                        ^
  373 |         if (response === "") {
  374 |             window.location.reload();
  375 |         } else {

There is a type error. Could you fix it?

yes slot.toString() done in commit [TypeScript error fix]

@codecov-commenter
Copy link

codecov-commenter commented Aug 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.16%. Comparing base (6c56470) to head (275ee36).
⚠️ Report is 85 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #341      +/-   ##
============================================
+ Coverage     43.38%   47.16%   +3.77%     
============================================
  Files            37       45       +8     
  Lines          2971     4425    +1454     
============================================
+ Hits           1289     2087     +798     
- Misses         1544     2129     +585     
- Partials        138      209      +71     
Flag Coverage Δ
unittests 47.16% <ø> (+3.77%) ⬆️

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.

@PragmaTwice PragmaTwice merged commit 0cffae9 into apache:unstable Aug 19, 2025
4 checks passed
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