You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by Jiang Yan Xu <ya...@jxu.me> on 2017/07/13 00:04:15 UTC

Review Request 60821: Introduced a "no sender" UPID.

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60821/
-----------------------------------------------------------

Review request for mesos, Benjamin Mahler, James Peach, and Joseph Wu.


Bugs: MESOS-7786
    https://issues.apache.org/jira/browse/MESOS-7786


Repository: mesos


Description
-------

The immediate use of this is to fix MESOS-7753 but I feel this is a general concept that's defined in similar systems (e.g., akka).


Diffs
-----

  3rdparty/libprocess/src/process.cpp b4d7791782a5d9e10fa44489057c8504d594bab2 
  3rdparty/libprocess/src/tests/process_tests.cpp c6109547d04bd06e9395e4ec5f5130fd1500f9a0 


Diff: https://reviews.apache.org/r/60821/diff/1/


Testing
-------

make check.


Thanks,

Jiang Yan Xu


Re: Review Request 60821: Introduced a "no sender" UPID.

Posted by Jiang Yan Xu <ya...@jxu.me>.

> On July 12, 2017, 5:27 p.m., James Peach wrote:
> > I think that a better approach is to define a static `UPID UPID::anonymous()` function that returns a well-defined anonymous UPID for the system. Remove all the sending functions that don't specify a `from` UPID and force them to explicitly pass the anonymous UPID. This makes the used of anonymous message sends explicit which I think is preferable to this implicit approach.
> 
> Jiang Yan Xu wrote:
>     Here's my thinking:
>     
>     - In libprocess the PID is usually not constructed directly, aside from being parsed but that's also hidden from the users of the library. Users of libprocess tend to get the PID from the process that owns that PID or from `spawn`. Afterwards it is used as an opaque ID. Therefore I feel like more consistent with the current architecture to not expose it at all. Having to know to use a speical ID is less straighfoward than calling a method that doesn't take a `from` IMO.
>     
>     - Right now the PID is just a simple data struct and not guarded by a `process::initialize()` call. This special UPID and PID uses the value of `__address__`, which initialized in `process::initialize()`. Therefore even if we expose this anonymous / no sender PID directly, I feel it's probably going to be constructed by something other than a static UPID method. This is a minor point though.
> 
> James Peach wrote:
>     * Anything that calls `post` is going to have to initialize `libprocess`, so initializing `libprocess` when we generate the anonymous UPID seems OK too. `UPID process::anonymous()`.
>     * Sending anonymous messages is a special case, so it should be explicit. `post` is also a special case since you already have to specify a target UPID. I argue that explicit is better than implicit and 1 way to `post` is better than 2.
> 
> Jiang Yan Xu wrote:
>     Yeah I think the main thing I am arguing for here is that as you said, the purpose of this is to support "Sending anonymous messages / message with no sender address". IMO the sentence from the user's POV translates to a method (and we already have this method), not an UPID.
>     
>     In othe words, this special [process::post](https://github.com/apache/mesos/blob/5645fddf07eab0fcd195a3514e9e5ad3ef25628d/3rdparty/libprocess/include/process/process.hpp#L626-L637) overload serves a special purpose that
>     - We currently have a use case directly
>     - I don't see how it could be incorrectly used for other unintended ways.
>     
>     
>     In contrast, exposing a special UPID to user:
>     - I don't see how the UPID can be used for another legit purpose.
>     - I can see it could used incorrectly by the user.
>     
>     
>     I do support explictness, but I think saying a method "sends message with no sender address" is pretty explicit too and without exposing too much flexibility and a concept that could be hard(er) to undertand (than this).
>     
>     Having said that, I am not adamant on the current design. Given another vote/idea I can switch.
> 
> Joseph Wu wrote:
>     If the eventual goal is to enable `LIBPROCESS_REQUIRE_PEER_ADDRESS_IP_MATCH` by default, it would make sense to either (A) add the special anonymous sender, or (B) remove the sender-less `process::post` variant entirely.
>     
>     In terms of implementing (A), I would opt for an implementation that is explicit.  This is primarily due to the ambiguity from calling `process::post(to, message)` within the context of a libprocess Process, vs a main thread or test body.
>     
>     That being said, we don't have any protections or validation regarding the `from` field anyway.  Any process can say `process::post(not_me /* :P */, to, message)` and that would be considered valid.
>     
>     ---
>     
>     I agree with the explicit anonymous sender approach.  But I don't think we necessarily need to implement the anonymous sender yet.
>     
>     I think going with the explicit route will give us an excuse to double-check any places with no sender address/UPID.  If we see no reason to keep it, then we could add the explicit anonymous sender if we ever find a reason to include it.

Not sure if I 100% understand the recommendation here. I think that it is:

- We implement `UPID process::anonymous()` and use it to avoid `LIBPROCESS_REQUIRE_PEER_ADDRESS_IP_MATCH` check failure.

> But I don't think we necessarily need to implement the anonymous sender yet.

Did you mean to say that we do "(B) remove the sender-less process::post variant entirely" later after we "double-check any places with no sender address/UPID"?


- Jiang Yan


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60821/#review180383
-----------------------------------------------------------


On July 12, 2017, 5:04 p.m., Jiang Yan Xu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60821/
> -----------------------------------------------------------
> 
> (Updated July 12, 2017, 5:04 p.m.)
> 
> 
> Review request for mesos, Benjamin Mahler, James Peach, and Joseph Wu.
> 
> 
> Bugs: MESOS-7786
>     https://issues.apache.org/jira/browse/MESOS-7786
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> The immediate use of this is to fix MESOS-7753 but I feel this is a general concept that's defined in similar systems (e.g., akka).
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/process.cpp b4d7791782a5d9e10fa44489057c8504d594bab2 
>   3rdparty/libprocess/src/tests/process_tests.cpp c6109547d04bd06e9395e4ec5f5130fd1500f9a0 
> 
> 
> Diff: https://reviews.apache.org/r/60821/diff/1/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jiang Yan Xu
> 
>


Re: Review Request 60821: Introduced a "no sender" UPID.

Posted by James Peach <jp...@apache.org>.

> On July 13, 2017, 12:27 a.m., James Peach wrote:
> > I think that a better approach is to define a static `UPID UPID::anonymous()` function that returns a well-defined anonymous UPID for the system. Remove all the sending functions that don't specify a `from` UPID and force them to explicitly pass the anonymous UPID. This makes the used of anonymous message sends explicit which I think is preferable to this implicit approach.
> 
> Jiang Yan Xu wrote:
>     Here's my thinking:
>     
>     - In libprocess the PID is usually not constructed directly, aside from being parsed but that's also hidden from the users of the library. Users of libprocess tend to get the PID from the process that owns that PID or from `spawn`. Afterwards it is used as an opaque ID. Therefore I feel like more consistent with the current architecture to not expose it at all. Having to know to use a speical ID is less straighfoward than calling a method that doesn't take a `from` IMO.
>     
>     - Right now the PID is just a simple data struct and not guarded by a `process::initialize()` call. This special UPID and PID uses the value of `__address__`, which initialized in `process::initialize()`. Therefore even if we expose this anonymous / no sender PID directly, I feel it's probably going to be constructed by something other than a static UPID method. This is a minor point though.

* Anything that calls `post` is going to have to initialize `libprocess`, so initializing `libprocess` when we generate the anonymous UPID seems OK too. `UPID process::anonymous()`.
* Sending anonymous messages is a special case, so it should be explicit. `post` is also a special case since you already have to specify a target UPID. I argue that explicit is better than implicit and 1 way to `post` is better than 2.


- James


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60821/#review180383
-----------------------------------------------------------


On July 13, 2017, 12:04 a.m., Jiang Yan Xu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60821/
> -----------------------------------------------------------
> 
> (Updated July 13, 2017, 12:04 a.m.)
> 
> 
> Review request for mesos, Benjamin Mahler, James Peach, and Joseph Wu.
> 
> 
> Bugs: MESOS-7786
>     https://issues.apache.org/jira/browse/MESOS-7786
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> The immediate use of this is to fix MESOS-7753 but I feel this is a general concept that's defined in similar systems (e.g., akka).
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/process.cpp b4d7791782a5d9e10fa44489057c8504d594bab2 
>   3rdparty/libprocess/src/tests/process_tests.cpp c6109547d04bd06e9395e4ec5f5130fd1500f9a0 
> 
> 
> Diff: https://reviews.apache.org/r/60821/diff/1/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jiang Yan Xu
> 
>


Re: Review Request 60821: Introduced a "no sender" UPID.

Posted by Joseph Wu <jo...@mesosphere.io>.

> On July 12, 2017, 5:27 p.m., James Peach wrote:
> > I think that a better approach is to define a static `UPID UPID::anonymous()` function that returns a well-defined anonymous UPID for the system. Remove all the sending functions that don't specify a `from` UPID and force them to explicitly pass the anonymous UPID. This makes the used of anonymous message sends explicit which I think is preferable to this implicit approach.
> 
> Jiang Yan Xu wrote:
>     Here's my thinking:
>     
>     - In libprocess the PID is usually not constructed directly, aside from being parsed but that's also hidden from the users of the library. Users of libprocess tend to get the PID from the process that owns that PID or from `spawn`. Afterwards it is used as an opaque ID. Therefore I feel like more consistent with the current architecture to not expose it at all. Having to know to use a speical ID is less straighfoward than calling a method that doesn't take a `from` IMO.
>     
>     - Right now the PID is just a simple data struct and not guarded by a `process::initialize()` call. This special UPID and PID uses the value of `__address__`, which initialized in `process::initialize()`. Therefore even if we expose this anonymous / no sender PID directly, I feel it's probably going to be constructed by something other than a static UPID method. This is a minor point though.
> 
> James Peach wrote:
>     * Anything that calls `post` is going to have to initialize `libprocess`, so initializing `libprocess` when we generate the anonymous UPID seems OK too. `UPID process::anonymous()`.
>     * Sending anonymous messages is a special case, so it should be explicit. `post` is also a special case since you already have to specify a target UPID. I argue that explicit is better than implicit and 1 way to `post` is better than 2.
> 
> Jiang Yan Xu wrote:
>     Yeah I think the main thing I am arguing for here is that as you said, the purpose of this is to support "Sending anonymous messages / message with no sender address". IMO the sentence from the user's POV translates to a method (and we already have this method), not an UPID.
>     
>     In othe words, this special [process::post](https://github.com/apache/mesos/blob/5645fddf07eab0fcd195a3514e9e5ad3ef25628d/3rdparty/libprocess/include/process/process.hpp#L626-L637) overload serves a special purpose that
>     - We currently have a use case directly
>     - I don't see how it could be incorrectly used for other unintended ways.
>     
>     
>     In contrast, exposing a special UPID to user:
>     - I don't see how the UPID can be used for another legit purpose.
>     - I can see it could used incorrectly by the user.
>     
>     
>     I do support explictness, but I think saying a method "sends message with no sender address" is pretty explicit too and without exposing too much flexibility and a concept that could be hard(er) to undertand (than this).
>     
>     Having said that, I am not adamant on the current design. Given another vote/idea I can switch.

If the eventual goal is to enable `LIBPROCESS_REQUIRE_PEER_ADDRESS_IP_MATCH` by default, it would make sense to either (A) add the special anonymous sender, or (B) remove the sender-less `process::post` variant entirely.

In terms of implementing (A), I would opt for an implementation that is explicit.  This is primarily due to the ambiguity from calling `process::post(to, message)` within the context of a libprocess Process, vs a main thread or test body.

That being said, we don't have any protections or validation regarding the `from` field anyway.  Any process can say `process::post(not_me /* :P */, to, message)` and that would be considered valid.

---

I agree with the explicit anonymous sender approach.  But I don't think we necessarily need to implement the anonymous sender yet.

I think going with the explicit route will give us an excuse to double-check any places with no sender address/UPID.  If we see no reason to keep it, then we could add the explicit anonymous sender if we ever find a reason to include it.


- Joseph


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60821/#review180383
-----------------------------------------------------------


On July 12, 2017, 5:04 p.m., Jiang Yan Xu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60821/
> -----------------------------------------------------------
> 
> (Updated July 12, 2017, 5:04 p.m.)
> 
> 
> Review request for mesos, Benjamin Mahler, James Peach, and Joseph Wu.
> 
> 
> Bugs: MESOS-7786
>     https://issues.apache.org/jira/browse/MESOS-7786
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> The immediate use of this is to fix MESOS-7753 but I feel this is a general concept that's defined in similar systems (e.g., akka).
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/process.cpp b4d7791782a5d9e10fa44489057c8504d594bab2 
>   3rdparty/libprocess/src/tests/process_tests.cpp c6109547d04bd06e9395e4ec5f5130fd1500f9a0 
> 
> 
> Diff: https://reviews.apache.org/r/60821/diff/1/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jiang Yan Xu
> 
>


Re: Review Request 60821: Introduced a "no sender" UPID.

Posted by Jiang Yan Xu <ya...@jxu.me>.

> On July 12, 2017, 5:27 p.m., James Peach wrote:
> > I think that a better approach is to define a static `UPID UPID::anonymous()` function that returns a well-defined anonymous UPID for the system. Remove all the sending functions that don't specify a `from` UPID and force them to explicitly pass the anonymous UPID. This makes the used of anonymous message sends explicit which I think is preferable to this implicit approach.
> 
> Jiang Yan Xu wrote:
>     Here's my thinking:
>     
>     - In libprocess the PID is usually not constructed directly, aside from being parsed but that's also hidden from the users of the library. Users of libprocess tend to get the PID from the process that owns that PID or from `spawn`. Afterwards it is used as an opaque ID. Therefore I feel like more consistent with the current architecture to not expose it at all. Having to know to use a speical ID is less straighfoward than calling a method that doesn't take a `from` IMO.
>     
>     - Right now the PID is just a simple data struct and not guarded by a `process::initialize()` call. This special UPID and PID uses the value of `__address__`, which initialized in `process::initialize()`. Therefore even if we expose this anonymous / no sender PID directly, I feel it's probably going to be constructed by something other than a static UPID method. This is a minor point though.
> 
> James Peach wrote:
>     * Anything that calls `post` is going to have to initialize `libprocess`, so initializing `libprocess` when we generate the anonymous UPID seems OK too. `UPID process::anonymous()`.
>     * Sending anonymous messages is a special case, so it should be explicit. `post` is also a special case since you already have to specify a target UPID. I argue that explicit is better than implicit and 1 way to `post` is better than 2.

Yeah I think the main thing I am arguing for here is that as you said, the purpose of this is to support "Sending anonymous messages / message with no sender address". IMO the sentence from the user's POV translates to a method (and we already have this method), not an UPID.

In othe words, this special [process::post](https://github.com/apache/mesos/blob/5645fddf07eab0fcd195a3514e9e5ad3ef25628d/3rdparty/libprocess/include/process/process.hpp#L626-L637) overload serves a special purpose that
- We currently have a use case directly
- I don't see how it could be incorrectly used for other unintended ways.


In contrast, exposing a special UPID to user:
- I don't see how the UPID can be used for another legit purpose.
- I can see it could used incorrectly by the user.


I do support explictness, but I think saying a method "sends message with no sender address" is pretty explicit too and without exposing too much flexibility and a concept that could be hard(er) to undertand (than this).

Having said that, I am not adamant on the current design. Given another vote/idea I can switch.


- Jiang Yan


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60821/#review180383
-----------------------------------------------------------


On July 12, 2017, 5:04 p.m., Jiang Yan Xu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60821/
> -----------------------------------------------------------
> 
> (Updated July 12, 2017, 5:04 p.m.)
> 
> 
> Review request for mesos, Benjamin Mahler, James Peach, and Joseph Wu.
> 
> 
> Bugs: MESOS-7786
>     https://issues.apache.org/jira/browse/MESOS-7786
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> The immediate use of this is to fix MESOS-7753 but I feel this is a general concept that's defined in similar systems (e.g., akka).
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/process.cpp b4d7791782a5d9e10fa44489057c8504d594bab2 
>   3rdparty/libprocess/src/tests/process_tests.cpp c6109547d04bd06e9395e4ec5f5130fd1500f9a0 
> 
> 
> Diff: https://reviews.apache.org/r/60821/diff/1/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jiang Yan Xu
> 
>


Re: Review Request 60821: Introduced a "no sender" UPID.

Posted by James Peach <jp...@apache.org>.
> On July 17th, 2017, 2:14 p.m. PDT, Jiang Yan Xu wrote:
> 
> Clarified with Joseph offline. The proposal is to just fix this specific situation in MESOS-7753 (I submitted /r/60917/ for review). I'll drop this review for now and we can revisit this when we have another use case.
> While I dropped this for now, here I'd like to summarize the discussion.
> So the discussion is around how to make these process::post methods less error-prone:
> // post(1)
> void post(const UPID& to,
>           const std::string& name,
>           const char* data = nullptr,
>           size_t length = 0);
> 
> // post(2)
> void post(const UPID& from,
>           const UPID& to,
>           const std::string& name,
>           const char* data = nullptr,
>           size_t length = 0);
> 
> 
> Given post(1) may be confused with send, which most Mesos "production" code uses:
>   void send(
>       const UPID& to,
>       const std::string& name,
>       const char* data = nullptr,
>       size_t length = 0);
> 
> 
> We can either a) eliminate post(1) and do
> post(UPID::anonymous(), to, data);
> 
> or b) hide the implementation under post(1) so you would do:
> post(to, data);
> 
> 
> Explicitness is good and at this point I am not preferring b) over a), but just would like to explore whether either is a good enough fix.
> Consider:
> 
> 	• Even if we eliminate post(2), is post(2) good enough? Should we put it in a different namespace to prevent misuse (currently most uses of either post are in tests)?

No, I already struggle to find symbols in the forest of namespaces.

> 	• What's going to prevent the caller from doing post(UPID(), to, data), is Try<Nothing> post(from, to, data) with validation going to help?

Maybe there's no good use case for an empty UPID? Alternatively `post` could `CHECK` the UPID?

> 	• Could UPID::anonymous() be misused for some unintented purposes?
> 	• If we use a different method name for post(1), something like noSenderPost(to, data) (I am sure we can come up with a better name), is it still confusing?

If `post` for when you send a message without a process. Maybe the right approach is to remove post(2) and define post(1) to always use the anonymous sender?

> 	• Finally, is any of these better than clearly document the APIs with caution notes about empty UPIDs?

Usually I refer to Rusty Russell' API levels. If we can make the API impossible to misuse or throw a runtime or compile time error, that's better than simply documenting the traps.

J

Re: Review Request 60821: Introduced a "no sender" UPID.

Posted by Jiang Yan Xu <ya...@jxu.me>.

> On July 12, 2017, 5:27 p.m., James Peach wrote:
> > I think that a better approach is to define a static `UPID UPID::anonymous()` function that returns a well-defined anonymous UPID for the system. Remove all the sending functions that don't specify a `from` UPID and force them to explicitly pass the anonymous UPID. This makes the used of anonymous message sends explicit which I think is preferable to this implicit approach.
> 
> Jiang Yan Xu wrote:
>     Here's my thinking:
>     
>     - In libprocess the PID is usually not constructed directly, aside from being parsed but that's also hidden from the users of the library. Users of libprocess tend to get the PID from the process that owns that PID or from `spawn`. Afterwards it is used as an opaque ID. Therefore I feel like more consistent with the current architecture to not expose it at all. Having to know to use a speical ID is less straighfoward than calling a method that doesn't take a `from` IMO.
>     
>     - Right now the PID is just a simple data struct and not guarded by a `process::initialize()` call. This special UPID and PID uses the value of `__address__`, which initialized in `process::initialize()`. Therefore even if we expose this anonymous / no sender PID directly, I feel it's probably going to be constructed by something other than a static UPID method. This is a minor point though.
> 
> James Peach wrote:
>     * Anything that calls `post` is going to have to initialize `libprocess`, so initializing `libprocess` when we generate the anonymous UPID seems OK too. `UPID process::anonymous()`.
>     * Sending anonymous messages is a special case, so it should be explicit. `post` is also a special case since you already have to specify a target UPID. I argue that explicit is better than implicit and 1 way to `post` is better than 2.
> 
> Jiang Yan Xu wrote:
>     Yeah I think the main thing I am arguing for here is that as you said, the purpose of this is to support "Sending anonymous messages / message with no sender address". IMO the sentence from the user's POV translates to a method (and we already have this method), not an UPID.
>     
>     In othe words, this special [process::post](https://github.com/apache/mesos/blob/5645fddf07eab0fcd195a3514e9e5ad3ef25628d/3rdparty/libprocess/include/process/process.hpp#L626-L637) overload serves a special purpose that
>     - We currently have a use case directly
>     - I don't see how it could be incorrectly used for other unintended ways.
>     
>     
>     In contrast, exposing a special UPID to user:
>     - I don't see how the UPID can be used for another legit purpose.
>     - I can see it could used incorrectly by the user.
>     
>     
>     I do support explictness, but I think saying a method "sends message with no sender address" is pretty explicit too and without exposing too much flexibility and a concept that could be hard(er) to undertand (than this).
>     
>     Having said that, I am not adamant on the current design. Given another vote/idea I can switch.
> 
> Joseph Wu wrote:
>     If the eventual goal is to enable `LIBPROCESS_REQUIRE_PEER_ADDRESS_IP_MATCH` by default, it would make sense to either (A) add the special anonymous sender, or (B) remove the sender-less `process::post` variant entirely.
>     
>     In terms of implementing (A), I would opt for an implementation that is explicit.  This is primarily due to the ambiguity from calling `process::post(to, message)` within the context of a libprocess Process, vs a main thread or test body.
>     
>     That being said, we don't have any protections or validation regarding the `from` field anyway.  Any process can say `process::post(not_me /* :P */, to, message)` and that would be considered valid.
>     
>     ---
>     
>     I agree with the explicit anonymous sender approach.  But I don't think we necessarily need to implement the anonymous sender yet.
>     
>     I think going with the explicit route will give us an excuse to double-check any places with no sender address/UPID.  If we see no reason to keep it, then we could add the explicit anonymous sender if we ever find a reason to include it.
> 
> Jiang Yan Xu wrote:
>     Not sure if I 100% understand the recommendation here. I think that it is:
>     
>     - We implement `UPID process::anonymous()` and use it to avoid `LIBPROCESS_REQUIRE_PEER_ADDRESS_IP_MATCH` check failure.
>     
>     > But I don't think we necessarily need to implement the anonymous sender yet.
>     
>     Did you mean to say that we do "(B) remove the sender-less process::post variant entirely" later after we "double-check any places with no sender address/UPID"?
> 
> Jiang Yan Xu wrote:
>     Clarified with Joseph offline. The proposal is to just fix this specific situation in MESOS-7753 (I submitted /r/60917/ for review). I'll drop this review for now and we can revisit this when we have another use case.

While I dropped this for now, here I'd like to summarize the discussion.

So the discussion is around how to make these [process::post](https://github.com/apache/mesos/blob/91b3abcfa98de3c2b6231eec7ab0f3df3c53dcd8/3rdparty/libprocess/include/process/process.hpp#L626-L644) methods less error-prone:

```
// post(1)
void post(const UPID& to,
          const std::string& name,
          const char* data = nullptr,
          size_t length = 0);

// post(2)
void post(const UPID& from,
          const UPID& to,
          const std::string& name,
          const char* data = nullptr,
          size_t length = 0);
```

Given `post`(1) may be confused with [send](https://github.com/apache/mesos/blob/91b3abcfa98de3c2b6231eec7ab0f3df3c53dcd8/3rdparty/libprocess/include/process/process.hpp#L142-L151), which most Mesos "production" code uses:

```
  void send(
      const UPID& to,
      const std::string& name,
      const char* data = nullptr,
      size_t length = 0);
```

We can either a) eliminate `post`(1) and do

```
post(UPID::anonymous(), to, data);
```

or b) hide the implementation under `post`(1) so you would do:

```
post(to, data);
```

Explicitness is good and at this point I am not preferring b) over a), but just would like to explore whether either is a good enough fix.

Consider:

- Even if we eliminate post(2), is post(2) good enough? Should we put it in a different namespace to prevent misuse (currently most uses of either `post` are in tests)?
- What's going to prevent the caller from doing `post(UPID(), to, data)`, is `Try<Nothing> post(from, to, data)` with validation going to help?
- Could `UPID::anonymous()` be misused for some unintented purposes?
- If we use a different method name for post(1), something like `noSenderPost(to, data)` (I am sure we can come up with a better name), is it still confusing? 
- Finally, is any of these better than clearly document the APIs with caution notes about empty `UPID`s?


- Jiang Yan


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60821/#review180383
-----------------------------------------------------------


On July 12, 2017, 5:04 p.m., Jiang Yan Xu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60821/
> -----------------------------------------------------------
> 
> (Updated July 12, 2017, 5:04 p.m.)
> 
> 
> Review request for mesos, Benjamin Mahler, James Peach, and Joseph Wu.
> 
> 
> Bugs: MESOS-7786
>     https://issues.apache.org/jira/browse/MESOS-7786
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> The immediate use of this is to fix MESOS-7753 but I feel this is a general concept that's defined in similar systems (e.g., akka).
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/process.cpp b4d7791782a5d9e10fa44489057c8504d594bab2 
>   3rdparty/libprocess/src/tests/process_tests.cpp c6109547d04bd06e9395e4ec5f5130fd1500f9a0 
> 
> 
> Diff: https://reviews.apache.org/r/60821/diff/1/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jiang Yan Xu
> 
>


Re: Review Request 60821: Introduced a "no sender" UPID.

Posted by Jiang Yan Xu <ya...@jxu.me>.

> On July 12, 2017, 5:27 p.m., James Peach wrote:
> > I think that a better approach is to define a static `UPID UPID::anonymous()` function that returns a well-defined anonymous UPID for the system. Remove all the sending functions that don't specify a `from` UPID and force them to explicitly pass the anonymous UPID. This makes the used of anonymous message sends explicit which I think is preferable to this implicit approach.
> 
> Jiang Yan Xu wrote:
>     Here's my thinking:
>     
>     - In libprocess the PID is usually not constructed directly, aside from being parsed but that's also hidden from the users of the library. Users of libprocess tend to get the PID from the process that owns that PID or from `spawn`. Afterwards it is used as an opaque ID. Therefore I feel like more consistent with the current architecture to not expose it at all. Having to know to use a speical ID is less straighfoward than calling a method that doesn't take a `from` IMO.
>     
>     - Right now the PID is just a simple data struct and not guarded by a `process::initialize()` call. This special UPID and PID uses the value of `__address__`, which initialized in `process::initialize()`. Therefore even if we expose this anonymous / no sender PID directly, I feel it's probably going to be constructed by something other than a static UPID method. This is a minor point though.
> 
> James Peach wrote:
>     * Anything that calls `post` is going to have to initialize `libprocess`, so initializing `libprocess` when we generate the anonymous UPID seems OK too. `UPID process::anonymous()`.
>     * Sending anonymous messages is a special case, so it should be explicit. `post` is also a special case since you already have to specify a target UPID. I argue that explicit is better than implicit and 1 way to `post` is better than 2.
> 
> Jiang Yan Xu wrote:
>     Yeah I think the main thing I am arguing for here is that as you said, the purpose of this is to support "Sending anonymous messages / message with no sender address". IMO the sentence from the user's POV translates to a method (and we already have this method), not an UPID.
>     
>     In othe words, this special [process::post](https://github.com/apache/mesos/blob/5645fddf07eab0fcd195a3514e9e5ad3ef25628d/3rdparty/libprocess/include/process/process.hpp#L626-L637) overload serves a special purpose that
>     - We currently have a use case directly
>     - I don't see how it could be incorrectly used for other unintended ways.
>     
>     
>     In contrast, exposing a special UPID to user:
>     - I don't see how the UPID can be used for another legit purpose.
>     - I can see it could used incorrectly by the user.
>     
>     
>     I do support explictness, but I think saying a method "sends message with no sender address" is pretty explicit too and without exposing too much flexibility and a concept that could be hard(er) to undertand (than this).
>     
>     Having said that, I am not adamant on the current design. Given another vote/idea I can switch.
> 
> Joseph Wu wrote:
>     If the eventual goal is to enable `LIBPROCESS_REQUIRE_PEER_ADDRESS_IP_MATCH` by default, it would make sense to either (A) add the special anonymous sender, or (B) remove the sender-less `process::post` variant entirely.
>     
>     In terms of implementing (A), I would opt for an implementation that is explicit.  This is primarily due to the ambiguity from calling `process::post(to, message)` within the context of a libprocess Process, vs a main thread or test body.
>     
>     That being said, we don't have any protections or validation regarding the `from` field anyway.  Any process can say `process::post(not_me /* :P */, to, message)` and that would be considered valid.
>     
>     ---
>     
>     I agree with the explicit anonymous sender approach.  But I don't think we necessarily need to implement the anonymous sender yet.
>     
>     I think going with the explicit route will give us an excuse to double-check any places with no sender address/UPID.  If we see no reason to keep it, then we could add the explicit anonymous sender if we ever find a reason to include it.
> 
> Jiang Yan Xu wrote:
>     Not sure if I 100% understand the recommendation here. I think that it is:
>     
>     - We implement `UPID process::anonymous()` and use it to avoid `LIBPROCESS_REQUIRE_PEER_ADDRESS_IP_MATCH` check failure.
>     
>     > But I don't think we necessarily need to implement the anonymous sender yet.
>     
>     Did you mean to say that we do "(B) remove the sender-less process::post variant entirely" later after we "double-check any places with no sender address/UPID"?

Clarified with Joseph offline. The proposal is to just fix this specific situation in MESOS-7753 (I submitted /r/60917/ for review). I'll drop this review for now and we can revisit this when we have another use case.


- Jiang Yan


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60821/#review180383
-----------------------------------------------------------


On July 12, 2017, 5:04 p.m., Jiang Yan Xu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60821/
> -----------------------------------------------------------
> 
> (Updated July 12, 2017, 5:04 p.m.)
> 
> 
> Review request for mesos, Benjamin Mahler, James Peach, and Joseph Wu.
> 
> 
> Bugs: MESOS-7786
>     https://issues.apache.org/jira/browse/MESOS-7786
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> The immediate use of this is to fix MESOS-7753 but I feel this is a general concept that's defined in similar systems (e.g., akka).
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/process.cpp b4d7791782a5d9e10fa44489057c8504d594bab2 
>   3rdparty/libprocess/src/tests/process_tests.cpp c6109547d04bd06e9395e4ec5f5130fd1500f9a0 
> 
> 
> Diff: https://reviews.apache.org/r/60821/diff/1/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jiang Yan Xu
> 
>


Re: Review Request 60821: Introduced a "no sender" UPID.

Posted by Jiang Yan Xu <ya...@jxu.me>.

> On July 12, 2017, 5:27 p.m., James Peach wrote:
> > I think that a better approach is to define a static `UPID UPID::anonymous()` function that returns a well-defined anonymous UPID for the system. Remove all the sending functions that don't specify a `from` UPID and force them to explicitly pass the anonymous UPID. This makes the used of anonymous message sends explicit which I think is preferable to this implicit approach.

Here's my thinking:

- In libprocess the PID is usually not constructed directly, aside from being parsed but that's also hidden from the users of the library. Users of libprocess tend to get the PID from the process that owns that PID or from `spawn`. Afterwards it is used as an opaque ID. Therefore I feel like more consistent with the current architecture to not expose it at all. Having to know to use a speical ID is less straighfoward than calling a method that doesn't take a `from` IMO.

- Right now the PID is just a simple data struct and not guarded by a `process::initialize()` call. This special UPID and PID uses the value of `__address__`, which initialized in `process::initialize()`. Therefore even if we expose this anonymous / no sender PID directly, I feel it's probably going to be constructed by something other than a static UPID method. This is a minor point though.


- Jiang Yan


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60821/#review180383
-----------------------------------------------------------


On July 12, 2017, 5:04 p.m., Jiang Yan Xu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60821/
> -----------------------------------------------------------
> 
> (Updated July 12, 2017, 5:04 p.m.)
> 
> 
> Review request for mesos, Benjamin Mahler, James Peach, and Joseph Wu.
> 
> 
> Bugs: MESOS-7786
>     https://issues.apache.org/jira/browse/MESOS-7786
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> The immediate use of this is to fix MESOS-7753 but I feel this is a general concept that's defined in similar systems (e.g., akka).
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/process.cpp b4d7791782a5d9e10fa44489057c8504d594bab2 
>   3rdparty/libprocess/src/tests/process_tests.cpp c6109547d04bd06e9395e4ec5f5130fd1500f9a0 
> 
> 
> Diff: https://reviews.apache.org/r/60821/diff/1/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jiang Yan Xu
> 
>


Re: Review Request 60821: Introduced a "no sender" UPID.

Posted by James Peach <jp...@apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60821/#review180383
-----------------------------------------------------------



I think that a better approach is to define a static `UPID UPID::anonymous()` function that returns a well-defined anonymous UPID for the system. Remove all the sending functions that don't specify a `from` UPID and force them to explicitly pass the anonymous UPID. This makes the used of anonymous message sends explicit which I think is preferable to this implicit approach.

- James Peach


On July 13, 2017, 12:04 a.m., Jiang Yan Xu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60821/
> -----------------------------------------------------------
> 
> (Updated July 13, 2017, 12:04 a.m.)
> 
> 
> Review request for mesos, Benjamin Mahler, James Peach, and Joseph Wu.
> 
> 
> Bugs: MESOS-7786
>     https://issues.apache.org/jira/browse/MESOS-7786
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> The immediate use of this is to fix MESOS-7753 but I feel this is a general concept that's defined in similar systems (e.g., akka).
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/process.cpp b4d7791782a5d9e10fa44489057c8504d594bab2 
>   3rdparty/libprocess/src/tests/process_tests.cpp c6109547d04bd06e9395e4ec5f5130fd1500f9a0 
> 
> 
> Diff: https://reviews.apache.org/r/60821/diff/1/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jiang Yan Xu
> 
>


Re: Review Request 60821: Introduced a "no sender" UPID.

Posted by Mesos Reviewbot Windows <re...@mesos.apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60821/#review180386
-----------------------------------------------------------



Patch looks great!

Reviews applied: [60821]

Passed command: support\windows-build.bat

- Mesos Reviewbot Windows


On July 12, 2017, 5:04 p.m., Jiang Yan Xu wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60821/
> -----------------------------------------------------------
> 
> (Updated July 12, 2017, 5:04 p.m.)
> 
> 
> Review request for mesos, Benjamin Mahler, James Peach, and Joseph Wu.
> 
> 
> Bugs: MESOS-7786
>     https://issues.apache.org/jira/browse/MESOS-7786
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> The immediate use of this is to fix MESOS-7753 but I feel this is a general concept that's defined in similar systems (e.g., akka).
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/src/process.cpp b4d7791782a5d9e10fa44489057c8504d594bab2 
>   3rdparty/libprocess/src/tests/process_tests.cpp c6109547d04bd06e9395e4ec5f5130fd1500f9a0 
> 
> 
> Diff: https://reviews.apache.org/r/60821/diff/1/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jiang Yan Xu
> 
>