-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[wsman-bridge] Introduce admission preferences #6164
Conversation
/approve no-issue |
/werft run 👍 started the job as gitpod-build-cw-admission-prefs.2 |
/werft run 👍 started the job as gitpod-build-cw-admission-prefs.3 |
/werft run 👍 started the job as gitpod-build-cw-admission-prefs.4 |
bc1ea6a
to
f956e3a
Compare
7fabcce
to
3d3f2a1
Compare
public async up(queryRunner: QueryRunner): Promise<any> { | ||
if (await tableExists(queryRunner, "d_b_workspace_cluster")) { | ||
if (!(await columnExists(queryRunner, "d_b_workspace_cluster", "admissionPreferences"))) { | ||
await queryRunner.query("ALTER TABLE d_b_workspace_cluster ADD COLUMN admissionPreferences TEXT"); |
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.
Why not make this a JSON
column?
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.
to follow the same pattern as for admissionConstraints
|
||
function admissionPreferencesFilter(user: ExtendedUser): (c: WorkspaceClusterWoTLS) => boolean { | ||
return (c: WorkspaceClusterWoTLS) => { | ||
if (!c.admissionPreferences) { |
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.
nit: superfluous
3d3f2a1
to
2e22630
Compare
2e22630
to
d55abfd
Compare
* See License-AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import {MigrationInterface, QueryRunner} from "typeorm"; |
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.
nit: formatting, no space
@@ -46,6 +47,13 @@ message AdmissionConstraint { | |||
oneof constraint { | |||
FeaturePreview has_feature_preview = 1; | |||
HasPermission has_permission = 2; | |||
string has_user_level = 3; |
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.
Any specific reason not to have this as a message type instad of a string?
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.
Yes. The message was a bad choice to beging with :) but for now we're stuck with it for backwards compatibility reasons.
Overall lgtm other than a few clarifying questions. Also, there are no unit tests, given that we don't have them for any other file this is not a blocker, but we, should definitely discuss this. |
let availableCluster = await this.getAvailableStartCluster(user, workspace, instance); | ||
if (!!exceptInstallations) { | ||
availableCluster = availableCluster.filter(c => !exceptInstallations?.includes(c.name)); | ||
} | ||
const chosenCluster = chooseCluster(availableCluster); | ||
|
||
let chosenCluster = chooseCluster(availableCluster.filter(admissionPreferencesFilter(user))) |
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.
👍
/werft run 👍 started the job as gitpod-build-cw-admission-prefs.14 |
/werft run 👍 started the job as gitpod-build-cw-admission-prefs.15 |
return JSON.stringify(value); | ||
}, | ||
from(value: any): any { | ||
if (!value) { | ||
return undefined; |
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.
Should return defaultValue
.
{{- range .Status }} | ||
{{ .Name }} {{ .Url }} {{ .Static }} {{ .State }} {{ .Score }} {{ .Governed }} {{ .AdmissionConstraints -}} | ||
{{ .Name }} {{ .Url }} {{ .Static }} {{ .State }} {{ .Score }} {{ .Governed }} {{ .AdmissionConstraint -}} {{ .AdmissionPreference -}} |
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.
@@ -164,8 +167,8 @@ export class ClusterService implements IClusterServiceServer { | |||
if (call.request.hasCordoned()) { | |||
cluster.state = mapCordoned(req.cordoned); | |||
} | |||
if (call.request.hasAdmissionConstraints()) { |
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.
Bumped into this while testing: A few lines up (L158/159) the error ALREADY_EXISTS
is wrong. Not introduce with this PR, but worth fixing.
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.
Finally found the time for testing: works as advertised!
There are a couple of things which are worth fixing, but am fine with doing those in a followup PR:
- [wsman-bridge] Introduce admission preferences #6164 (comment)
- [wsman-bridge] Introduce admission preferences #6164 (comment)
- [wsman-bridge] Introduce admission preferences #6164 (comment)
👍
LGTM label has been added. Git tree hash: 929e1e57a57fb0be37107c119e84af17325dd1ed
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: csweichel, geropl Associated issue requirement bypassed by: csweichel 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 |
Description
This PR adds admission preferences to the workspace cluster selection mechanism. While admission constraints limit the set of clusters a workspace can be started on, admission preferences express a preference for a set of cluster but still allow fall-back to clusters that do not match that preference.
With this change, we first try and choose a cluster from the preferred clusters (green circle below) following the usual score mechanism. If there are no preferred cluster, we'll fall back to all clusters matching the admission constraints.
Use-cases this addition is helpful for:
user-level
. This in-descriptive level can be used for a variety of purposes, e.g. express "paying customer" status. In a follow-up PR (once I've figured out if a user is actually paying), we would set this level topaying-customer
. All workspace cluster with an admission preferenceuser-level=paying-customer
and the (new) admission constrainthas-user-level=paying-customer
would then become exclusive for paying users.has-permission=workspace-cluster
constraint and a high score, hoping that after so many attempts we land on the new cluster. We could introduce a prefix context parser which takes a cluster name, and add an admission preference for that name.How to test
Release Notes