Description of problem: Update machineautoscaler machineset should first delete the original machineset annotations, then add annotations to the new machineset Version-Release number of selected component (if applicable): $ bin/openshift-install version bin/openshift-install v0.7.0-master-16-g81e2a8810350b18030d313bc17ddaecdb1ed32b7 $ oc version oc v4.0.0-alpha.0+1cdd4a1-781 kubernetes v1.11.0+1cdd4a1 features: Basic-Auth GSSAPI Kerberos SPNEGO How reproducible: Always Steps to Reproduce: 1. Create machineautoscaler set machineset "qe-zhsun-1-worker-us-east-2a" $ oc create -f machineautoscaler.yml apiVersion: autoscaling.openshift.io/v1alpha1 kind: MachineAutoscaler metadata: finalizers: - machinetarget.autoscaling.openshift.io name: autoscale-us-east-2a namespace: openshift-cluster-api spec: maxReplicas: 3 minReplicas: 1 scaleTargetRef: apiVersion: cluster.k8s.io/v1alpha1 kind: MachineSet name: qe-zhsun-1-worker-us-east-2a status: {} 2. Edit machineautoscaler set machineset "qe-zhsun-1-worker-us-east-2b" $ oc edit machineautoscaler autoscale-us-east-2a apiVersion: autoscaling.openshift.io/v1alpha1 kind: MachineAutoscaler metadata: finalizers: - machinetarget.autoscaling.openshift.io name: autoscale-us-east-2a namespace: openshift-cluster-api spec: maxReplicas: 3 minReplicas: 1 scaleTargetRef: apiVersion: cluster.k8s.io/v1alpha1 kind: MachineSet name: qe-zhsun-1-worker-us-east-2b status: {} 3. Check machineset "qe-zhsun-1-worker-us-east-2a" " qe-zhsun-1-worker-us-east-2b" annotations $ oc get machineset qe-zhsun-1-worker-us-east-2a -o yaml annotations: sigs.k8s.io/cluster-api-autoscaler-node-group-max-size: "3" sigs.k8s.io/cluster-api-autoscaler-node-group-min-size: "1" $ oc get machineset qe-zhsun-1-worker-us-east-2b -o yaml annotations: sigs.k8s.io/cluster-api-autoscaler-node-group-max-size: "3" sigs.k8s.io/cluster-api-autoscaler-node-group-min-size: "1" 4. Delete machineautoscaler 5. Check machineset "qe-zhsun-1-worker-us-east-2a" " qe-zhsun-1-worker-us-east-2b" annotations $ oc get machineset qe-zhsun-1-worker-us-east-2a -o yaml annotations: sigs.k8s.io/cluster-api-autoscaler-node-group-max-size: "3" sigs.k8s.io/cluster-api-autoscaler-node-group-min-size: "1" $ oc get machineset qe-zhsun-1-worker-us-east-2b -o yaml Actual results: Machineset "qe-zhsun-1-worker-us-east-2a" annotations still exists, "qe-zhsun-1-worker-us-east-2b" annotations was deleted Expected results: When machineautoscaler machineset changed to another one, the original machineset annotations should be deleted. Additional info:
Work-in-progress PR: https://github.com/openshift/cluster-autoscaler-operator/pull/31
I think this is fixed on master. The last observed target is now recorded in the MachineAutoscaler status, if it's changed the previous target has its annotations removed before the new target is annotated.
Verified Create a MachineAutoscaler, then edit it and update the scaleTargetRef to reference a different MachineSet, the previously targeted MachineSet removed its annotations before the new target is annotated. $ oc get clusterversion NAME VERSION AVAILABLE PROGRESSING SINCE STATUS version 4.0.0-0.nightly-2019-01-25-034943 True False 13m Cluster version is 4.0.0-0.nightly-2019-01-25-034943 Create a machineautoscaler to reference machineSet "zhsun-worker-us-east-2a" $ oc get machineautoscaler autoscale-us-east-2a -o yaml spec: maxReplicas: 3 minReplicas: 1 scaleTargetRef: apiVersion: cluster.k8s.io/v1alpha1 kind: MachineSet name: zhsun-worker-us-east-2a status: lastTargetRef: apiVersion: cluster.k8s.io/v1alpha1 kind: MachineSet name: zhsun-worker-us-east-2a $ oc get machineset zhsun-worker-us-east-2a -o yaml annotations: autoscaling.openshift.io/machineautoscaler: openshift-cluster-api/autoscale-us-east-2a sigs.k8s.io/cluster-api-autoscaler-node-group-max-size: "3" sigs.k8s.io/cluster-api-autoscaler-node-group-min-size: "1" Update the machineautoscaler to reference a different MachineSet "zhsun-worker-us-east-2c" $ oc get machineautoscaler autoscale-us-east-2a -o yaml spec: maxReplicas: 3 minReplicas: 1 scaleTargetRef: apiVersion: cluster.k8s.io/v1alpha1 kind: MachineSet name: zhsun-worker-us-east-2c status: lastTargetRef: apiVersion: cluster.k8s.io/v1alpha1 kind: MachineSet name: zhsun-worker-us-east-2c $ oc get machineset zhsun-worker-us-east-2c -o yaml annotations: autoscaling.openshift.io/machineautoscaler: openshift-cluster-api/autoscale-us-east-2c sigs.k8s.io/cluster-api-autoscaler-node-group-max-size: "3" sigs.k8s.io/cluster-api-autoscaler-node-group-min-size: "1" $ oc get machineset zhsun-worker-us-east-2a -o yaml apiVersion: cluster.k8s.io/v1alpha1 kind: MachineSet metadata: labels: sigs.k8s.io/cluster-api-cluster: zhsun sigs.k8s.io/cluster-api-machine-role: worker sigs.k8s.io/cluster-api-machine-type: worker name: zhsun-worker-us-east-2a namespace: openshift-cluster-api spec: replicas: 1 selector: matchLabels: sigs.k8s.io/cluster-api-cluster: zhsun sigs.k8s.io/cluster-api-machineset: zhsun-worker-us-east-2a
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2019:0758