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

Conversation

timcharper
Copy link
Contributor

JIRA Issues: MARATHON_EE-1667

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

I'm building your change at jenkins-marathon-pipelines-PR-5587-1.

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

✔ Build of #5587 completed successfully.

See details at jenkins-marathon-pipelines-PR-5587-1.

You can create a DC/OS with your patched Marathon by creating a new pull
request with the following changes in buildinfo.json:

"url": "https://s3.amazonaws.com/downloads.mesosphere.io/marathon/snapshots/marathon-1.6.0-pre-31-g4302502.tgz",
"sha1": "696ff561009affd7ddeda9299780d476fa243196"

\\ ٩( ᐛ )و //


"IN operator" should {
"require that the offer value be in the comma delimited list of values" in {
makeOffer("host1") should meetConstraint(hostnameField, IN, "host1,host2")
Copy link
Contributor

Choose a reason for hiding this comment

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

I am worried that values might have commas in them. In this case, we would need to support escaping and/or strings inside value strings of constraint definitions. Although I would vote for supports of arrays of strings as constraint values. In this case the constraint in an app definition could look like ["some-field", "IN", ["value1", "value2"]. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like what Ivan is proposing! :)

Copy link
Contributor Author

@timcharper timcharper Oct 10, 2017

Choose a reason for hiding this comment

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

I thought of this; This would break API compatibility. If you put a comma in your value then you are awful. We can escape the comma for v2 API api and then allow the array syntax for v3.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please forgive me my ignorance, but I do not see how it would break the user-facing API compatibility. Isn't it about addition/extension only? Are you referring to the case when Java/Python/etc clients would fail if their receive an array value, and not a string one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would change the type, specified here:

https://github.com/mesosphere/marathon/blob/v1.6.0-pre/docs/docs/rest-api/public/api/v2/types/constraint.raml#L20-L29

The specification is that constraints are a 2-3 item array of strings. Putting a non-string in there breaks the API.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking of supporting strings and arrays: arrays for IN and strings for everything else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understood this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ichernetsky did you mean to write this earlier?

["some-field", "IN", "value1", "value2"]

(sans the additional [)?

@jdef mentioned this as a possibility and it made me wonder if perhaps this was what you were trying to suggest :)

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I was suggesting ["field", "IN", ["value1", "value2"]].

Copy link
Contributor

@alenkacz alenkacz left a comment

Choose a reason for hiding this comment

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

Just a general question - who and when updates the docs? Like this one https://mesosphere.github.io/marathon/docs/constraints.html

@timcharper
Copy link
Contributor Author

Great question :) On the one hand, it'd probably be a good idea to update the docs with this PR. Suzanne usually does our docs.

On the other hand, no sense in writing docs until we fully settle on the behavior of these constraints.

@alenkacz
Copy link
Contributor

@timcharper ok, thanks :)

then LGTM

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

I'm building your change at jenkins-marathon-pipelines-PR-5587-2.

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

✔ Build of #5587 completed successfully.

See details at jenkins-marathon-pipelines-PR-5587-2.

You can create a DC/OS with your patched Marathon by creating a new pull
request with the following changes in buildinfo.json:

"url": "https://s3.amazonaws.com/downloads.mesosphere.io/marathon/snapshots/marathon-1.6.0-pre-38-geed526c.tgz",
"sha1": "a140ce48e9e79c0eea51eab17a3d56ddb335ed3f"

\\ ٩( ᐛ )و //

Copy link
Contributor

@meln1k meln1k left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -26,6 +26,10 @@ message Constraint {
UNLIKE = 4;
// Field will be grouped by field. Value specifies the maximum size of each group.
MAX_PER = 5;
// Field must be the specified value
IS = 6;
Copy link
Contributor

Choose a reason for hiding this comment

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

Our API is also defined in Protos?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🎉


"trims whitespace after the commas (but not before)" in {
makeOffer("host1") should meetConstraint(hostnameField, IN, "host1, host2")
makeOffer("host1") should meetConstraint(hostnameField, IN, "host1 , host2")
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't here a whitespace before the comma? host1 is not equal to host1[ ]. What am I missing?

Copy link
Contributor

Choose a reason for hiding this comment

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

The separator is a comma optionally surrounded by whitespaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

err lol the test description is a lie 😢

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe Mesos constraints what values can be specified on an agent attribute value. A user could potentially put trailing or leading spaces in the value. That would be an awful thing to do, but, none-the-less, possible.

I think it is more likely that people accidentally put a space in comma-delimited list.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, in agreement here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vinodkone corrected me; spaces are explicitly not allowed in attribute values, and they are removed by Mesos.

@timcharper timcharper changed the title Add IN and IS constraint operator Add IN and IS constraint operator [DO NOT MERGE] Oct 12, 2017
@timcharper timcharper changed the title Add IN and IS constraint operator [DO NOT MERGE] Add IN and IS constraint operator [DO NOT MERGE YET] Oct 12, 2017
@timcharper
Copy link
Contributor Author

Waiting for this proposal to be accepted by DCOS SDK / Storage Services team:

https://docs.google.com/document/d/e/2PACX-1vSFvPol0pcHC2Web7EaNU0oSDS5wrOWSgFcmuslYBtISV2NB2JZ_D-B4wpWy_Vutaf08m2LX6WZVy6s/pub

Tim Harper added 3 commits October 30, 2017 00:12
JIRA Issues: MARATHON_EE-1667
- Reject set/range values from IS constraints
- Accept only set values for IN constraints
- Reduce test verbosity
@timcharper timcharper force-pushed the tharper/add-in-and-is-constraint branch from 4302502 to c84c556 Compare October 31, 2017 06:06
@timcharper timcharper changed the title Add IN and IS constraint operator [DO NOT MERGE YET] Add IN and IS constraint operator Oct 31, 2017
@timcharper
Copy link
Contributor Author

Proposal is accepted and change has been updated to match proposal

@timcharper timcharper changed the title Add IN and IS constraint operator Add IN and IS constraint operators Oct 31, 2017
Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

I'm building your change at jenkins-marathon-pipelines-PR-5587-3.

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

✔ Build of #5587 completed successfully.

See details at jenkins-marathon-pipelines-PR-5587-3.

You can create a DC/OS with your patched Marathon by creating a new pull
request with the following changes in buildinfo.json:

"url": "https://s3.amazonaws.com/downloads.mesosphere.io/marathon/snapshots/marathon-1.6.0-pre-115-g254168f.tgz",
"sha1": "4c2d677483212af6cfe5bce9897afc255f58900c"

You can run system integration test changes of this PR against Marathon
master by tirggering this Jenkins job with the Pull_Request_id 5587.
The job then reports back to this PR.

\\ ٩( ᐛ )و //

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

I'm building your change at jenkins-marathon-pipelines-PR-5587-4.

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

I'm building your change at jenkins-marathon-pipelines-PR-5587-5.

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

I'm building your change at jenkins-marathon-pipelines-PR-5587-6.

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

✔ Build of #5587 completed successfully.

See details at jenkins-marathon-pipelines-PR-5587-4.

You can create a DC/OS with your patched Marathon by creating a new pull
request with the following changes in buildinfo.json:

"url": "https://s3.amazonaws.com/downloads.mesosphere.io/marathon/snapshots/marathon-1.6.0-pre-116-gcd129c2.tgz",
"sha1": "1881d93f62c1fe8dbcd43dc4a34b42f604b1f327"

You can run system integration test changes of this PR against Marathon
master by tirggering this Jenkins job with the Pull_Request_id 5587.
The job then reports back to this PR.

\\ ٩( ᐛ )و //

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

✔ Build of #5587 completed successfully.

See details at jenkins-marathon-pipelines-PR-5587-5.

You can create a DC/OS with your patched Marathon by creating a new pull
request with the following changes in buildinfo.json:

"url": "https://s3.amazonaws.com/downloads.mesosphere.io/marathon/snapshots/marathon-1.6.0-pre-117-g85dd4af.tgz",
"sha1": "257cd31f926d0956d9da7a8e4db1e180d1820508"

You can run system integration test changes of this PR against Marathon
master by tirggering this Jenkins job with the Pull_Request_id 5587.
The job then reports back to this PR.

\\ ٩( ᐛ )و //

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

✔ Build of #5587 completed successfully.

See details at jenkins-marathon-pipelines-PR-5587-6.

You can create a DC/OS with your patched Marathon by creating a new pull
request with the following changes in buildinfo.json:

"url": "https://s3.amazonaws.com/downloads.mesosphere.io/marathon/snapshots/marathon-1.6.0-pre-118-gc35fe74.tgz",
"sha1": "3b39ab10929cdf100ea909907236e495dd5b62b7"

You can run system integration test changes of this PR against Marathon
master by tirggering this Jenkins job with the Pull_Request_id 5587.
The job then reports back to this PR.

\\ ٩( ᐛ )و //

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

I'm building your change at jenkins-marathon-pipelines-PR-5587-7.

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

I'm building your change at jenkins-marathon-pipelines-PR-5587-8.

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

✔ Build of #5587 completed successfully.

See details at jenkins-marathon-pipelines-PR-5587-7.

You can create a DC/OS with your patched Marathon by creating a new pull
request with the following changes in buildinfo.json:

"url": "https://s3.amazonaws.com/downloads.mesosphere.io/marathon/snapshots/marathon-1.6.0-pre-119-gf1ca7e7.tgz",
"sha1": "a399477fc29e3993e5ceebaa71dfcf8da1fc0db8"

You can run system integration test changes of this PR against Marathon
master by tirggering this Jenkins job with the Pull_Request_id 5587.
The job then reports back to this PR.

\\ ٩( ᐛ )و //

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

✔ Build of #5587 completed successfully.

See details at jenkins-marathon-pipelines-PR-5587-8.

You can create a DC/OS with your patched Marathon by creating a new pull
request with the following changes in buildinfo.json:

"url": "https://s3.amazonaws.com/downloads.mesosphere.io/marathon/snapshots/marathon-1.6.0-pre-120-g86f7168.tgz",
"sha1": "1772832233f6db5a56586b196701a57e43e9ce58"

You can run system integration test changes of this PR against Marathon
master by tirggering this Jenkins job with the Pull_Request_id 5587.
The job then reports back to this PR.

\\ ٩( ᐛ )و //

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

I'm building your change at jenkins-marathon-pipelines-PR-5587-9.

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

✔ Build of #5587 completed successfully.

See details at jenkins-marathon-pipelines-PR-5587-9.

You can create a DC/OS with your patched Marathon by creating a new pull
request with the following changes in buildinfo.json:

"url": "https://s3.amazonaws.com/downloads.mesosphere.io/marathon/snapshots/marathon-1.6.0-pre-123-g7fc6036.tgz",
"sha1": "f65fd33a3ab33e8f6a9a4ac9fc450ad75f6b560d"

You can run system integration test changes of this PR against Marathon
master by tirggering this Jenkins job with the Pull_Request_id 5587.
The job then reports back to this PR.

\\ ٩( ᐛ )و //

@timcharper timcharper changed the title Add IN and IS constraint operators Add IS constraint operators Nov 1, 2017
@timcharper timcharper changed the title Add IS constraint operators Add IS constraint operator Nov 1, 2017
Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

I'm building your change at jenkins-marathon-pipelines-PR-5587-10.

Copy link

@mesosphere-ci mesosphere-ci left a comment

Choose a reason for hiding this comment

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

✔ Build of #5587 completed successfully.

See details at jenkins-marathon-pipelines-PR-5587-10.

You can create a DC/OS with your patched Marathon by creating a new pull
request with the following changes in buildinfo.json:

"url": "https://s3.amazonaws.com/downloads.mesosphere.io/marathon/snapshots/marathon-1.6.0-pre-125-g193bf8b.tgz",
"sha1": "457e50923cb2c4fdc7e7c72c473495776c5d404a"

You can run system integration test changes of this PR against Marathon
master by tirggering this Jenkins job with the Pull_Request_id 5587.
The job then reports back to this PR.

\\ ٩( ᐛ )و //

Copy link
Contributor

@sascala sascala left a comment

Choose a reason for hiding this comment

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

a couple tiny comments. Otherwise, LGTM!

@@ -102,6 +102,8 @@ $ curl -X POST -H "Content-type: application/json" localhost:8080/v2/apps -d '{
}'
```

Note, if the attribute in question is a scalar, it is rounded to the nearest thousandth using the half-even rounding strategy; zeroes after the decimal are dropped.
Copy link
Contributor

Choose a reason for hiding this comment

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

**Note:** If...

Copy link
Contributor Author

Choose a reason for hiding this comment

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


#### 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.

@timcharper timcharper closed this Nov 1, 2017
@timcharper
Copy link
Contributor Author

Thanks! Merged

@timcharper timcharper deleted the tharper/add-in-and-is-constraint branch November 27, 2017 22:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants