Skip to content
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

[ISSUE #176] Support manage multi cluster #183

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

drivebyer
Copy link
Contributor

@drivebyer drivebyer commented Sep 28, 2023

What is the purpose of the change

In order to manage multi cluster by one operator.

task1 && task2 of #176

Brief changelog

XX

Verifying this change

  1. tested against old cluster()

  2. tested against creating two cluster in one namespace
    yaml1(set rocketmq cluster name to empty string): https://gist.github.com/drivebyer/8795a96966be4fd6ebf395cc347a159d
    yaml2(set rocketmq cluster name to test-rocketmq): https://gist.github.com/drivebyer/338a0cba168249dd3c02ce0f33f775d8

Please go through this checklist to help us incorporate your contribution quickly and easily.

Notice: It would be helpful if you could finish the following checklist (the last one is not necessary) before request the community to review your PR.

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Check RBAC rights for Kubernetes roles.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist.
  • Run make docker-build to build docker image for operator, try your changes from Pod inside your Kubernetes cluster, not just locally. Also provide screenshots to show that the RocketMQ cluster is healthy after the changes.
  • Before committing your changes, remember to run make manifests to make sure the CRD files are updated.
  • Update documentation if necessary.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@drivebyer
Copy link
Contributor Author

@caigy PTAL

Copy link
Contributor

@caigy caigy left a comment

Choose a reason for hiding this comment

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

It seems that there're lots of modifications in this pr, you'd better add some doc for your design, especially for the changes in CRs reflecting the status of all modules in the RocketMQ cluster.

Comment on lines +70 to +81
err := mgr.GetFieldIndexer().IndexField(context.TODO(), &rocketmqv1alpha1.NameService{}, rocketmqv1alpha1.NameServiceRocketMqNameIndexKey,
func(rawObj client.Object) []string {
n, ok := rawObj.(*rocketmqv1alpha1.NameService)
if !ok {
return nil
}
return []string{n.Spec.RocketMqName + "-" + n.Namespace}
},
)
if err != nil {
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the usage of this block? You'd better show more about your design.

Comment on lines +243 to +248
// get cluster of output
clusterName := ""
for _, line := range strings.Split(string(clusterListOutput), "\n") {
if strings.HasPrefix(line, "#Cluster Name") {
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not stable to get cluster name by analyzing the output of a command.

// #Cluster Name #Broker Name #BID #Addr #Version #InTPS(LOAD) #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE
// broker broker-0 0 192.168.180.40:10911 V4_5_0 0.00(0,0ms) 0.00(0,0ms) 0 471030.34 -1.0000
// broker broker-0 1 192.168.137.89:10911 V4_5_0 0.00(0,0ms) 0.00(0,0ms) 0 471030.34 0.2673
clusterListCmd := exec.Command("sh", cons.AdminToolDir, cons.ClusterList, "-n", oldNameServerListStr)
Copy link
Contributor

Choose a reason for hiding this comment

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

As isNameServersStrUpdated is true, why using oldNameServerListStr as the addresses of name servers?

Comment on lines +264 to +265
command := mqAdmin + " " + subCmd + " -c " + clusterName + " -k " + key + " -n " + oldNameServerListStr + " -v " + newNameServerListStr
cmd := exec.Command("sh", mqAdmin, subCmd, "-c", clusterName, "-k", key, "-n", oldNameServerListStr, "-v", newNameServerListStr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Only brokers registering successfully to name servers can receive the command, others will not be updated.

Comment on lines -244 to -248
runningNameServerNum := getRunningNameServersNum(podList.Items)
if runningNameServerNum == instance.Spec.Size {
share.IsNameServersStrInitialized = true
share.NameServersStr = nameServerListStr // reassign if operator restarts
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this block be safely removed?

@drivebyer
Copy link
Contributor Author

It seems that there're lots of modifications in this pr, you'd better add some doc for your design, especially for the changes in CRs reflecting the status of all modules in the RocketMQ cluster.

OK, i would add this.

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