Bug 1660304 - [cloud-CA] Update machineautoscaler machineset should first delete the original machineset annotations
Summary: [cloud-CA] Update machineautoscaler machineset should first delete the origin...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Cloud Compute
Version: 4.1.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.1.0
Assignee: Brad Ison
QA Contact: sunzhaohua
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-12-18 06:32 UTC by sunzhaohua
Modified: 2019-06-04 10:41 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-04 10:41:16 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:0758 None None None 2019-06-04 10:41:21 UTC

Description sunzhaohua 2018-12-18 06:32:30 UTC
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:

Comment 1 Brad Ison 2019-01-18 14:59:38 UTC
Work-in-progress PR: https://github.com/openshift/cluster-autoscaler-operator/pull/31

Comment 2 Brad Ison 2019-01-24 12:27:47 UTC
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.

Comment 4 sunzhaohua 2019-01-25 08:56:15 UTC
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

Comment 7 errata-xmlrpc 2019-06-04 10:41:16 UTC
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


Note You need to log in before you can comment on or make changes to this bug.