Bug 1825851 - MHC MaxUnhealthy allows malformed value `2%0`
Summary: MHC MaxUnhealthy allows malformed value `2%0`
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Cloud Compute
Version: 4.5
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: 4.5.0
Assignee: Joel Speed
QA Contact: Milind Yadav
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-04-20 12:14 UTC by Joel Speed
Modified: 2020-07-13 17:29 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: Entering an invalid string containing a percentage sign for the MaxUnhealthy field on an MHC would be interpreted as a percentage value (eg "2%0" would be interpreted as "20%") Consequence: The MaxUnhealthy field had unpredictable behaviour and Machines may have been remediated when they were not intended to be remediated Fix: Ensure the percentage sign is the last character before assuming the value is a percentage Result: Entering a malformed value such as "2%0" now results in an error being returned
Clone Of:
Environment:
Last Closed: 2020-07-13 17:29:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift machine-api-operator pull 562 0 None closed BUG 1825851: Ensure malformed IntOrPercent returns error 2020-07-16 18:00:01 UTC
Red Hat Product Errata RHBA-2020:2409 0 None None None 2020-07-13 17:29:22 UTC

Description Joel Speed 2020-04-20 12:14:59 UTC
Description of problem:

A value of `2%0` for the MHC MaxUnhealthy field is currently interpreted the same way `50%` would be, even though it is malformed.

Version-Release number of selected component (if applicable):


How reproducible:

Create MHC with `maxUnhealthy` set to `2%0`


Actual results:

Remediation will occur if no more than 20% of nodes are unhealthy

Expected results:

An error should be returned as `2%0` is not a valid value

Additional info:

Comment 3 Milind Yadav 2020-04-27 09:18:22 UTC
Validated on :
[miyadav@miyadav ManualRun]$ oc get clusterversion
NAME      VERSION                             AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.5.0-0.nightly-2020-04-26-225842   True        False         46m     Cluster version is 4.5.0-0.nightly-2020-04-26-225842

Reproducible Always

Steps :

1.Create a mhc , use below yml.
oc create -f mhc.yml
---
apiVersion: machine.openshift.io/v1beta1
kind: MachineHealthCheck
metadata:
  creationTimestamp: "2020-02-14T09:47:08Z"
  generation: 1
  name: mhc1
  namespace: openshift-machine-api
  resourceVersion: "71059"
  selfLink: /apis/machine.openshift.io/v1beta1/namespaces/openshift-machine-api/machinehealthchecks/mhc-miyadav-1402-drlvf-worker-us-east-2c
  uid: ef74b735-e58e-4c24-aa69-015d90998b77
spec:
  maxUnhealthy: 2%0
  selector:
    matchLabels:
      machine.openshift.io/cluster-api-cluster: miyada-x5rl5
      machine.openshift.io/cluster-api-machine-role: worker
      machine.openshift.io/cluster-api-machine-type: worker
      machine.openshift.io/cluster-api-machineset: miyada-x5rl5-w-a
  unhealthyConditions:
    - 
      status: "False"
      timeout: 300s
      type: Ready
    - 
      status: Unknown
      timeout: 300s
      type: Ready



2.Delete the machine containing the machineset that we are monitoring using the mhc.
oc delete machine miyada-x5rl5-w-a-gf8wr
Actual & Expected : machine.machine.openshift.io "miyada-x5rl5-w-a-gf8wr" deleted

3.Monitor logs,  mhc should not be triggered but gives error msg as below :

Actual:
W0427 09:09:35.411030       1 machinehealthcheck_controller.go:187] Reconciling openshift-machine-api/mhc1: total targets: 1,  maxUnhealthy: 2%0, unhealthy: 1. Short-circuiting remediation
I0427 09:09:41.927580       1 machinehealthcheck_controller.go:152] Reconciling openshift-machine-api/mhc1
I0427 09:09:41.927614       1 machinehealthcheck_controller.go:165] Reconciling openshift-machine-api/mhc1: finding targets
I0427 09:09:41.927727       1 machinehealthcheck_controller.go:277] Reconciling openshift-machine-api/mhc1/miyada-x5rl5-w-a-456hk/miyada-x5rl5-w-a-456hk.c.openshift-qe.internal: health checking
I0427 09:09:41.927742       1 machinehealthcheck_controller.go:291] Reconciling openshift-machine-api/mhc1/miyada-x5rl5-w-a-456hk/miyada-x5rl5-w-a-456hk.c.openshift-qe.internal: is likely to go unhealthy in 4m50.072266761s
E0427 09:09:41.939136       1 machinehealthcheck_controller.go:242] openshift-machine-api/mhc1: error decoding maxUnhealthy, remediation won't be allowed: invalid value for IntOrString: invalid value "2%0": strconv.Atoi: parsing "2%0": invalid syntax


Additional info:

Can we review the error message to make it more simpler.
Example : error decoding maxUnhealthy, remediation won't be allowed: invalid value for maxUnhealthy: It should be either integer or percent

Comment 4 Milind Yadav 2020-04-27 09:54:55 UTC
moving to VERIFIED , looks good for now, may be later if it feels the message needs to be improved , we can have PR.

Comment 5 errata-xmlrpc 2020-07-13 17:29:07 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-2020:2409


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