Skip to content

Add deployment mode switching for QueryNode #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hodie-aurora
Copy link
Contributor

Overview

This PR introduces the functionality to switch between single deployment mode (OneDeployMode) and dual deployment mode (TwoDeployMode) for the QueryNode component in Milvus. This is the first part of addressing issue #298.

Changes

  • Feature Description:
    • Added a DeployMode field to the MilvusQueryNode struct in the v1beta1 package, supporting configurations for "OneDeployMode" or "TwoDeployMode", with a default value of "TwoDeployMode".
    • Modified the Reconcile method in DeployControllerImpl to reconcile the QueryNode based on the configured deployment mode.
    • Implemented ChangeToOneDeployMode and ChangeToTwoDeployMode methods in DeployControllerBizImpl to manage the switching of deployment modes.
  • Testing:
    • Added new test cases in deploy_ctrl_test.go to verify the logic for deployment mode switching.
    • Modified some existing test cases to accommodate the new functionality.

Purpose

  • The dual deployment mode is necessary in certain scenarios (e.g., when using HPA) to avoid issues during rolling updates.
  • This change allows users to flexibly configure the deployment mode of QueryNode based on their needs.

Notes

  • I have made some modifications to the existing test code to adapt to the new feature. However, I am unsure if these changes fully comply with the project's testing standards, so I would appreciate feedback from the reviewers.
  • The HPA-related functionality (further integration with deployment mode switching) will be addressed in a subsequent PR after this one is reviewed and merged.

Related Issue

Request

Please review the code, especially the modifications to the test cases, to ensure they meet the standards. If everything is in order, I will proceed with the HPA-related deployment mode switching functionality in the next PR after this one is merged. Thank you!

@sre-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hodie-aurora
To complete the pull request process, please assign haorenfsa after the PR has been reviewed.
You can assign the PR to them by writing /assign @haorenfsa in a comment when ready.

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

Copy link

codecov bot commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 83.75635% with 32 lines in your changes missing coverage. Please review.

Project coverage is 75.89%. Comparing base (01440d5) to head (85321bd).

Files with missing lines Patch % Lines
pkg/controllers/deploy_ctrl.go 78.35% 22 Missing and 7 partials ⚠️
pkg/controllers/deploy_mode_changer.go 95.23% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #320      +/-   ##
==========================================
- Coverage   76.15%   75.89%   -0.26%     
==========================================
  Files          64       64              
  Lines        6761     6958     +197     
==========================================
+ Hits         5149     5281     +132     
- Misses       1406     1465      +59     
- Partials      206      212       +6     

☔ 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.

@hodie-aurora hodie-aurora force-pushed the feat/querynode-deploymode branch from e55bae9 to 847f2fc Compare April 15, 2025 09:19
@haorenfsa
Copy link
Collaborator

Thank you very much, @hodie-aurora! I'm a bit occupied with other stuffs, will review it soon

@haorenfsa haorenfsa requested a review from Copilot April 16, 2025 02:50
Copy link

@Copilot 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 introduces deployment mode switching for the QueryNode component by adding a new DeployMode field and corresponding reconciliation logic to enable switching between single (OneDeployMode) and dual (TwoDeployMode) deployment modes. Key changes include modifications to the controller logic for deployment mode reconciliation, new methods for switching deployment modes, and extensive test cases covering various operational scenarios.

Reviewed Changes

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

File Description
pkg/controllers/deploy_mode_changer_test.go Added tests for ChangeToOneDeployMode with various scenarios, including error simulation.
pkg/controllers/deploy_mode_changer.go Implemented ChangeToOneDeployMode logic for handling QueryNode mode switching in single deployment.
pkg/controllers/deploy_ctrl.go Integrated deployment mode switching in the Reconcile flow and added parsing and error handling.
apis/milvus.io/v1beta1/components_types.go Added DeployMode field in MilvusQueryNode with accompanying kubebuilder validations and defaults.
Comments suppressed due to low confidence (2)

pkg/controllers/deploy_mode_changer_test.go:381

  • [nitpick] Consider extracting the deployment name format into a shared constant for consistency and easier maintenance across both test and production code.
currentDeployName := fmt.Sprintf("%s-%s-0", QueryNode.Name, mc.Name)

pkg/controllers/deploy_mode_changer.go:232

  • [nitpick] Extract the deployment naming pattern into a constant to ensure consistent formatting and reduce the risk of mismatches when referenced elsewhere.
currentDeployName := fmt.Sprintf("%s-%s-0", c.component.Name, mc.Name)

@hodie-aurora
Copy link
Contributor Author

@haorenfsa Thanks for the quick response and for taking the time to review,No rush at all, please handle your other tasks first. This is my first code-related PR to Milvus, so if I’ve made any mistakes (like the extra commits from #291), I really appreciate your patience and guidance. Thanks again for your support!

// +kubebuilder:validation:Enum=OneDeployMode;TwoDeployMode
// +kubebuilder:default:=TwoDeployMode
// +kubebuilder:validation:Optional
DeployMode string `json:"deployMode,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

You also need to run make generate-all after you changed the CRD.

@@ -50,6 +50,48 @@ func (c *DeployControllerImpl) Reconcile(ctx context.Context, mc v1beta1.Milvus,
return errors.Wrap(err, "update milvus rolling mode status")
}
biz := c.bizFactory.GetBiz(component)
// Reconcile QueryNode deploy mode
if component == QueryNode {
Copy link
Collaborator

@haorenfsa haorenfsa Apr 17, 2025

Choose a reason for hiding this comment

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

you may move the code inside to a function named like ReconcileQueryNode() to avoid making Reconcile() too long.

if err != nil {
return errors.Wrap(err, "scale down old deployment")
}
err = c.cli.Delete(ctx, oldDeploy)
Copy link
Collaborator

@haorenfsa haorenfsa Apr 17, 2025

Choose a reason for hiding this comment

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

I think the Above Update() is redundant. You can delete it directly, the pods will also be scaled down.

@hodie-aurora
Copy link
Contributor Author

@haorenfsa Thank you for your guidance! I will make the suggested changes as soon as possible. I appreciate your time and effort in reviewing this PR.

@hodie-aurora hodie-aurora force-pushed the feat/querynode-deploymode branch from 847f2fc to 85321bd Compare April 28, 2025 07:00
- Added DeployMode field to MilvusQueryNode struct to support OneDeployMode and TwoDeployMode
- Modified DeployControllerImpl to reconcile QueryNode deployment mode based on configuration
- Implemented ChangeToOneDeployMode and ChangeToTwoDeployMode in DeployControllerBizImpl
- Updated test cases in deploy_ctrl_test.go to cover deployment mode switching

Signed-off-by: hodie-aurora <zhw1726195788@gmail.com>
@hodie-aurora hodie-aurora force-pushed the feat/querynode-deploymode branch from 85321bd to 186cfb1 Compare April 29, 2025 06:20
Signed-off-by: hodie-aurora <zhw1726195788@gmail.com>
@hodie-aurora hodie-aurora force-pushed the feat/querynode-deploymode branch from 186cfb1 to 3e6cf9a Compare April 29, 2025 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants