New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 1972777: Unable to edit the default Health check probe values #9237
Bug 1972777: Unable to edit the default Health check probe values #9237
Conversation
/kind bug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this locally, works fine. But please let us use toInteger instead of toNumber.
frontend/packages/dev-console/src/components/health-checks/create-health-checks-probe-utils.ts
Outdated
Show resolved
Hide resolved
frontend/packages/dev-console/src/components/health-checks/create-health-checks-probe-utils.ts
Outdated
Show resolved
Hide resolved
@debsmita1 Can you also update the existing test in |
7a810ca
to
0b3a464
Compare
Done |
<p> | ||
{t('devconsole~Health checks for')} | ||
<ResourceLink | ||
kind={referenceFor(resource)} | ||
name={name} | ||
namespace={namespace} | ||
title={name} | ||
inline | ||
/> | ||
</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This should probably be using <Trans>...</Trans>
. Translators should always be given full context as not all languages keep the same sentence structure. Sometimes the noun is first, sometimes it's last.
initialDelaySeconds: number | string; | ||
periodSeconds: number | string; | ||
timeoutSeconds: number | string; | ||
successThreshold: number | string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This muddiest the water of our TypeScript types. Either we need to convert at Input level to a number, and always treat it as number. Or we need to have two types... one for the formik data structure which are input value driven data. And then you want pure representation data that we talk about in "HealthCheck" terms.
Merging these two things together just allows us to not ever know by just looking at the type which state it is in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this for sake of adding a unit test where the input data is string, the utils are all strictly typed, and won't allow testing string data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need to mangle types for Tests, please extend the type in the test file and expand it there. Best not impact our application types for tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, maybe its a good idea to split this into two kinds of data.
HealthCheckProbe vs HealthCheckForm and then constructProbeData gets form data and return "kubernetes data".
But I don't know how big this change is. But it sounds not sooo bad, or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are "just" inside a new release. This is not the time to concern ourselves with it. If this fix/bug is something we need to backport, then perhaps we go with what we have.
If it's not intended for backport or @debsmita1 you're okay with making a slimmed version for backport manually, we should 100% be looking towards the horizons when making type changes and not do something that lowers our quality and ease of use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should backport this asap as this breaks the health checks, at least if the user changes one of this five numeric fields. So I hope that we pick this up for the first z-stream release.
I checked the code now again. Andrew is in general right that we should distinguish between k8s resource data and internal form data. From my understand the HealthChecksData
is currently used as form data type, not as resource definition.
The convert from form data to resource data happen in updateHealthChecksProbe
and getProbesData
.
And the convert from resource data to form data in getHealthChecksData
.
At the moment this last method doesn't convert the resource integers to form strings. But when the user changes the values in the form we currently save strings in the form data. So at the moment its right that we have number|string values in the form. (Status quo. Which doesn't mean that I liked this.)
So one option is that we create two clean types. One for the FormData and one for the ResourceData and update all methods above to ensure that they convert between strings and numbers. So that the type doesn't change anymore when the user touches a field.
The other one is to create a follow up issue (tech debt or bug) and accept that the form mixes two types at the moment. This makes at least the verification and backport of this fix easy. When I understand Andrew correctly this is also acceptable for him.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should backport this asap as this breaks the health checks, at least if the user changes one of this five numeric fields. So I hope that we pick this up for the first z-stream release.
No z-streams for 4.8 for at least 3 weeks, if not more. We need to go GA, then 1 or 2 z-streams (at roughly 1 week cadences) before we can get changes into it.
It's fine doing it a tech debt, but I am concerned about our approach to code. We have always had TypeScript lax feelings and this is a good case when we are opting for more lax types to multi-purpose them. I'm personally against this style of coding. We can take this as-is and port it back, wait 3ish weeks to merge it, and in the meantime work to clean this up in 4.9 asap (and it cannot be "on the backlog" imo).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logged ticket https://issues.redhat.com/browse/ODC-6037
@@ -6,8 +6,8 @@ import { healthChecksDefaultValues } from './health-checks-probe-utils'; | |||
|
|||
export const constructProbeData = (data: HealthCheckProbeData, resourceType?: Resources) => { | |||
const probeData = { | |||
...(data.failureThreshold && { failureThreshold: data.failureThreshold }), | |||
...(data.successThreshold && { successThreshold: data.successThreshold }), | |||
...(data.failureThreshold && { failureThreshold: _.toInteger(data.failureThreshold) }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we use parseInt
here instead of lodash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some other _.toInteger
calls in this function before. I think its good to use a similar way in one function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think toInteger
can be replaced using parseInt
for all the cases.
shouldn't we prefer using standard built in functions to external library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nemesis09 You're waaay too late to that party lol (I've been preaching that since Aug 2019 when I got hired lol). We have corrected it in a few places, but for the most part it is a mixed bag. There isn't too much loss to using lodash, and there is often a lot of code safety to gain in the utilities.
My preference is definitely to go with native functions when they do the same thing, to reduce our reliance on "magic" 3rd party utility functions. But in the end it doesn't really matter.
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please log a backlog ticket with my two comments and complete it this sprint (separate of this PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified import flow with an health check and adding/modifing a health check later on an existing deployment.
/lgtm
/retest |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, debsmita1, jerolimov The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cherry-pick release-4.8 |
@debsmita1: #9237 failed to apply on top of branch "release-4.8":
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@debsmita1: All pull requests linked via external trackers have merged: Bugzilla bug 1972777 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/bugzilla refresh |
@debsmita1: Bugzilla bug 1972777 is in an unrecognized state (MODIFIED) and will not be moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/bugzilla refresh |
@debsmita1: Bugzilla bug 1972777 is in an unrecognized state (MODIFIED) and will not be moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Fixes:
https://issues.redhat.com/browse/ODC-6015
Root analysis:
The field input type was changed from number to text to bypass the browser validation (#8198), because of this the probe data is received as a string instead of number
Solution description:
GIF: