[ISSUE 57] add rocketmq api - #63
Conversation
4b07bd0 to
6b7520f
Compare
|
@linjiemiao ping, could you please help to resolve the conflict. |
Okay, I will cherry-pick your latest commit, and then I resolve the conflict. |
|
still need this |
|
This PR has conflicts with the base branch and cannot be merged. Please rebase or merge the base branch into your branch and resolve the conflicts: git fetch origin
git checkout issue-57-dev
git rebase origin/main
# resolve conflicts, then:
git push --force-with-leaseThis is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved. Automated notification by github-manager-bot |
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR modifies 10 file(s) with 1043 lines of diff. No test changes detected — consider adding test coverage.
Automated review by github-manager-bot
Additional notes (not anchored to a changed line)
- [INFO]
README.md:1— Large diff (1043 lines). Consider breaking into smaller, focused PRs for easier review. (line outside diff)
| @@ -33,7 +33,7 @@ type BrokerSpec struct { | |||
| // Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html | |||
There was a problem hiding this comment.
No test changes detected alongside source modifications. Consider adding tests to cover the changes.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
PR received and logged for review. This PR requires detailed code review by a maintainer.
Diff size: 1043 lines
Author: linjiemiao (NONE)
Automated review by RockteMQ-AI
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Review of PR #63: [ISSUE 57] add rocketmq api
Findings: 13 issue(s) identified (3 critical).
CLA: unknown
Please address the inline comments above.
Automated review by github-manager-bot
| brokerSts.Namespace, "broker.Name", brokerSts.Name) | ||
| } | ||
| return reconcile.Result{Requeue: true}, nil | ||
| } else if err != nil { |
There was a problem hiding this comment.
Broker creation error is logged but not returned. The function returns reconcile.Result{Requeue: true}, nil which discards the error, defeating the controller-runtime's exponential backoff retry mechanism. The error should be returned so the framework can properly retry with backoff.
| } else { | ||
| // Resource broker will change; Only ReplicaPerGroup Size ImagePullPolicy BrokerImage can update | ||
| if !reflect.DeepEqual(brokerSts.Spec.ReplicaPerGroup, brokerFound.Spec.ReplicaPerGroup) || | ||
| !reflect.DeepEqual(brokerSts.Spec.Size, brokerFound.Spec.Size) || |
There was a problem hiding this comment.
When broker Get fails with a non-NotFound error, the error is logged but not returned. The code falls through to the status update section where brokerFound is still a zero-value &Broker{} (never populated), causing the status to be set to empty strings and potentially overwriting valid status.
| } | ||
| } | ||
| if instance.Spec.Console.ConsoleDeployment.Spec.Replicas != nil { | ||
| consoleFound := &rocketmqv1alpha1.Console{} |
There was a problem hiding this comment.
Console update calls r.client.Update(context.TODO(), consoleDep) on the desired-state object (consoleDep) instead of the existing cluster object (consoleFound). This will fail because consoleDep lacks the server-assigned ResourceVersion, and even if it succeeded it would overwrite the existing resource with a stale version.
| // Resource NameService will change; Only size nameServiceImage imagePullPolicy can update | ||
| if !reflect.DeepEqual(nameServiceSts.Spec.Size, nameServiceFound.Spec.Size) || | ||
| !reflect.DeepEqual(nameServiceSts.Spec.NameServiceImage, nameServiceFound.Spec.NameServiceImage) || | ||
| !reflect.DeepEqual(nameServiceSts.Spec.ImagePullPolicy, nameServiceFound.Spec.ImagePullPolicy) { |
There was a problem hiding this comment.
No readiness gate between NameService and Broker creation: the controller creates the Broker immediately after the NameService resource exists, without waiting for NameService pods to be Running/Ready. The README states 'the name server cluster will be created first, after all name server cluster is in running state, the operator will create the broker cluster' but the code does not enforce this ordering, which can cause brokers to fail on startup.
| env := corev1.EnvVar{ | ||
| Name: "JAVA_OPTS", | ||
| Value: fmt.Sprintf("-Drocketmq.namesrv.addr=%s -Dcom.rocketmq.sendMessageWithVIPChannel=false", share.NameServersStr), | ||
| } |
There was a problem hiding this comment.
The label mutation selectorLabels["console-cr"] = cr.Name and labels["console-cr"] = cr.Name modifies the maps from cr.Spec in place. Since maps are reference types in Go, this permanently mutates the CR's spec in memory, which can cause spurious diffs on subsequent reconcile passes and incorrect Update calls to the API server.
| Size int `json:"size"` | ||
| // NameServers defines the name service list e.g. 192.168.1.1:9876;192.168.1.2:9876 | ||
| NameServers string `json:"nameServers,omitempty"` | ||
| NameServers string `json:"nameServers"` |
There was a problem hiding this comment.
Removing omitempty from the nameServers JSON tag (json:"nameServers,omitempty" -> json:"nameServers") is a breaking API change. Existing Broker resources serialized without nameServers will now fail deserialization or validation. This breaks backward compatibility for users of the standalone Broker CRD.
| spec: | ||
| properties: | ||
| broker: | ||
| description: Broker defines rocketmq broker spec info |
There was a problem hiding this comment.
The CRD validation schema defines broker, nameService, and console as type: object with no sub-properties. This provides zero validation for nested fields, meaning any malformed spec will be accepted by the API server. At minimum, required sub-fields should be enumerated, or the full nested schemas from the Broker/NameService/Console CRDs should be inlined.
| err = r.client.Get(context.TODO(), types.NamespacedName{Name: consoleDep.Name, Namespace: consoleDep.Namespace}, consoleFound) | ||
| if err != nil && errors.IsNotFound(err) { | ||
| err = r.client.Create(context.TODO(), consoleDep) | ||
| if err != nil { |
There was a problem hiding this comment.
Console creation error is logged but not returned (reqLogger.Error(err, ...) without return reconcile.Result{}, err). This means console creation failures are silently swallowed and won't trigger proper retry with backoff.
| // Note: | ||
| // The Controller will requeue the Request to be processed again if the returned error is non-nil or | ||
| // Result.Requeue is true, otherwise upon completion it will remove the work from the queue. | ||
| func (r *ReconcileRocketmq) Reconcile(request reconcile.Request) (reconcile.Result, error) { |
There was a problem hiding this comment.
No unit or integration tests are included for the new Rocketmq controller, which orchestrates three sub-resources (NameService, Broker, Console) with non-trivial reconciliation logic including conditional creation, selective field updates, and status management. This is a significant gap in test coverage for a new controller.
| spec: | ||
| type: NodePort | ||
| selector: | ||
| name_service_cr: ${rocketmq-name}-name-service |
There was a problem hiding this comment.
The selector name_service_cr: ${rocketmq-name}-name-service uses a shell variable placeholder ${rocketmq-name} that is not substituted by kubectl. Users must manually replace this value, but this is not documented and will silently result in a Service with no matching pods if applied as-is.
add rocketmq api