【ISSUE #133】RocketMQ-Operator support the rocketmq-5.0 proxy node for cluster pattern - #134
【ISSUE #133】RocketMQ-Operator support the rocketmq-5.0 proxy node for cluster pattern#134shendongsd wants to merge 6 commits into
Conversation
…q-operator into feature_proxy
caigy
left a comment
There was a problem hiding this comment.
It seems that ClusterRole for proxy is missing.
| // 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"` |
There was a problem hiding this comment.
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.
|
How is it going? Can you merge it? @shendongsd |
|
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-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 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)
| @@ -23,6 +23,7 @@ import ( | |||
| "github.com/apache/rocketmq-operator/pkg/controller/broker" | |||
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: 8682 lines
Author: shendongsd (NONE)
Automated review by RockteMQ-AI
| 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 |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 @@ | |||
| /* | |||
There was a problem hiding this comment.
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.
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