Skip to content
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 1826664: handle Builder image detection when url is changed #5145

Merged

Conversation

debsmita1
Copy link
Contributor

@debsmita1 debsmita1 commented Apr 22, 2020

Fixes
https://issues.redhat.com/browse/ODC-3159

Analysis / Root cause
When the URL is unreachable, we don't have the capability to decide whether it's invalid or a private one because in both cases it will show the same error.

Solution Description
In this bug fix, I am trying to ensure that the builder image is reset if the user never manually touched the field, in that case, the form will wait for validation of the URL and auto/manual selection of builder image.

GIF
git-url-validation

/kind bug

@openshift-ci-robot openshift-ci-robot added kind/bug Categorizes issue or PR as related to a bug. component/dev-console Related to dev-console labels Apr 22, 2020
@debsmita1 debsmita1 changed the title disable submit till url is validated Bug 1826664: disable submit till url is validated Apr 22, 2020
@openshift-ci-robot
Copy link
Contributor

@debsmita1: This pull request references Bugzilla bug 1826664, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1826664: disable submit till url is validated

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Apr 22, 2020
@debsmita1
Copy link
Contributor Author

/cc @rohitkrai03

disableSubmit={!dirty || !_.isEmpty(errors)}
disableSubmit={
values.git.urlValidation === ValidatedOptions.default || !dirty || !_.isEmpty(errors)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to do this when you are adding the validation that will add the error if repo url is not correct? https://github.com/openshift/console/pull/5145/files#diff-ad8be16d16eef75fed4951b2be470be8R234-R244. If the error is there the button will anyways get disabled.

Copy link
Contributor Author

@debsmita1 debsmita1 Apr 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@divyanshiGupta @rohitkrai03 validation will occur only if the user clicks outside the input field. So there can be a scenario where all the required fields are filled and the user goes ahead and edits just the url. The create button is NOT disabled when the user makes changes to the url. As a result, the user can very easily click on the Create button without validating the git url. Below is the gif to give you a clear picture:

gitimport

I felt that we should be taking care of such cases. Please let me know if you would like to handle this in a different way

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we do have a bug that will change the onBlur behavior to onChange. That will validate the URL while user is typing so you won't need the explicit check like this. But for now I would say its okay to have this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohitkrai03 you must be talking about this issue https://issues.redhat.com/browse/ODC-2451, where the validation should take place right away as the user types the url

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above gif you showed has an inherent problem itself. Validations run every time user clicks on the submit button and we can see that it shows the error after that. So why does the submit handler submits the form even when there is an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The submit action was called before the url could be validated and this was possible only because the Submit button was not disabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submit handler waits for the validation to complete. Formik runs the validation again before calling onSubmit handler https://github.com/jaredpalmer/formik/blob/master/packages/formik/src/Formik.tsx#L740. But the problem is git service validations run async and separate from form validation schema and there is no way of checking errors in the onSubmit handler since formik omits that in formikBag

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This I did mention in the Root cause, in the PR summary, that the url validation that we are doing, if errors occur it doesn't show up in the formik errors.

Copy link
Contributor

@rohitkrai03 rohitkrai03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 23, 2020
@debsmita1
Copy link
Contributor Author

/test e2e-gcp-console

2 similar comments
@debsmita1
Copy link
Contributor Author

/test e2e-gcp-console

@debsmita1
Copy link
Contributor Author

/test e2e-gcp-console

@christianvogt
Copy link
Contributor

/approve cancel
/lgtm cancel

The error git repository not reachable does not equate to an invalid git repo. This simply means that we failed to reach the repo in order to auto detect the builder image.

This change breaks the dev-console from using private git repos because those URLs are always unreachable.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 23, 2020
@rohitkrai03
Copy link
Contributor

rohitkrai03 commented Apr 23, 2020

/approve cancel
/lgtm cancel

The error git repository not reachable does not equate to an invalid git repo. This simply means that we failed to reach the repo in order to auto detect the builder image.

This change breaks the dev-console from using private git repos because those URLs are always unreachable.

Looks like I missed private repository use case. Sorry for that. Should we change the error to be something more generic which also conveys that your repo might be private and you should try to add a secret for it? But even with the secret I don't think the validation status will change since git service can't make use of that secret to validate the repo. So either we make changes to git service which then validates the URL with newly added secret or we do nothing and let user proceed without disabling the submit button.

@debsmita1
Copy link
Contributor Author

/approve cancel
/lgtm cancel
The error git repository not reachable does not equate to an invalid git repo. This simply means that we failed to reach the repo in order to auto detect the builder image.
This change breaks the dev-console from using private git repos because those URLs are always unreachable.

Looks like I missed private repository use case. Sorry for that. Should we change the error to be something more generic which also conveys that your repo might be private and you should try to add a secret for it? But even with the secret I don't think the validation status will change since git service can't make use of that secret to validate the repo. So either we make changes to git service which then validates the URL with newly added secret or we do nothing and let user proceed without disabling the submit button.

We can at least show more informative error (or alert) message saying that the repo is not reachable as it can be either invalid or a private one.

@rohitkrai03
Copy link
Contributor

/approve cancel
/lgtm cancel
The error git repository not reachable does not equate to an invalid git repo. This simply means that we failed to reach the repo in order to auto detect the builder image.
This change breaks the dev-console from using private git repos because those URLs are always unreachable.

Looks like I missed private repository use case. Sorry for that. Should we change the error to be something more generic which also conveys that your repo might be private and you should try to add a secret for it? But even with the secret I don't think the validation status will change since git service can't make use of that secret to validate the repo. So either we make changes to git service which then validates the URL with newly added secret or we do nothing and let user proceed without disabling the submit button.

We can at least show more informative error (or alert) message saying that the repo is not reachable as it can be either invalid or a private one.

I think I've seen another bug to change the wordings of the error but the changes in your PR will make private repos unusable with git import. So either we look at another solution similar to what I mentioned in my earlier comment or we just don't do this change at all.

@rohitkrai03
Copy link
Contributor

/approve cancel

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-unspecified Referenced Bugzilla bug's severity is unspecified for the PR. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/unspecified labels Apr 24, 2020
@christianvogt
Copy link
Contributor

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 30, 2020
@openshift-ci-robot openshift-ci-robot added the component/shared Related to console-shared label Apr 30, 2020
@openshift-ci-robot
Copy link
Contributor

@debsmita1: This pull request references Bugzilla bug 1826664, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1826664: disable submit till url is validated

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 debsmita1 changed the title Bug 1826664: disable submit till url is validated Bug 1826664: handle Builder image detection when url is changed Apr 30, 2020
@debsmita1
Copy link
Contributor Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 4, 2020
@debsmita1
Copy link
Contributor Author

/cc @christianvogt

Copy link
Contributor

@rohitkrai03 rohitkrai03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 5, 2020
@christianvogt
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christianvogt, debsmita1, rohitkrai03

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 6, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit b30a4ba into openshift:master May 7, 2020
@openshift-ci-robot
Copy link
Contributor

@debsmita1: All pull requests linked via external trackers have merged: openshift/console#5145. Bugzilla bug 1826664 has been moved to the MODIFIED state.

In response to this:

Bug 1826664: handle Builder image detection when url is changed

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.

@spadgett spadgett added this to the v4.5 milestone May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-unspecified Referenced Bugzilla bug's severity is unspecified for the PR. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/dev-console Related to dev-console component/shared Related to console-shared kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants