From 2f959fdb05f58803fab6052ff39df44abfdb3597 Mon Sep 17 00:00:00 2001 From: Chunyi Lyu Date: Tue, 21 Feb 2023 17:32:44 +0000 Subject: [PATCH 1/2] Update generated CRD --- .../bases/rabbitmq.com_rabbitmqclusters.yaml | 114 +++++++++++++++++- 1 file changed, 111 insertions(+), 3 deletions(-) diff --git a/config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml b/config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml index 33c384b17..512a03434 100644 --- a/config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml +++ b/config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml @@ -10,7 +10,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.10.0 + controller-gen.kubebuilder.io/version: v0.11.3 creationTimestamp: null name: rabbitmqclusters.rabbitmq.com spec: @@ -1484,6 +1484,18 @@ spec: type: object resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2101,6 +2113,18 @@ spec: type: object resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2725,6 +2749,18 @@ spec: type: object resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -2967,12 +3003,43 @@ spec: - conditionType type: object type: array + resourceClaims: + items: + properties: + name: + type: string + source: + properties: + resourceClaimName: + type: string + resourceClaimTemplateName: + type: string + type: object + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map restartPolicy: type: string runtimeClassName: type: string schedulerName: type: string + schedulingGates: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map securityContext: properties: fsGroup: @@ -3344,13 +3411,26 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -3889,13 +3969,26 @@ spec: type: string name: type: string + namespace: + type: string required: - kind - name type: object - x-kubernetes-map-type: atomic resources: properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: @@ -4007,6 +4100,21 @@ spec: memory: 2Gi description: The desired compute resource requirements of Pods in the cluster. properties: + claims: + description: "Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. \n This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. \n This field is immutable." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in pod.spec.resourceClaims of the Pod where this field is used. It makes that resource available inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map limits: additionalProperties: anyOf: From d5a7cbceb6f960588ec6124c9e7ff9b2d46b406b Mon Sep 17 00:00:00 2001 From: Chunyi Lyu Date: Tue, 21 Feb 2023 17:36:51 +0000 Subject: [PATCH 2/2] Log rabbitmqcluster spec at debug level - log cluster spec at debug instead of info - log message about requeue request to enable plugin at debug - log successfully queue rebalance like other cli command --- controllers/rabbitmqcluster_controller.go | 6 +++--- controllers/reconcile_cli.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/controllers/rabbitmqcluster_controller.go b/controllers/rabbitmqcluster_controller.go index dd714ab78..e114c0896 100644 --- a/controllers/rabbitmqcluster_controller.go +++ b/controllers/rabbitmqcluster_controller.go @@ -149,13 +149,13 @@ func (r *RabbitmqClusterReconciler) Reconcile(ctx context.Context, req ctrl.Requ } } + logger.Info("Start reconciling") + instanceSpec, err := json.Marshal(rabbitmqCluster.Spec) if err != nil { logger.Error(err, "Failed to marshal cluster spec") } - - logger.Info("Start reconciling", - "spec", string(instanceSpec)) + logger.V(1).Info("RabbitmqCluster", "spec", string(instanceSpec)) resourceBuilder := resource.RabbitmqResourceBuilder{ Instance: rabbitmqCluster, diff --git a/controllers/reconcile_cli.go b/controllers/reconcile_cli.go index 11c449773..ae3ad76df 100644 --- a/controllers/reconcile_cli.go +++ b/controllers/reconcile_cli.go @@ -38,7 +38,7 @@ func (r *RabbitmqClusterReconciler) runRabbitmqCLICommandsIfAnnotated(ctx contex // plugins configMap was updated very recently // give StatefulSet controller some time to trigger restart of StatefulSet if necessary // otherwise, there would be race conditions where we exec into containers losing the connection due to pods being terminated - logger.Info("requeuing request to set plugins") + logger.V(1).Info("requeuing request to set plugins") return 2 * time.Second, nil } @@ -113,6 +113,7 @@ func (r *RabbitmqClusterReconciler) runQueueRebalanceCommand(ctx context.Context r.Recorder.Event(rmq, corev1.EventTypeWarning, "FailedReconcile", fmt.Sprintf("%s %s", msg, podName)) return fmt.Errorf("%s %s: %w", msg, podName, err) } + logger.Info("successfully rebalanced queues") return r.deleteAnnotation(ctx, rmq, queueRebalanceAnnotation) }