-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Pluggable Workspace Cluster: Admission Constraints #4158
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8118e95
[pwc] Support admission constraints
csweichel 50320b1
[pwc] Add admission constraints to gpctl
csweichel 3502f0b
[gpctl] Implement cluster swap
csweichel b083e6e
[gpctl] List static workspace cluster, too
csweichel b8a96bb
[gpctl] Updated bash completion
csweichel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
components/gitpod-db/src/typeorm/migration/1620209434733-AdmissionConstraints.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright (c) 2021 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License-AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import {MigrationInterface, QueryRunner} from "typeorm"; | ||
import { columnExists, tableExists } from "./helper/helper"; | ||
|
||
export class AdmissionConstraints1620209434733 implements MigrationInterface { | ||
|
||
public async up(queryRunner: QueryRunner): Promise<any> { | ||
if (await tableExists(queryRunner, "d_b_workspace_cluster")) { | ||
if (!(await columnExists(queryRunner, "d_b_workspace_cluster", "admissionConstraints"))) { | ||
await queryRunner.query("ALTER TABLE d_b_workspace_cluster ADD COLUMN admissionConstraints TEXT NOT NULL"); | ||
} | ||
} | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<any> { | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--require ts-node/register | ||
--require reflect-metadata/Reflect | ||
--require source-map-support/register | ||
--reporter spec | ||
--watch-extensions ts | ||
--exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
components/ws-manager-api/typescript/src/client-provider.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Copyright (c) 2021 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License-AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import "reflect-metadata"; | ||
|
||
import { Container } from 'inversify'; | ||
import { suite, test } from "@testdeck/mocha"; | ||
import * as chai from 'chai'; | ||
import { WorkspaceManagerClientProvider } from "./client-provider"; | ||
import { WorkspaceManagerClientProviderCompositeSource, WorkspaceManagerClientProviderSource } from "./client-provider-source"; | ||
import { WorkspaceCluster, WorkspaceClusterWoTLS } from "@gitpod/gitpod-protocol/lib/workspace-cluster"; | ||
import { User, Workspace, WorkspaceInstance } from "@gitpod/gitpod-protocol"; | ||
const expect = chai.expect; | ||
|
||
@suite | ||
class TestClientProvider { | ||
protected provider: WorkspaceManagerClientProvider; | ||
|
||
public before() { | ||
const c = new Container(); | ||
c.bind(WorkspaceManagerClientProvider).toSelf().inSingletonScope(); | ||
c.bind(WorkspaceManagerClientProviderCompositeSource).toSelf().inSingletonScope(); | ||
c.bind(WorkspaceManagerClientProviderSource).toDynamicValue((): WorkspaceManagerClientProviderSource => { | ||
const cluster: WorkspaceCluster[] = [ | ||
{ name: "c1", govern: true, maxScore: 100, score: 0, state: "cordoned", url: "", admissionConstraints: [] }, | ||
{ name: "c2", govern: true, maxScore: 100, score: 50, state: "cordoned", url: "", admissionConstraints: [] }, | ||
{ name: "c3", govern: false, maxScore: 100, score: 50, state: "cordoned", url: "", admissionConstraints: [] }, | ||
{ name: "a1", govern: true, maxScore: 100, score: 0, state: "available", url: "", admissionConstraints: [] }, | ||
{ name: "a2", govern: true, maxScore: 100, score: 50, state: "available", url: "", admissionConstraints: [] }, | ||
{ name: "a3", govern: false, maxScore: 100, score: 50, state: "available", url: "", admissionConstraints: [] }, | ||
{ | ||
name: "con1", govern: true, maxScore: 100, score: 0, state: "available", url: "", admissionConstraints: [ | ||
{ type: "has-feature-preview" }, | ||
] | ||
}, | ||
{ | ||
name: "con2", govern: true, maxScore: 100, score: 50, state: "available", url: "", admissionConstraints: [ | ||
{ type: "has-permission", permission: "new-workspace-cluster" }, | ||
] | ||
}, | ||
]; | ||
return <WorkspaceManagerClientProviderSource>{ | ||
getAllWorkspaceClusters: async () => { return cluster as WorkspaceClusterWoTLS[] }, | ||
getWorkspaceCluster: async (name: string) => { | ||
return cluster.find(c => c.name === name); | ||
} | ||
}; | ||
}).inSingletonScope(); | ||
this.provider = c.get(WorkspaceManagerClientProvider); | ||
} | ||
|
||
@test | ||
public async testGetStarterWorkspaceCluster() { | ||
this.expectInstallations(["a1", "a2", "a3"], await this.provider.getAvailableStartCluster({} as User, {} as Workspace, {} as WorkspaceInstance)); | ||
this.expectInstallations(["a1", "a2", "a3", "con1"], await this.provider.getAvailableStartCluster({ | ||
additionalData: {featurePreview: true} | ||
} as User, {} as Workspace, {} as WorkspaceInstance)); | ||
this.expectInstallations(["a1", "a2", "a3", "con2"], await this.provider.getAvailableStartCluster({ | ||
rolesOrPermissions: ["admin"] | ||
} as User, {} as Workspace, {} as WorkspaceInstance)); | ||
} | ||
|
||
private expectInstallations(expected: string[], actual: WorkspaceClusterWoTLS[]) { | ||
expect(actual.map(e => e.name).sort()).to.be.eql(expected); | ||
} | ||
|
||
} | ||
|
||
module.exports = new TestClientProvider() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
c.govern
👍