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

Support SSH urls #539

Merged
merged 4 commits into from
Aug 27, 2023
Merged

Support SSH urls #539

merged 4 commits into from
Aug 27, 2023

Conversation

vinokurig
Copy link
Contributor

@vinokurig vinokurig commented Aug 8, 2023

What does this PR do?

Extend each SCM provider implementation to support SSH urls.

Screenshot/screencast of this PR

What issues does this PR fix or reference?

fixes eclipse-che/che#22354

How to test this PR?

  1. Deploy Che with the PR image: quay.io/eclipse/che-server:pr-539
  2. Configure Che to use SSH keys for Git operations
  3. Try to start a workspace from an SSH url of a PUBLIC repository to avoid configuring OAuth or PAT, see: Add some SSH notes che-docs#2639

See:

  • Dashboard shows a notification that the devfile has been fetched:
    screenshot-eclipse-che apps cluster-c8wk5 c8wk5 sandbox2818 opentlc com-2023 08 08-16_06_34
  • Workspace starts successfully

PR Checklist

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

Reviewers

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

Signed-off-by: Igor Vinokur <[email protected]>
@ibuziuk
Copy link
Member

ibuziuk commented Aug 9, 2023

@vinokurig could you please update the description e.g. ssh setup step and provide an image for testing

Copy link
Contributor

@tolusha tolusha left a comment

Choose a reason for hiding this comment

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

Tested for Azure DevOps

@@ -80,7 +80,7 @@ private String fetchContent(
String authorization;
if (isNullOrEmpty(credentials)) {
PersonalAccessToken token =
personalAccessTokenManager.get(remoteFactoryUrl.getHostName());
personalAccessTokenManager.get(remoteFactoryUrl.getProviderUrl());
Copy link
Contributor

Choose a reason for hiding this comment

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

Will it affect existed PATs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't. This is just a refactoring of a method which retrieves SCM endpoint. The output is the same but the method is different.

@tolusha
Copy link
Contributor

tolusha commented Aug 10, 2023

test-project (main) $ git remote -v
origin  [email protected]:v3/my-abazko/test-project/test-project (fetch)
origin  [email protected]:v3/my-abazko/test-project/test-project (push)
test-project (main) $ touch test-file
test-project (main) $ git add -A
test-project (main) $ git commit -m "Add file" --signoff 
[main 3205e4c] Add file
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test-file
test-project (main) $ git push origin 
Warning: Permanently added 'ssh.dev.azure.com,40.74.28.27' (RSA) to the list of known hosts.
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 328 bytes | 109.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Analyzing objects... (3/3) (28 ms)
remote: Storing packfile... done (63 ms)
remote: Storing index... done (60 ms)
To ssh.dev.azure.com:v3/my-abazko/test-project/test-project
   dec2ba5..3205e4c  main -> main
test-project (main) $ 

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.

Tested the following scenarios with private GitHub repo [email protected]:ibuziuk/private.git

  • vanilla installation, no OAuth, PAT, SSH is setup - workspace is failing to start with

image

  • only SSH is setup (no PAT / OAuth) - same error as above

  • SSH and PAT are set

devfile is found, workspace is started and the project is cloned + remotes are set correctly:

origin  [email protected]:ibuziuk/private.git (fetch)
origin  [email protected]:ibuziuk/private.git (push)

Basically, we need to document that SSH setup is not enough to make the flow work (PAT or OAuth should be also set). Also, wondering if we can make the error more explicit

@ibuziuk
Copy link
Member

ibuziuk commented Aug 10, 2023

@ScrewTSW when you will be doing review please verify against bitbucket

@vinokurig
Copy link
Contributor Author

@ibuziuk

Also, wondering if we can make the error more explicit

The error is thrown because Che could not find GitHub oauth provider in its list of registered providers. The same error appears when a private https url is used without Oauth and PAT being configured. This question worth a separate discussion.

@ibuziuk
Copy link
Member

ibuziuk commented Aug 10, 2023

sounds, good
approving, but please provide relevant docs PR

@openshift-ci openshift-ci bot added the lgtm label Aug 24, 2023
@ibuziuk ibuziuk requested a review from ScrewTSW August 24, 2023 13:42
@openshift-ci openshift-ci bot removed the lgtm label Aug 24, 2023
@ScrewTSW
Copy link
Member

LGTM, verified using the prcheck image - AOK

@openshift-ci
Copy link

openshift-ci bot commented Aug 25, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ibuziuk, ScrewTSW, 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 7d0cfb3 into main Aug 27, 2023
@vinokurig vinokurig deleted the che-22354 branch August 27, 2023 13:17
@devstudio-release
Copy link

Build 3.9 :: server_3.x/203: Console, Changes, Git Data

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.9 :: get-sources-rhpkg-container-build_3.x/4085: FAILURE

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

@l0rd
Copy link
Contributor

l0rd commented Aug 31, 2023

After this SSH URLs other than GitHub/GitLab/BB/Azure don't work at all. It doesn't matter if the repo is public or private, the workspace will fail to start. This is a regression from what we had before because the workspace could start although the devfile was ignored. (I have tried with sourcehut for instance and I verified that it fails at the step "Inspecting repo for a devfile" with message "Cannot build factory with any of the provided parameters. Please check parameters correctness, and resend query.").

Moreover, as mentioned by @ibuziuk above, for GitHub/GitLab/BB/Azure SSH URLs it still requires a PAT secret (beyond the SSH private key) and there is no obvious value using the SSH URL. But I may be wrong here because using SSH key to pull/push rather then PAT can avoid problems with token expiration (to verify) so that, at least, have some value for users.

@vinokurig
Copy link
Contributor Author

@l0rd

After this SSH URLs other than GitHub/GitLab/BB/Azure don't work at all. It doesn't matter if the repo is public or private, the workspace will fail to start. This is a regression from what we had before because the workspace could start although the devfile was ignored. (I have tried with sourcehut for instance and I verified that it fails at the step "Inspecting repo for a devfile" with message "Cannot build factory with any of the provided parameters. Please check parameters correctness, and resend query.")

filed a bug report: eclipse-che/che#22473

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.

Devfile is not resolved when using GIT+SSH URLs
7 participants