Skip to content

【ISSUE #133】RocketMQ-Operator support the rocketmq-5.0 proxy node for cluster pattern - #134

Open
shendongsd wants to merge 6 commits into
apache:masterfrom
shendongsd:feature_proxy
Open

【ISSUE #133】RocketMQ-Operator support the rocketmq-5.0 proxy node for cluster pattern#134
shendongsd wants to merge 6 commits into
apache:masterfrom
shendongsd:feature_proxy

Conversation

@shendongsd

@shendongsd shendongsd commented Oct 18, 2022

Copy link
Copy Markdown

What is the purpose of the change

ISSUE #133RocketMQ-Operator support the rocketmq-5.0 proxy node for cluster pattern
And I will add local pattern later

@caigy caigy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems that ClusterRole for proxy is missing.

Comment thread deploy/crds/rocketmq.apache.org_proxys.yaml
Comment thread pkg/controller/proxy/proxy_controller.go Outdated
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
// Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
ProxyStatefulSet v1.StatefulSet `json:"proxyStatefulSet"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Proxy is stateless, so is deployment more appropriate than statefulset?

Furthermore, it would be more elegant that users should only provide configs which they care about, instead of providing the whole statefulset or deployment.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok

@caigy caigy added the enhancement New feature or request label Oct 18, 2022
@AllenZMC

AllenZMC commented May 11, 2024

Copy link
Copy Markdown

How is it going? Can you merge it? @shendongsd

@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 feature_proxy
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 11 file(s) with 8682 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] Makefile:1 — Large diff (8682 lines). Consider breaking into smaller, focused PRs for easier review. (line outside diff)

Comment thread main.go
@@ -23,6 +23,7 @@ import (
"github.com/apache/rocketmq-operator/pkg/controller/broker"

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: 8682 lines
Author: shendongsd (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 #134: 【ISSUE #133】RocketMQ-Operator support the rocketmq-5.0 proxy node for cluster pattern

Findings: 14 issue(s) identified (8 critical).
CLA: unknown

Please address the inline comments above.


Automated review by github-manager-bot

Comment thread Makefile
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
kubectl create -f deploy/crds/rocketmq.apache.org_brokers.yaml
kubectl create -f deploy/crds/rocketmq.apache.org_nameservices.yaml
kubectl create -f deploy/crds/rocketmq.apache.proxys.yaml

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 install target references deploy/crds/rocketmq.apache.proxys.yaml, which is missing .org_. The actual generated file is rocketmq.apache.org_proxys.yaml, so the CRD will not be installed and the operator cannot reconcile Proxy resources.

Comment thread Makefile
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
kubectl delete --ignore-not-found=$(ignore-not-found) -f deploy/crds/rocketmq.apache.org_brokers.yaml
kubectl delete --ignore-not-found=$(ignore-not-found) -f deploy/crds/rocketmq.apache.org_nameservices.yaml
kubectl delete --ignore-not-found=$(ignore-not-found) -f deploy/crds/rocketmq.apache.org_proxys.yaml

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 added uninstall command is indented with spaces instead of a tab. Make requires recipe lines to begin with a tab, so make uninstall will fail with a missing separator error.


// TODO(user): Modify this to be the types you create that are owned by the primary resource
// Watch for changes to secondary resource Pods and requeue the owner Proxy
err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &handler.EnqueueRequestForOwner{

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 controller watches corev1.Pod as a secondary resource, but there is no corresponding RBAC marker granting get/list/watch on pods. The controller will fail to start the watch with a Forbidden error unless the role is manually fixed.

//+kubebuilder:rbac:groups=rocketmq.apache.org,resources=proxys,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=rocketmq.apache.org,resources=proxys/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=rocketmq.apache.org,resources=proxys/finalizers,verbs=update
//+kubebuilder:rbac:groups="apps",resources=Deployments,verbs=get;list;watch;create;update;patch;delete

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 RBAC marker uses resources=Deployments. Kubernetes RBAC resource names should be lowercase plural (deployments); Deployments is non-idiomatic and may not be accepted by controller-gen or the API server.


// Fetch the Proxy instance
instance := &rocketmqv1alpha1.Proxy{}
err := r.client.Get(context.TODO(), request.NamespacedName, instance)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reconcile receives a ctx context.Context parameter but calls r.client.Get(context.TODO(), ...). It should use the supplied ctx so cancellation and deadlines are respected.

Affinity: cr.Spec.ProxyDeployment.Spec.Template.Spec.Affinity,
ImagePullSecrets: cr.Spec.ProxyDeployment.Spec.Template.Spec.ImagePullSecrets,
Containers: []corev1.Container{{
Resources: cr.Spec.ProxyDeployment.Spec.Template.Spec.Containers[0].Resources,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

newDeploymentForCR accesses Spec.Template.Spec.Containers[0] without verifying that at least one container is provided. Omitting containers causes an index-out-of-range panic.


func getContainerSecurityContext(proxy *rocketmqv1alpha1.Proxy) *corev1.SecurityContext {
var securityContext = corev1.SecurityContext{}
if proxy.Spec.ProxyDeployment.Spec.Template.Spec.Containers[0].SecurityContext != 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.

getContainerSecurityContext also dereferences Containers[0] without a length check, leading to a panic when the container list is empty.

}

// Support proxy Deployment scaling
if !reflect.DeepEqual(instance.Spec.ProxyDeployment.Spec.Replicas, found.Spec.Replicas) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

After the Deployment exists, the reconcile loop only updates Replicas. Changes to image, environment variables, volumes, labels, affinity, or other template fields are ignored, so updates to the Proxy CR will not be fully applied.

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if [ $PROXY_MODE == "LOCAL" ]; then

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 PROXY_MODE is LOCAL, the script runs ./mqproxy -bc ... -pm LOCAL and then falls through to unconditionally run ./mqproxy -pc ... -pm ... on line 20. The second invocation lacks the broker config and will either fail or create an unwanted cluster-mode process. An else branch is needed.

@@ -0,0 +1,236 @@
/*

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 tests or integration tests are added for the new Proxy type, controller, or Deployment reconciliation logic. The PR introduces a new CRD and controller that should have test coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants