Invert `regexp` operator
- Dominant language
- Go
- Stars
- 17k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 105
Description
### Proposal
I want to have a constraint that makes the job **avoid** clients with `batch` (substring) in their metadata `tags` (string) field.
The issue is loosely related to https://github.com/hashicorp/nomad/issues/6610.
`test, batch, demo` --> avoid
`test, demo` --> fine
### Attempted Solutions
1. I've tried this:
```hcl
constraint {
attribute = "${meta.tags}"
operator = "regexp"
value = "^(?!.*batch).*$"
}
```
But it looks the Go engine does not support negative lookaheads for performance reasons ([ref](https://stackoverflow.com/questions/26771592/negative-look-ahead-in-go-regular-expressions)).
2. One option would be to negate the `regexp` operator, but `regexp_not` does not seem to exist in Nomad.
Is there any way to achieve this in Nomad? I've ended up moving `batch` to a different individual metadata field, but I would like to know if it's possible just in case for next time.
Thanks!
Contributor guide
No contributing guide indexed for this repository
Research direction
No source file or test is named. Start by tracing Nomad’s existing `regexp` constraint operator and its Go regular-expression handling; done should support an inverse form that avoids clients whose `meta.tags` contains `batch`, while preserving the shown matching behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100