Treat constraint expressions as an AST
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 3.7k
- Forks
- 676
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 6
Description
First of all, this is mostly meant as a topic for discussion, rather than a concrete proposal.
As of now, constraints are a set of key-value expressions using == or != operators that are chained together with implicit logical AND (&&) operators.
In BNF, this can be expressed as follows, even though there is currently no actual && operator:
<expr> ::= <key> <op> <value>
| <expr> `&&` <expr>
<op> ::= `==` | `!=`
I would argue that there are use cases where the model is overly restrictive or it requires excessive node labelling.
Without going into details about variations of <op> or adding different keys, I believe that this model could benefit from an explicit OR (||) operator and by setting the AND operator to be explicit.
This would be reflected in the following grammar:
<expr> ::= <key> <op> <value>
| <expr> `&&` <expr>
| <expr> `||` <expr>
| `(` expr `)`
<op> ::= `==` | `!=`
One example expression would be:
(node.role == manager && node.labels.disk == ssd) || (node.role != manager && node.labels.disk != ssd) meaning "schedule on a manager node only if its storage drive is an ssd`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or entry point is named. Start by locating the existing constraint representation and parser, then compare them with the proposed BNF for explicit &&, ||, and parentheses. Done would require an agreed design and corresponding parsing and scheduling behavior, but this issue is presented as discussion rather than a concrete proposal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- compilers, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100