Bug 1733473 - [MDB] Shouldn't be allowed to create MDB with negative number of minAvailable
Summary: [MDB] Shouldn't be allowed to create MDB with negative number of minAvailable
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Cloud Compute
Version: 4.2.0
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: ---
: 4.2.0
Assignee: Jan Chaloupka
QA Contact: sunzhaohua
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-07-26 08:21 UTC by sunzhaohua
Modified: 2019-10-16 06:33 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-10-16 06:33:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:2922 0 None None None 2019-10-16 06:33:59 UTC

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


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