Skip to content

Scope config lookup to org #19217

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

Merged
merged 1 commit into from
Dec 8, 2023
Merged

Scope config lookup to org #19217

merged 1 commit into from
Dec 8, 2023

Conversation

filiptronicek
Copy link
Member

@filiptronicek filiptronicek commented Dec 7, 2023

Description

When creating a workspace, we check if by any chance there aren't multiple configurations for this repository, because we cannot just guess it by the context URL you provided. This lookup was previously done on a global level, so if anyone in the world configured a repo which you also had configured, you would start getting a Multiple projects found for clone URL. error.

This change tweaks the behavior so that even if you had a repo configured across two organizations, only the one for the currently active one will apply.

Important

This PR does not address the same error message caused by multiple configurations of the same repo within a single organization. This will come later most likely via a --configuration flag for gitpod workspace create.

Related Issue(s)

Fixes EXP-962

How to test

  1. Join my org
  2. Create your own one and configure https://github.com/gitpod-io/gitpod within it
  3. gitpod login --host https://ft-ws-crea72590a191a.preview.gitpod-dev.com/
  4. gitpod ws create "https://github.com/gitpod-io/gitpod"

Preview status

Gitpod was successfully deployed to your preview environment.

## Build Options
Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • /werft preemptible
    Saves cost. Untick this only if you're really sure you need a non-preemtible machine.
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

@filiptronicek
Copy link
Member Author

/gh run recreate-vm=true

@filiptronicek filiptronicek mentioned this pull request Dec 7, 2023
15 tasks
@filiptronicek filiptronicek self-assigned this Dec 7, 2023
@filiptronicek filiptronicek marked this pull request as ready for review December 7, 2023 21:59
@filiptronicek filiptronicek requested a review from a team as a code owner December 7, 2023 21:59
@mustard-mh
Copy link
Contributor

This PR should also fix issue EXP-986

@mustard-mh
Copy link
Contributor

mustard-mh commented Dec 8, 2023

Original issue EXP-962 will not fix completely because there can be multiple configrations for the same repo in the same organization.

But it can unblock lots of users (maybe almost all? Since actual multiple case should not that normal) with this problem 👍

Copy link
Contributor

@mustard-mh mustard-mh left a comment

Choose a reason for hiding this comment

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

👍 Works as promised

@roboquat roboquat merged commit 46ff2d0 into main Dec 8, 2023
@roboquat roboquat deleted the ft/ws-creation-duplicate-configs branch December 8, 2023 06:50
@@ -120,7 +120,11 @@ export class ContextService {
if (options?.projectId) {
project = await this.projectsService.getProject(user.id, options.projectId);
} else if (CommitContext.is(context)) {
const projects = await this.projectsService.findProjectsByCloneUrl(user.id, context.repository.cloneUrl);
const projects = await this.projectsService.findProjectsByCloneUrl(
Copy link
Member

Choose a reason for hiding this comment

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

It would be good if we added DB tests for various cases.

const repo = await this.getRepo();
const conditions: FindConditions<DBProject> = { cloneUrl, markedDeleted: false };
const conditions: FindConditions<DBProject> = { cloneUrl, markedDeleted: false, teamId: organizationId };
Copy link
Member

Choose a reason for hiding this comment

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

How does it work here? If teamId is present but undefined then it doest not count or it will check as null.

Copy link
Contributor

Choose a reason for hiding this comment

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

TypeOrm don't know it's null unless we use something like Null (not sure) or queryBuild with IS NULL,

so condition would be { cloneUrl, markedDeleted: false }

Copy link
Contributor

@mustard-mh mustard-mh Dec 8, 2023

Choose a reason for hiding this comment

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

We may need to worry if organizationId is default value => EmptyString in gPRC, then it will find with { teamId: "" }

Copy link
Contributor

Choose a reason for hiding this comment

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

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

Successfully merging this pull request may close these issues.

4 participants