Uploaded image for project: 'AMQ Broker'
  1. AMQ Broker
  2. ENTMQBR-6855

[Operator] Pod's custom labels cannot be updated

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • AMQ 7.10.1.OPR.1.GA
    • AMQ 7.10.0.OPR.2.GA
    • operator
    • None
    • False
    • None
    • False
    • Hide
      • 1 Create a basic AMQ deployment using the following CR defining your custom label "mylabel":
      apiVersion: broker.amq.io/v1beta1
      kind: ActiveMQArtemis
      metadata:
        name: ex-aao
      spec:
        deploymentPlan:
          labels:
            mylabel: myvalue1
          persistenceEnabled: false
          size: 1
          image: placeholder
          resources:
            limits:
              cpu: 1000m
              memory: 1024Mi
            requests:
              cpu: 500m
              memory: 1024Mi
        console:
          expose: true
          sslEnabled: false
      • 2 The AMQ POD will be created properly, labeled with your custom label (among others):
      $ oc describe pod ex-aao-ss-0 
      Name:         ex-aao-ss-0
      Namespace:    amq-demo
      Priority:     0
      Node:         crc-scmfr-master-0/192.168.126.11
      Start Time:   Thu, 21 Jul 2022 11:05:53 +0200
      Labels:       ActiveMQArtemis=ex-aao
                    application=ex-aao-app
                    com.company=Red_Hat
                    controller-revision-hash=ex-aao-ss-7748495bb6
                    mylabel=myvalue1
                    rht.comp=Broker_AMQ
                    rht.comp_ver=7.10.0
                    rht.prod_name=Red_Hat_Integration
                    rht.prod_ver=2022.Q2
                    rht.subcomp=broker-amq
                    rht.subcomp_t=application
                    statefulset.kubernetes.io/pod-name=ex-aao-ss-0
         :
         :
         :
      • 3 The Statefulset SELECTOR is also using the label:
      $ oc get sts ex-aao-ss -o json |jq -r '.spec.selector'
      {
        "matchLabels": {
          "ActiveMQArtemis": "ex-aao",
          "application": "ex-aao-app",
          "com.company": "Red_Hat",
          "mylabel": "myvalue1",
          "rht.comp": "Broker_AMQ",
          "rht.comp_ver": "7.10.0",
          "rht.prod_name": "Red_Hat_Integration",
          "rht.prod_ver": "2022.Q2",
          "rht.subcomp": "broker-amq",
          "rht.subcomp_t": "application"
        }
      }
      • 4 Update the value for the custom label "mylabel" to "myvalue2"
      apiVersion: broker.amq.io/v1beta1
      kind: ActiveMQArtemis
      metadata:
        name: ex-aao
      spec:
        deploymentPlan:
          labels:
            mylabel: myvalue2
          persistenceEnabled: false
          size: 1
          image: placeholder
          resources:
            limits:
              cpu: 1000m
              memory: 1024Mi
            requests:
              cpu: 500m
              memory: 1024Mi
        console:
          expose: true
          sslEnabled: false 
      • 5 Apply again the Custom Resource. The following error log can be seen in the Operator's log:
      2022-07-21T09:08:22.992Z    INFO    controller_v1beta1activemqartemis        {"ActiveMQArtemis Name": "ex-aao", "instances of ": "v1.StatefulSet", "Will create ": 0, "update ": 1, "and delete": 0}
      2022-07-21T09:08:23.005Z    ERROR    package k8s_actions    Failed to update *v1.StatefulSet    {"ActiveMQArtemis Name": "ex-aao-ss", "error": "StatefulSet.apps \"ex-aao-ss\" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden"}
      github.com/artemiscloud/activemq-artemis-operator/controllers.(*ActiveMQArtemisReconcilerImpl).ProcessResources
          /remote-source/app/controllers/activemqartemis_reconciler.go:1377
      github.com/artemiscloud/activemq-artemis-operator/controllers.(*ActiveMQArtemisReconcilerImpl).Process
          /remote-source/app/controllers/activemqartemis_reconciler.go:144
      github.com/artemiscloud/activemq-artemis-operator/controllers.(*ContainerRunningState).Update
          /remote-source/app/controllers/containerRunning_state.go:96
      github.com/artemiscloud/activemq-artemis-operator/pkg/utils/fsm.(*Machine).Update
          /remote-source/app/pkg/utils/fsm/fsm.go:144
      github.com/artemiscloud/activemq-artemis-operator/controllers.(*ActiveMQArtemisFSM).Update
          /remote-source/app/controllers/activemqartemis_fsm.go:315
      github.com/artemiscloud/activemq-artemis-operator/controllers.(*ActiveMQArtemisReconciler).Reconcile
          /remote-source/app/controllers/activemqartemis_controller.go:232
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
          /remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:114
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
          /remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:311
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
          /remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:266
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
          /remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:227
      
      Show
      1 Create a basic AMQ deployment using the following CR defining your custom label " mylabel ": apiVersion: broker.amq.io/v1beta1 kind: ActiveMQArtemis metadata:   name: ex-aao spec:   deploymentPlan:     labels:       mylabel: myvalue1     persistenceEnabled: false     size: 1     image: placeholder     resources:       limits:         cpu: 1000m         memory: 1024Mi       requests:         cpu: 500m         memory: 1024Mi   console:     expose: true     sslEnabled: false 2 The AMQ POD will be created properly, labeled with your custom label (among others): $ oc describe pod ex-aao-ss-0  Name:         ex-aao-ss-0 Namespace:    amq-demo Priority:     0 Node:         crc-scmfr-master-0/192.168.126.11 Start Time:   Thu, 21 Jul 2022 11:05:53 +0200 Labels:       ActiveMQArtemis=ex-aao               application=ex-aao-app               com.company=Red_Hat               controller-revision-hash=ex-aao-ss-7748495bb6               mylabel=myvalue1               rht.comp=Broker_AMQ               rht.comp_ver=7.10.0               rht.prod_name=Red_Hat_Integration               rht.prod_ver=2022.Q2               rht.subcomp=broker-amq               rht.subcomp_t=application               statefulset.kubernetes.io/pod-name=ex-aao-ss-0 : : : 3 The Statefulset SELECTOR is also using the label: $ oc get sts ex-aao-ss -o json |jq -r '.spec.selector' {   "matchLabels": {     "ActiveMQArtemis": "ex-aao",     "application": "ex-aao-app",     "com.company": "Red_Hat",     "mylabel": "myvalue1",     "rht.comp": "Broker_AMQ",     "rht.comp_ver": "7.10.0",     "rht.prod_name": "Red_Hat_Integration",     "rht.prod_ver": "2022.Q2",     "rht.subcomp": "broker-amq",     "rht.subcomp_t": "application"   } } 4 Update the value for the custom label " mylabel " to " myvalue2 " apiVersion: broker.amq.io/v1beta1 kind: ActiveMQArtemis metadata:   name: ex-aao spec:   deploymentPlan:     labels:       mylabel: myvalue2     persistenceEnabled: false     size: 1     image: placeholder     resources:       limits:         cpu: 1000m         memory: 1024Mi       requests:         cpu: 500m         memory: 1024Mi   console:     expose: true     sslEnabled: false 5 Apply again the Custom Resource. The following error log can be seen in the Operator's log: 2022-07-21T09:08:22.992Z    INFO    controller_v1beta1activemqartemis        {"ActiveMQArtemis Name": "ex-aao", "instances of ": "v1.StatefulSet", "Will create ": 0, "update ": 1, "and delete": 0} 2022-07-21T09:08:23.005Z    ERROR    package k8s_actions    Failed to update *v1.StatefulSet    {"ActiveMQArtemis Name": "ex-aao-ss", "error": "StatefulSet.apps \"ex-aao-ss\" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden"} github.com/artemiscloud/activemq-artemis-operator/controllers.(*ActiveMQArtemisReconcilerImpl).ProcessResources     /remote-source/app/controllers/activemqartemis_reconciler.go:1377 github.com/artemiscloud/activemq-artemis-operator/controllers.(*ActiveMQArtemisReconcilerImpl).Process     /remote-source/app/controllers/activemqartemis_reconciler.go:144 github.com/artemiscloud/activemq-artemis-operator/controllers.(*ContainerRunningState).Update     /remote-source/app/controllers/containerRunning_state.go:96 github.com/artemiscloud/activemq-artemis-operator/pkg/utils/fsm.(*Machine).Update     /remote-source/app/pkg/utils/fsm/fsm.go:144 github.com/artemiscloud/activemq-artemis-operator/controllers.(*ActiveMQArtemisFSM).Update     /remote-source/app/controllers/activemqartemis_fsm.go:315 github.com/artemiscloud/activemq-artemis-operator/controllers.(*ActiveMQArtemisReconciler).Reconcile     /remote-source/app/controllers/activemqartemis_controller.go:232 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile     /remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:114 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler     /remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:311 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem     /remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:266 sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2     /remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:227

      Since Operator version 7.10 you can define your own custom labels in the Custom Resource, in order to have the created AMQ pods labeled with them.

      It's working properly and after applying your CR for the first time, the AMQ pods will be labeled with your custom labels. But the operator is also using those labels in the statefulset's selector.matchLabels section. This is a problem when you want to update the value of your custom labels, or adding a new one: the Kubernetes spec doesn't allow to modify the spec.selector section.

      If you apply again your custom resource after updating the value for one label, the update fails and you'll see the error in the operator's log:

      Failed to update *v1.StatefulSet    {"ActiveMQArtemis Name": "ex-aao-ss", "error": "StatefulSet.apps \"ex-aao-ss\" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden"}

      The custom labels should not be included by default in the Statefulset spec.selector.matchLabels section. Usually the label values can be updated due to customer requirements. IMHO only the label "ActiveMQArtemis" should be used for the selector (and perhaps, the label "application" also).

            gtully@redhat.com Gary Tully
            ryanezil Rafael Yáñez Illescas
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: