-
Notifications
You must be signed in to change notification settings - Fork 37
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
select clusters with CEL expressions #137
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: haoqing0110 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 |
- Variable `managedCluster` will be added. | ||
The input types may either be instances of `proto.Message` or `ref.Type`. Since OCM API does not implement `proto.Message`, we will add a function called ConvertManagedCluster() to convert ManagedCluster to a Map as an easier way to get started. | ||
|
||
- Function `score` will be added. |
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.
Need to enhance AddonPlacementScore
to add original score value. And aeed a more appropriate name than score
.
- requiredClusterSelector: | ||
celSelector: | ||
celExpressions: | ||
- managedCluster.metadata.labels["version"].versionIsGreaterThan("1.30.0") |
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.
what kind of version does it support? only semVersion? What if the value is "v0.13.1"?
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 support both Semantic Versioning and v as a prefix, will update the detail in the proposal.
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.
how about we change this example using managedCluster.Status.version.kubernetes instead?
- requiredClusterSelector: | ||
celSelector: | ||
celExpressions: | ||
- managedCluster.score("default, "cpuAvailable") < 2 |
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.
could we do like managedCluster.score.default.cpuAvailable? or we have to use a function here?
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.
managedCluster does not have a score field so if we pass managedCluster.score.default.cpuAvailable
to the cel for evaluation, it can not recognize it.
Maybe we can use something like managedCluster.score(default).cpuAvailable. function score("crname") will return a map of [scorename]scorevalue, and user can use standard cel expression to select it.
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.
what if we do clusterScore instead of managedCluster instead? will it work?
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.
Hmm, have considered about this, when evaluate a expression is true or false, the clusterScore may still need a cluster name as input, managedCluster.score("default") equals to score(managedCluster, "default") (but can not write a cel expression like this).
827317d
to
70b2aa8
Compare
Signed-off-by: Qing Hao <[email protected]>
|
||
// Quantity defines the original value of the score. | ||
// +optional | ||
Quantity resource.Quantity `json:"quantity"` |
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.
this could be quite noisy, brings frequent update on the API. We would need to consider how this should be rate limited.
- requiredClusterSelector: | ||
celSelector: | ||
celExpressions: | ||
- managedCluster.metadata.labels["version"].versionIsGreaterThan("1.30.0") |
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.
how about we change this example using managedCluster.Status.version.kubernetes instead?
ref: #136