Bug 1733473

Summary: [MDB] Shouldn't be allowed to create MDB with negative number of minAvailable
Product: OpenShift Container Platform Reporter: sunzhaohua <zhsun>
Component: Cloud ComputeAssignee: Jan Chaloupka <jchaloup>
Status: CLOSED ERRATA QA Contact: sunzhaohua <zhsun>
Severity: medium Docs Contact:
Priority: low    
Version: 4.2.0CC: agarcial
Target Milestone: ---   
Target Release: 4.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-10-16 06:33:49 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 2019-07-26 08:21:31 UTC
Description of problem:
Shouldn't be allowed to create MDB with negative number of minAvailable

Version-Release number of selected component (if applicable):
4.2.0-0.nightly-2019-07-25-053632

How reproducible:
Always

Steps to Reproduce:
1. Create MDB with negative number of minAvailable:

apiVersion: healthchecking.openshift.io/v1alpha1
kind: MachineDisruptionBudget
metadata:
  name: mdb-test1
  namespace: openshift-machine-api
spec:
  selector:
    matchLabels:
      machine.openshift.io/cluster-api-machine-role: worker
  minAvailable: -3
    

Actual results:
Create success.


Expected results:
Should fail.

Additional info:

Comment 1 Alberto 2019-07-29 09:38:19 UTC
Until OpenAPI v3 validation schemas are beta in 1.15 or we introduce webhook validation we can only fail and report accordingly

Comment 2 Jan Chaloupka 2019-07-29 11:45:32 UTC
This constrain can be fortunately already expressed in CRD: https://github.com/openshift/machine-api-operator/pull/364

Comment 4 sunzhaohua 2019-08-01 01:28:16 UTC
Verified.

$ oc get clusterversion
NAME      VERSION                             AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.2.0-0.nightly-2019-07-31-162901   True        False         8m4s    Cluster version is 4.2.0-0.nightly-2019-07-31-162901

$ oc create -f mdb.yaml 
The MachineDisruptionBudget "mdb-test1" is invalid: []: Invalid value: map[string]interface {}{"apiVersion":"healthchecking.openshift.io/v1alpha1", "kind":"MachineDisruptionBudget", "metadata":map[string]interface {}{"creationTimestamp":"2019-08-01T01:25:40Z", "generation":1, "name":"mdb-test1", "namespace":"openshift-machine-api", "uid":"464434d1-b3fb-11e9-9c63-022d83138dda"}, "spec":map[string]interface {}{"minAvailable":-3, "selector":map[string]interface {}{"matchLabels":map[string]interface {}{"machine.openshift.io/cluster-api-machine-role":"worker"}}}}: validation failure list:
spec.minAvailable in body should be greater than or equal to 0

Comment 5 errata-xmlrpc 2019-10-16 06:33:49 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:2922