Bug 1660305

Summary: [cloud-CA] Shouldn't be allowed to create different machineautoscalers pointing to the same machineset
Product: OpenShift Container Platform Reporter: sunzhaohua <zhsun>
Component: Cloud ComputeAssignee: Brad Ison <brad.ison>
Status: CLOSED ERRATA QA Contact: sunzhaohua <zhsun>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.1.0CC: jhou
Target Milestone: ---   
Target Release: 4.1.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-04 10:41:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description sunzhaohua 2018-12-18 06:35:57 UTC
Description of problem:
Shouldn't be allowed to create different machineautoscalers pointing to the same 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. Create another 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-2b
  namespace: openshift-cluster-api
spec:
  maxReplicas: 4
  minReplicas: 2
  scaleTargetRef:
    apiVersion: cluster.k8s.io/v1alpha1
    kind: MachineSet
    name: qe-zhsun-1-worker-us-east-2a
status: {}

3. Check machineset annotations
$ oc get machineset qe-zhsun-1-worker-us-east-2a -o yaml
  annotations:
    sigs.k8s.io/cluster-api-autoscaler-node-group-max-size: "4"
    sigs.k8s.io/cluster-api-autoscaler-node-group-min-size: "2"
    
4. Delete the newly created machineautoscaler
$ oc delete machineautoscaler autoscale-us-east-2b
machineautoscaler.autoscaling.openshift.io "autoscale-us-east-2b" deleted

5. Check machineset annotations
$ oc get machineset qe-zhsun-1-worker-us-east-2a -o yaml
$ oc get machineautoscaler
NAME                   AGE
autoscale-us-east-2a   16m

Actual results:
Two machineautoscalers were created pointing the same machineset.

Expected results:
Creating different machineautoscalers pointing the same machineset is not allowed.

Additional info:

Comment 1 Brad Ison 2019-01-10 21:07:18 UTC
https://github.com/openshift/cluster-autoscaler-operator/pull/25

The changes in the above PR prevent multiple MachineAutoscaler resources with the same target from actually making conflicting changes. However, the error reporting in the status subresource is not complete. Also, blocking the creation of these resources up-front will require an admission webhook, which unfortunately will definitely not be ready before 4.0 feature freeze.

Comment 2 sunzhaohua 2019-02-18 03:43:43 UTC
Verified.

clusterversion: 4.0.0-0.nightly-2019-02-17-024922 


If multiple MachineAutoscaler resources reference the same target, the first wins and reconciliation will fail for the others.

$ oc logs -f cluster-autoscaler-operator-bb878c4cd-bqvr7
I0218 03:38:54.579680       1 machineautoscaler_controller.go:137] Reconciling MachineAutoscaler openshift-machine-api/autoscale-us-east-2a
I0218 03:39:26.775702       1 machineautoscaler_controller.go:137] Reconciling MachineAutoscaler openshift-machine-api/autoscale-us-east-2b
E0218 03:39:26.779709       1 machineautoscaler_controller.go:173] Error setting target owner: already owned by another MachineAutoscaler

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