Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Add IS constraint operator #5587

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion docs/docs/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Constraints control where apps run to allow optimizing for either fault toleranc

Entering `hostname` as the field name matches the agent node hostnames. See `UNIQUE operator`, below, for a usage example.

All Marathon operators are supported when the field name is `hostname`.
All Marathon operators are supported when the field name is `hostname`.

### Attribute as field name

Expand Down Expand Up @@ -168,3 +168,44 @@ $ curl -X POST -H "Content-type: application/json" localhost:8080/v2/apps -d '{
"constraints": [["rack_id", "GROUP_BY", "3"]]
}'
```

### IS operator

**Value** (required): A Mesos Scalar or Text value, as specified by the [Mesos Attributes and Resources Type Specification](http://mesos.apache.org/documentation/latest/attributes-resources/#types):

```
scalar : floatValue

floatValue : ( intValue ( "." intValue )? ) | ...

intValue : [0-9]+

text : [a-zA-Z0-9_/.-]
```

#### Comparing text values

When an `IS` constraint is specified, a task is only launched on nodes that have the specified attribute value. Note that `IS` behaves similar to `CLUSTER` with a value, and has been added mostly for semantic value (except its behavior differs when comparing scalars).

``` bash
$ curl -X POST -H "Content-type: application/json" localhost:8080/v2/apps -d '{
"id": "sleep-cluster",
"cmd": "sleep 60",
"instances": 3,
"constraints": [["", "IS", "rack-1"]]
}'
```

#### Comparing scalar values

When comparing scalars, the value is compared to the nearest thousandth (using half-even rounding strategy)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^Period at the end of the sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Given a node with attribute "level:0.8", the following constraints would match:

``` json
[["level", "IS", "0.8"]]

[["level", "IS", "0.80"]]

[["level", "IS", "0.8001"]]
```
2 changes: 1 addition & 1 deletion docs/docs/rest-api/public/api/v2/types/constraint.raml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ uses:
types:
ConstraintOperator:
type: string
enum: [UNIQUE, CLUSTER, GROUP_BY, LIKE, UNLIKE, MAX_PER]
enum: [UNIQUE, CLUSTER, GROUP_BY, LIKE, UNLIKE, MAX_PER, IS]
Constraint:
type: object
properties:
Expand Down
Loading