Skip to content

[ISSUE 57] add rocketmq api - #63

Open
linjiemiao wants to merge 4 commits into
apache:masterfrom
silotrd:issue-57-dev
Open

[ISSUE 57] add rocketmq api#63
linjiemiao wants to merge 4 commits into
apache:masterfrom
silotrd:issue-57-dev

Conversation

@linjiemiao

Copy link
Copy Markdown

add rocketmq api

@liuruiyiyang

Copy link
Copy Markdown
Contributor

@linjiemiao ping, could you please help to resolve the conflict.

@linjiemiao

Copy link
Copy Markdown
Author

@linjiemiao ping, could you please help to resolve the conflict.

Okay, I will cherry-pick your latest commit, and then I resolve the conflict.

liuruiyiyang and others added 3 commits September 28, 2020 16:07
* feat(console): add CRD for RocketMQ Console

* chore(*): add ASF header

Co-authored-by: liuruiyiyang <liurui@apache.org>
@drivebyer

Copy link
Copy Markdown
Contributor

still need this

@RockteMQ-AI

Copy link
Copy Markdown

⚠️ Merge conflict detected

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-lease

This 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 RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No test changes detected alongside source modifications. Consider adding tests to cover the changes.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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) ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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{}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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),
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

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.

4 participants