Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-38218

[CAPI]Adding a MachineSet selector matchLabel causes orphaned Machines

XMLWordPrintable

    • Important
    • None
    • Rejected
    • False
    • Hide

      None

      Show
      None

      Description of problem:

      When adding new values to a capi MachineSet's `.spec.selector.matchLabels` and `.spec.template.metadata.labels`, new Machines are created for the MachineSet but the old Machines become orphaned from the MachineSet.

      Version-Release number of selected component (if applicable):

       4.17.0-0.nightly-2024-08-08-013133   

      How reproducible:

          Always

      Steps to Reproduce:

      1. Create a new cluster enable TechPreviewNoUpgrade
      2. Edit one of the capi worker MachineSets to add a new label in the `.spec.selector.matchLabels` and `.spec.template.metadata.labels` 
      3. Observe the Machines and MachineSet replica counts     

      Actual results:

      A new Machine is created which takes the new selector match label, and the old Machine becomes orphaned from the MachineSet. 
      $ oc edit machineset capi-ms 
        replicas: 2
        selector:
          matchLabels:
            aaa: aaa
            cluster.x-k8s.io/cluster-name: zhsun-gcp89-bgdwh
            machine.openshift.io/cluster-api-cluster: zhsun-gcp89-bgdwh-invalid
        template:
          metadata:
            labels:
              aaa: aaa
              cluster.x-k8s.io/cluster-name: zhsun-gcp89-bgdwh
              machine.openshift.io/cluster-api-cluster: zhsun-gcp89-bgdwh-invalid
      
      $ oc get machineset             
      NAME      CLUSTER             REPLICAS   READY   AVAILABLE   AGE   VERSION
      capi-ms   zhsun-gcp89-bgdwh   2          1       1           24m
      
      $ oc get machine      
      NAME            CLUSTER             NODENAME                                              PROVIDERID                                       PHASE     AGE     VERSION
      capi-ms-f6hxz   zhsun-gcp89-bgdwh                                                                                                          Pending   5m12s
      capi-ms-v7jhh   zhsun-gcp89-bgdwh   capi-ms-v7jhh.us-central1-a.c.openshift-qe.internal   gce://openshift-qe/us-central1-a/capi-ms-v7jhh   Running   5m46s
      capi-ms-wptvh   zhsun-gcp89-bgdwh   capi-ms-wptvh.us-central1-a.c.openshift-qe.internal   gce://openshift-qe/us-central1-a/capi-ms-wptvh   Running   24m

      Expected results:

      MachineSet selector is immutable    

      Additional info:

      Mapi bug https://bugzilla.redhat.com/show_bug.cgi?id=2005052
      
      If only edit `.spec.selector.matchLabels` like below, is not allowed.
      $ oc edit machineset capi-ms
        selector:
          matchLabels:
            aaa: aaa
            cluster.x-k8s.io/cluster-name: zhsun-gcp89-bgdwh
            machine.openshift.io/cluster-api-cluster: zhsun-gcp89-bgdwh-invalid
      
      # machinesets.cluster.x-k8s.io "capi-ms" was not valid:
      # * spec.template.metadata.labels: Invalid value: map[string]string{"cluster.x-k8s.io/cluster-name":"zhsun-gcp89-bgdwh", "machine.openshift.io/cluster-api-cluster":"zhsun-gcp89-bgdwh"}: must match spec.selector "aaa=aaa,cluster.x-k8s.io/cluster-name=zhsun-gcp89-bgdwh,machine.openshift.io/cluster-api-cluster=zhsun-gcp89-bgdwh-invalid"

            rh-ee-nbrubake Nolan Brubaker
            rhn-support-zhsun Zhaohua Sun
            Zhaohua Sun Zhaohua Sun
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: