You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by Dominic Hamon <do...@gmail.com> on 2014/02/12 01:53:27 UTC

Review Request 17976: Updated resource model reporting to respect multiple roles.

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

Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.


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


Repository: mesos-git


Description
-------

See summary.


Diffs
-----

  src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
  src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 

Diff: https://reviews.apache.org/r/17976/diff/


Testing
-------

make check


Thanks,

Dominic Hamon


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <dh...@twopensource.com>.

> On Feb. 12, 2014, 11:51 a.m., Ben Mahler wrote:
> > As a heads up, changing the Resource model will potentially break the webui, which is not verified through make check.
> > 
> > Can you also show the old vs new JSON format in the review description / testing, that would be very helpful!

Added to the description.

I'll check the webui can handle this new format.


- Dominic


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


On Feb. 14, 2014, 12:41 p.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 14, 2014, 12:41 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> old format of master/state.json:
> {...
> "slaves":[...
>   "resources":{"ports":"[31000-32000]"}}
>   ...]
> ...}
> 
> new format:
> {...
> "slaves":[...
>   "resources":{"*":{"ports":"[31000-32000]"}}}
>   ...]
> ...}
> 
> There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
>   src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Ben Mahler <be...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/#review34314
-----------------------------------------------------------


As a heads up, changing the Resource model will potentially break the webui, which is not verified through make check.

Can you also show the old vs new JSON format in the review description / testing, that would be very helpful!

- Ben Mahler


On Feb. 12, 2014, 12:53 a.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 12, 2014, 12:53 a.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <do...@gmail.com>.

> On Feb. 12, 2014, 11:40 p.m., Ben Mahler wrote:
> > You'll need to include some changes in here to update the webui, a good starting point is controllers.js (for example, see the update(...) function). We can help you test out the webui to make sure we've updated it to handle the new model.

I have a patch ready to go with the controllers.js updated. I ran mesos-master.sh, mesos-slave.sh, and the python test framework and the memory used updated.


> On Feb. 12, 2014, 11:40 p.m., Ben Mahler wrote:
> > src/master/http.cpp, lines 93-96
> > <https://reviews.apache.org/r/17976/diff/1/?file=483103#file483103line93>
> >
> >     We should definitely implement the aggregation since roles are not unique across resources.
> >     
> >     What about just pulling out the role object above when it already exists?
> >     
> >     JSON::Object role;
> >     if (object.values.count(resource.role()) > 0) {
> >       role = object.values[resource.role()];
> >     }
> >     
> >     ...
> >     
> >     object.values[resource.role()] = role;

it's not that simple. In the case of a scalar you'd then need to add the value. In the case of a range, you'd need to update the min/max, etc.

But yes, i'll make this change too now i've seen the webui causing the warning to be logged :)


- Dominic


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


On Feb. 12, 2014, 11:04 p.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 12, 2014, 11:04 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> old format of master/state.json:
> {...
> "slaves":[...
>   "resources":{"ports":"[31000-32000]"}}
>   ...]
> ...}
> 
> new format:
> {...
> "slaves":[...
>   "resources":{"*":{"ports":"[31000-32000]"}}}
>   ...]
> ...}
> 
> There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Ben Mahler <be...@gmail.com>.

> On Feb. 12, 2014, 11:40 p.m., Ben Mahler wrote:
> > src/master/http.cpp, lines 93-96
> > <https://reviews.apache.org/r/17976/diff/1/?file=483103#file483103line93>
> >
> >     We should definitely implement the aggregation since roles are not unique across resources.
> >     
> >     What about just pulling out the role object above when it already exists?
> >     
> >     JSON::Object role;
> >     if (object.values.count(resource.role()) > 0) {
> >       role = object.values[resource.role()];
> >     }
> >     
> >     ...
> >     
> >     object.values[resource.role()] = role;
> 
> Dominic Hamon wrote:
>     it's not that simple. In the case of a scalar you'd then need to add the value. In the case of a range, you'd need to update the min/max, etc.
>     
>     But yes, i'll make this change too now i've seen the webui causing the warning to be logged :)

Can you clarify why you need to do this kind of merging? Aren't the resource names different for a particular role? (That we should be enforcing, if not already).


- Ben


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


On Feb. 12, 2014, 11:04 p.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 12, 2014, 11:04 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> old format of master/state.json:
> {...
> "slaves":[...
>   "resources":{"ports":"[31000-32000]"}}
>   ...]
> ...}
> 
> new format:
> {...
> "slaves":[...
>   "resources":{"*":{"ports":"[31000-32000]"}}}
>   ...]
> ...}
> 
> There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Ben Mahler <be...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/#review34328
-----------------------------------------------------------


You'll need to include some changes in here to update the webui, a good starting point is controllers.js (for example, see the update(...) function). We can help you test out the webui to make sure we've updated it to handle the new model.


src/master/http.cpp
<https://reviews.apache.org/r/17976/#comment64379>

    We should definitely implement the aggregation since roles are not unique across resources.
    
    What about just pulling out the role object above when it already exists?
    
    JSON::Object role;
    if (object.values.count(resource.role()) > 0) {
      role = object.values[resource.role()];
    }
    
    ...
    
    object.values[resource.role()] = role;


- Ben Mahler


On Feb. 12, 2014, 11:04 p.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 12, 2014, 11:04 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> old format of master/state.json:
> {...
> "slaves":[...
>   "resources":{"ports":"[31000-32000]"}}
>   ...]
> ...}
> 
> new format:
> {...
> "slaves":[...
>   "resources":{"*":{"ports":"[31000-32000]"}}}
>   ...]
> ...}
> 
> There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Ben Mahler <be...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/#review34548
-----------------------------------------------------------


This is looking good, mostly just some stylistic nits below.


src/master/http.cpp
<https://reviews.apache.org/r/17976/#comment64667>

    Since there are already 'using' clauses above, we can remove the 'std::' qualifiers on map and string.
    
    How about: s/roleObjects/roles/



src/master/http.cpp
<https://reviews.apache.org/r/17976/#comment64678>

    In general we avoid using non-const references to mutate data, what if we stored the role string:
    
      foreach(...) {
        const string& role = resource.role();
        
        switch(...) {
          ...
          case Value::RANGES:
            roles[role].values[resource.name()] = stringify(resource.ranges());
            break;
          ...
      }



src/master/http.cpp
<https://reviews.apache.org/r/17976/#comment64676>

    Can you add a newline here?



src/master/http.cpp
<https://reviews.apache.org/r/17976/#comment64669>

    Can you remove the 'std::' qualifier?
    
    Maybe s/roleObject/object/ or s/roleObject/resources/ ?



src/webui/master/static/js/controllers.js
<https://reviews.apache.org/r/17976/#comment64675>

    What is r? ;)


- Ben Mahler


On Feb. 14, 2014, 8:41 p.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 14, 2014, 8:41 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> old format of master/state.json:
> {...
> "slaves":[...
>   "resources":{"ports":"[31000-32000]"}}
>   ...]
> ...}
> 
> new format:
> {...
> "slaves":[...
>   "resources":{"*":{"ports":"[31000-32000]"}}}
>   ...]
> ...}
> 
> There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
>   src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Benjamin Hindman <be...@berkeley.edu>.

> On Feb. 15, 2014, 12:56 a.m., Dominic Hamon wrote:
> >

FYI, we prefer to respond to review comments on the "main" page (i.e., the only one where you can read this comment). That way we can more easily track the thread across diffs. 


> On Feb. 15, 2014, 12:56 a.m., Dominic Hamon wrote:
> > src/master/http.cpp, line 78
> > <https://reviews.apache.org/r/17976/diff/2/?file=486048#file486048line78>
> >
> >     You're right, sorry.
> >     
> >     I do feel that it is much less readable (and maintainable) without the non-const reference. I'm still curious to understand why this perfectly valid use-case for references would be avoided in this case.

I'm not convinced it's more readable or maintainable with the non-const reference.

A reader needs to remember as they go through the code that 'role' is in fact a _pointer_ (masquerading as a reference) into the 'roles' map, so manipulating it is manipulating an object "someplace else". We avoid this style generally in Mesos (and libprocess, and stout), and while this piece of code is small it's better to be consistent everywhere.

The statement 'roles[resource.role()].values[resource.name()] = resource.scalar().value();' is "complete" in the sense that in isolation you can understand exactly what is happening because it has no dependencies (or at least, less dependencies, i.e., you need to remember less to understand it). In my experience, less dependencies has typically yielded more maintainable code (because there is less state around that needs to be referenced, copied, etc., when doing any refactoring).


- Benjamin


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


On Feb. 15, 2014, 12:56 a.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 15, 2014, 12:56 a.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> old format of master/state.json:
> {...
> "slaves":[...
>   "resources":{"ports":"[31000-32000]"}}
>   ...]
> ...}
> 
> new format:
> {...
> "slaves":[...
>   "resources":{"*":{"ports":"[31000-32000]"}}}
>   ...]
> ...}
> 
> There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
>   src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <dh...@twopensource.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/#review34562
-----------------------------------------------------------



src/master/http.cpp
<https://reviews.apache.org/r/17976/#comment64687>

    Fair enough - renamed (here and in slave)



src/master/http.cpp
<https://reviews.apache.org/r/17976/#comment64688>

    You're right, sorry.
    
    I do feel that it is much less readable (and maintainable) without the non-const reference. I'm still curious to understand why this perfectly valid use-case for references would be avoided in this case.


- Dominic Hamon


On Feb. 14, 2014, 4:56 p.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 14, 2014, 4:56 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> old format of master/state.json:
> {...
> "slaves":[...
>   "resources":{"ports":"[31000-32000]"}}
>   ...]
> ...}
> 
> new format:
> {...
> "slaves":[...
>   "resources":{"*":{"ports":"[31000-32000]"}}}
>   ...]
> ...}
> 
> There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
>   src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Ben Mahler <be...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/#review34821
-----------------------------------------------------------



src/webui/master/static/js/controllers.js
<https://reviews.apache.org/r/17976/#comment65181>

    'resource' seems a little misleading since it will be the 'resources' for a particular role.
    
    for (var resource in slave.resources) {
      // resource == {'cpus':1.0, 'mem':1024}
    }
    
    I would suggest this but it's a bit strange:
    for (var resources in slave.resources) {
    }
    
    What about iterating over the keys (pardon the bogus syntax):
    
    foreachkey (var role, offer.resources) {
      $scope.total_cpus += offer.resources[role].cpus;
      $scope.total_mem += offer.resources[role].mem;
    }
    
    Can you include Ross Allen on this review? I recall some discussion around 'for' syntax and using Angular's forEeach.


- Ben Mahler


On Feb. 18, 2014, 7:24 p.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 18, 2014, 7:24 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> old format of master/state.json:
> {...
> "slaves":[...
>   "resources":{"ports":"[31000-32000]"}}
>   ...]
> ...}
> 
> new format:
> {...
> "slaves":[...
>   "resources":{"*":{"ports":"[31000-32000]"}}}
>   ...]
> ...}
> 
> There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
>   src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <dh...@twopensource.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/
-----------------------------------------------------------

(Updated Feb. 19, 2014, 11:10 a.m.)


Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.


Changes
-------

Updated static html and js to correctly use summarised resources.


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


Repository: mesos-git


Description
-------

See summary.

old format of master/state.json:
{...
"slaves":[...
  "resources":{"ports":"[31000-32000]"}}
  ...]
...}

new format:
{...
"slaves":[...
  "resources":{"*":{"ports":"[31000-32000]"}}}
  ...]
...}

There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.


Diffs (updated)
-----

  src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
  src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
  src/webui/master/static/framework.html f6cce028867f527e49c647d39a481ffe6fe58328 
  src/webui/master/static/frameworks.html 8686b00eb0fca1c3102389cdc860ae8f2b46bd9f 
  src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 
  src/webui/master/static/offers.html cc199352fcf2074dcd0e8d24bb49651b38c41d86 
  src/webui/master/static/slave.html 09bfcf29a700168938f4ec4fa42ca8383fa55511 
  src/webui/master/static/slave_executor.html 7c66405090f46f89bdd29806a58c05dc76c0ad23 

Diff: https://reviews.apache.org/r/17976/diff/


Testing
-------

make check


Thanks,

Dominic Hamon


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <dh...@twopensource.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/
-----------------------------------------------------------

(Updated Feb. 19, 2014, 9:53 a.m.)


Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.


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


Repository: mesos-git


Description
-------

See summary.

old format of master/state.json:
{...
"slaves":[...
  "resources":{"ports":"[31000-32000]"}}
  ...]
...}

new format:
{...
"slaves":[...
  "resources":{"*":{"ports":"[31000-32000]"}}}
  ...]
...}

There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.


Diffs (updated)
-----

  src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
  src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
  src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 

Diff: https://reviews.apache.org/r/17976/diff/


Testing
-------

make check


Thanks,

Dominic Hamon


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Ross Allen <ro...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/#review34823
-----------------------------------------------------------



src/webui/master/static/js/controllers.js
<https://reviews.apache.org/r/17976/#comment65184>

    Since the file already uses Underscore's `_.each` for iteration, let's stick with that in all cases of iteration in this review request. It delegates to the native `Array.prototype.forEach` if it exists.
    
        _.each(slave.resources, function(resource) {
          ...
        });


- Ross Allen


On Feb. 18, 2014, 7:24 p.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 18, 2014, 7:24 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> old format of master/state.json:
> {...
> "slaves":[...
>   "resources":{"ports":"[31000-32000]"}}
>   ...]
> ...}
> 
> new format:
> {...
> "slaves":[...
>   "resources":{"*":{"ports":"[31000-32000]"}}}
>   ...]
> ...}
> 
> There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
>   src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <dh...@twopensource.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/
-----------------------------------------------------------

(Updated Feb. 18, 2014, 11:24 a.m.)


Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.


Changes
-------

There have been some discussion to change names of variables. Given that 18144 moves this code to 'src/common' and there's no functional changes requested, I'd like to take care of those fixes in that review.


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


Repository: mesos-git


Description
-------

See summary.

old format of master/state.json:
{...
"slaves":[...
  "resources":{"ports":"[31000-32000]"}}
  ...]
...}

new format:
{...
"slaves":[...
  "resources":{"*":{"ports":"[31000-32000]"}}}
  ...]
...}

There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.


Diffs
-----

  src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
  src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
  src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 

Diff: https://reviews.apache.org/r/17976/diff/


Testing
-------

make check


Thanks,

Dominic Hamon


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <dh...@twopensource.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/
-----------------------------------------------------------

(Updated Feb. 18, 2014, 9:47 a.m.)


Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.


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


Repository: mesos-git


Description
-------

See summary.

old format of master/state.json:
{...
"slaves":[...
  "resources":{"ports":"[31000-32000]"}}
  ...]
...}

new format:
{...
"slaves":[...
  "resources":{"*":{"ports":"[31000-32000]"}}}
  ...]
...}

There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.


Diffs (updated)
-----

  src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
  src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
  src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 

Diff: https://reviews.apache.org/r/17976/diff/


Testing
-------

make check


Thanks,

Dominic Hamon


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <dh...@twopensource.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/
-----------------------------------------------------------

(Updated Feb. 14, 2014, 4:56 p.m.)


Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.


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


Repository: mesos-git


Description
-------

See summary.

old format of master/state.json:
{...
"slaves":[...
  "resources":{"ports":"[31000-32000]"}}
  ...]
...}

new format:
{...
"slaves":[...
  "resources":{"*":{"ports":"[31000-32000]"}}}
  ...]
...}

There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.


Diffs (updated)
-----

  src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
  src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
  src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 

Diff: https://reviews.apache.org/r/17976/diff/


Testing
-------

make check


Thanks,

Dominic Hamon


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <dh...@twopensource.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/
-----------------------------------------------------------

(Updated Feb. 14, 2014, 4:14 p.m.)


Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.


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


Repository: mesos-git


Description
-------

See summary.

old format of master/state.json:
{...
"slaves":[...
  "resources":{"ports":"[31000-32000]"}}
  ...]
...}

new format:
{...
"slaves":[...
  "resources":{"*":{"ports":"[31000-32000]"}}}
  ...]
...}

There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.


Diffs (updated)
-----

  src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
  src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
  src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 

Diff: https://reviews.apache.org/r/17976/diff/


Testing
-------

make check


Thanks,

Dominic Hamon


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Ben Mahler <be...@gmail.com>.

> On Feb. 15, 2014, 12:08 a.m., Dominic Hamon wrote:
> > src/master/http.cpp, line 78
> > <https://reviews.apache.org/r/17976/diff/2/?file=486048#file486048line78>
> >
> >     I can understand avoiding passing non-const references to methods (to avoid dangling references) but why would you avoid the non-const reference for mutation in this case?
> >     
> >     The alternative is more expensive (a roles[role] lookup every time) and less readable.
> >     
> >     I'll change it if you insist, but I'd like to understand why.

What do you mean by 'every time'? There is a single lookup either way, since each switch case has a 'break'.


> On Feb. 15, 2014, 12:08 a.m., Dominic Hamon wrote:
> > src/master/http.cpp, line 75
> > <https://reviews.apache.org/r/17976/diff/2/?file=486048#file486048line75>
> >
> >     I prefer to specify that these are JSON::Objects that are being indexed.

I don't feel strongly here, it appears that the information about the 'Object' mapping is already apparent from the type (and since this variable is so close to its usage, the concise name seems evident). No?


- Ben


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


On Feb. 15, 2014, 12:14 a.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 15, 2014, 12:14 a.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> old format of master/state.json:
> {...
> "slaves":[...
>   "resources":{"ports":"[31000-32000]"}}
>   ...]
> ...}
> 
> new format:
> {...
> "slaves":[...
>   "resources":{"*":{"ports":"[31000-32000]"}}}
>   ...]
> ...}
> 
> There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
>   src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <dh...@twopensource.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/#review34554
-----------------------------------------------------------



src/master/http.cpp
<https://reviews.apache.org/r/17976/#comment64679>

    I prefer to specify that these are JSON::Objects that are being indexed.



src/master/http.cpp
<https://reviews.apache.org/r/17976/#comment64680>

    I can understand avoiding passing non-const references to methods (to avoid dangling references) but why would you avoid the non-const reference for mutation in this case?
    
    The alternative is more expensive (a roles[role] lookup every time) and less readable.
    
    I'll change it if you insist, but I'd like to understand why.


- Dominic Hamon


On Feb. 14, 2014, 12:41 p.m., Dominic Hamon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17976/
> -----------------------------------------------------------
> 
> (Updated Feb. 14, 2014, 12:41 p.m.)
> 
> 
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
> 
> 
> Bugs: MESOS-692
>     https://issues.apache.org/jira/browse/MESOS-692
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> See summary.
> 
> old format of master/state.json:
> {...
> "slaves":[...
>   "resources":{"ports":"[31000-32000]"}}
>   ...]
> ...}
> 
> new format:
> {...
> "slaves":[...
>   "resources":{"*":{"ports":"[31000-32000]"}}}
>   ...]
> ...}
> 
> There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.
> 
> 
> Diffs
> -----
> 
>   src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
>   src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
>   src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 
> 
> Diff: https://reviews.apache.org/r/17976/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Dominic Hamon
> 
>


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <dh...@twopensource.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/
-----------------------------------------------------------

(Updated Feb. 14, 2014, 12:41 p.m.)


Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.


Changes
-------

using a local map to build up the per-role resources, then combining.

output:

"resources":{"*":{"cpus":1,"disk":9386,"mem":988,"ports":"[31000-32000]"}}


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


Repository: mesos-git


Description
-------

See summary.

old format of master/state.json:
{...
"slaves":[...
  "resources":{"ports":"[31000-32000]"}}
  ...]
...}

new format:
{...
"slaves":[...
  "resources":{"*":{"ports":"[31000-32000]"}}}
  ...]
...}

There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.


Diffs (updated)
-----

  src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
  src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 
  src/webui/master/static/js/controllers.js afb24fb9c2184772f7314162f5637dbabaa2ab94 

Diff: https://reviews.apache.org/r/17976/diff/


Testing
-------

make check


Thanks,

Dominic Hamon


Re: Review Request 17976: Updated resource model reporting to respect multiple roles.

Posted by Dominic Hamon <do...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17976/
-----------------------------------------------------------

(Updated Feb. 12, 2014, 11:04 p.m.)


Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.


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


Repository: mesos-git


Description (updated)
-------

See summary.

old format of master/state.json:
{...
"slaves":[...
  "resources":{"ports":"[31000-32000]"}}
  ...]
...}

new format:
{...
"slaves":[...
  "resources":{"*":{"ports":"[31000-32000]"}}}
  ...]
...}

There is an assumption that there is each resource has a unique role. If this is not the case (ie, if there are multiple resources with the role '*' a warning is emitted. The solution for this is to correctly handle merging of resources with the same role.


Diffs
-----

  src/master/http.cpp 966eed6d8340038265ef799f1b6149502ccc606e 
  src/slave/http.cpp c4f598faf6807214608cc89a6d9cf665133f95f3 

Diff: https://reviews.apache.org/r/17976/diff/


Testing
-------

make check


Thanks,

Dominic Hamon