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

Respect the ScmComunicationException on token validation step #715

Merged
merged 5 commits into from
Sep 13, 2024

Conversation

vinokurig
Copy link
Contributor

@vinokurig vinokurig commented Aug 30, 2024

What does this PR do?

  • Throw the ScmCommunicationException on token validation step instead of returning invalid result.
  • Propagate the ScmCommunicationException to the dashboard as an ApiException.
  • Throw ScmUnauthorizedException on each scm api request with invalid token.
  • Log error instead of throwing RuntimeException on workspace provision steps.

Screenshot/screencast of this PR

What issues does this PR fix or reference?

eclipse-che/che#23076

How to test this PR?

  1. Deploy Che from the PR image: quay.io/ivinokur/che-server:che-23076 The image is built with a modification: to simulate the unreachable SCM server I changed the api endpoint url in the GitHub api client:
    public static final String GITHUB_SAAS_ENDPOINT_API = "https://api.github.com";
  2. Configure Che to use dashboard image from the related pull request: quay.io/eclipse/che-dashboard:pr-1179
  3. Configure GitHub oauth
  4. Start a workspace from a GitHub repository with devfile.

See: a warning notification appears during workspace startup:
Screenshot 2024-08-30 at 13 59 48
The workspace starts successfully.

PR Checklist

As the author of this Pull Request I made sure that:

Release Notes

Reviewers

Reviewers, please comment how you tested the PR when approving it.

@vinokurig
Copy link
Contributor Author

/retest

@artaleks9
Copy link
Contributor

By some reason, the changes in test file are not staged.
Maybe there is changed UI, or something like that.
I investigate it.
pr-715

@artaleks9
Copy link
Contributor

@vinokurig
The ci/prow/v14-gitlab-with-oauth-setup-flow is fail due to changes in IDE
I provided the screenshots to compare and I'm going to fix up it in our Che test repository
The functionality related to git provider OAuth works properly. I've checked it manually using quay.io/eclipse/che-server:pr-715
pr-715-che-IDE
pr-715-no-change-IDE

@artaleks9
Copy link
Contributor

So, there are no restrictions related tests to merge PR.

@@ -79,7 +83,7 @@ public void configure(NamespaceResolutionContext namespaceResolutionContext, Str
| ScmConfigurationPersistenceException
| UnsatisfiedScmPreconditionException
| ScmUnauthorizedException e) {
throw new RuntimeException(e);
LOG.error(e.getMessage(), e);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the benefits of logging 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.

We do not interrupt the workspace start in this case.

@@ -228,6 +235,8 @@ private <T> T executeRequest(
throw new ScmBadRequestException(body);
case HTTP_NOT_FOUND:
throw new ScmItemNotFoundException(body);
case HTTP_UNAUTHORIZED:
throw new ScmUnauthorizedException(body, "github", "v1", "");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move constant somewhere else?
Copy/paste from github?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy/paste from github?

right, fixed

Can we move constant somewhere else?

Could you please elaborate on this?

@@ -290,6 +296,8 @@ private <T> T executeRequest(
throw new ScmBadRequestException(body);
case HTTP_NOT_FOUND:
throw new ScmItemNotFoundException(body);
case HTTP_UNAUTHORIZED:
throw new ScmUnauthorizedException(body, "github", "v1", "");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why v1 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to v2 corresponds to oauth version.

@@ -159,6 +163,8 @@ private <T> T executeRequest(
throw new ScmBadRequestException(body);
case HTTP_NOT_FOUND:
throw new ScmItemNotFoundException(body);
case HTTP_UNAUTHORIZED:
throw new ScmUnauthorizedException(body, "github", "v1", "");
Copy link
Contributor

Choose a reason for hiding this comment

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

copy/paste from github ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

@ibuziuk ibuziuk left a comment

Choose a reason for hiding this comment

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

@vinokurig great job, but can we make UX more informative - Error message should say that Github might be down + add a link to the statuspage - https://www.githubstatus.com/

@vinokurig vinokurig force-pushed the che-23076 branch 3 times, most recently from 76f172d to 9d496cb Compare September 11, 2024 12:37
@vinokurig
Copy link
Contributor Author

@ibuziuk

can we make UX more informative - Error message should say that Github might be down + add a link to the statuspage - https://www.githubstatus.com/

I've improved the notification text but unfortunately there is no quick way to have the link clickable in the warning notification, would that be ok in the scope of the issue? cc @olexii4 @akurinnoy
screenshot-eclipse-che apps rosa z9hnf-8cdw2-7m6 qpi4 p3 openshiftapps com-2024 09 11-15_49_13

@ibuziuk
Copy link
Member

ibuziuk commented Sep 12, 2024

We should either make the link clickable or just reword the warning without the link - GitHub might not be operational. Check the status page.

@vinokurig
Copy link
Contributor Author

vinokurig commented Sep 12, 2024

@ibuziuk I have removed the links from the notification and opened an issue to be able to add links
screenshot-eclipse-che apps rosa x9djd-x3aqj-zvk qktx p3 openshiftapps com-2024 09 12-16_19_07

@vinokurig
Copy link
Contributor Author

/retest

Copy link

openshift-ci bot commented Sep 13, 2024

@vinokurig: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/v14-gitlab-with-oauth-setup-flow deda774 link true /test v14-gitlab-with-oauth-setup-flow

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

Copy link

openshift-ci bot commented Sep 13, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: artaleks9, ibuziuk, tolusha, vinokurig

The full list of commands accepted by this bot can be found 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

@vinokurig vinokurig merged commit 6121661 into main Sep 13, 2024
27 of 28 checks passed
@vinokurig vinokurig deleted the che-23076 branch September 13, 2024 13:58
@devstudio-release
Copy link

Build 3.17 :: server_3.x/359: Console, Changes, Git Data

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.17 :: get-sources-rhpkg-container-build_3.x/7693: FAILURE

server : 3.x :: Failed in 64203004 : BREW:BUILD/STATUS:UNKNOWN
FAILURE:; copied to quay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants