> On 十一月 25, 2016, 3:20 a.m., Guangya Liu wrote:
> > src/common/roles.cpp, lines 110-130
> > <https://reviews.apache.org/r/54062/diff/1/?file=1570158#file1570158line110>
> >
> >     Can we simplify the logic as your diagram above:
> >     
> >     ```
> >     if (frameworkInfo.roles_size() > 0 &&
> >         frameworkInfo.has_role()) {
> >         
> >     }
> >     
> >     if (frameworkHasCapability(
> >             frameworkInfo,
> >             FrameworkInfo::Capability::MULTI_ROLE)) {
> >       if (frameworkInfo.roles_size() == 0 &&
> >           frameworkInfo.has_role()) {
> >           
> >       }
> >     } else {
> >       if (frameworkInfo.roles_size() > 0 &&
> >           !frameworkInfo.has_role()) {
> >           
> >       }
> >     }
> >     ```
> 
> Jay Guo wrote:
>     I don't see this simplifies the logic, since inevitably we need to have 
> three error cases. And since the diagram describes the results in 2 
> categories, w/o MULTI_ROLE, I think current implementation may reflect that 
> pattern better, what do you think?

I want to use less nested `if-else`. ;)

```
  } else {
    if (frameworkInfo.roles_size()) {
      if (frameworkInfo.has_role()) {
        return Error("Only one of FrameworkInfo.role and FrameworkInfo.roles "
                     "must be set at a time.");
      } else {
        return Error("If FrameworkInfo.roles is set, then the MULTI_ROLE "
                     "framework capability must be provided.");
      }
    }   
  }

```


> On 十一月 25, 2016, 3:20 a.m., Guangya Liu wrote:
> > src/common/roles.cpp, line 138
> > <https://reviews.apache.org/r/54062/diff/1/?file=1570158#file1570158line138>
> >
> >     I think that you do not need this as there is no need to persist roles 
> > in this validation.
> 
> Jay Guo wrote:
>     This is used to check duplicate entries in roles. I added some comments 
> in the revision.

I see, we need check here.


- Guangya


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


On 十一月 25, 2016, 6:45 a.m., Jay Guo wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/54062/
> -----------------------------------------------------------
> 
> (Updated 十一月 25, 2016, 6:45 a.m.)
> 
> 
> Review request for mesos, Guangya Liu and Qiang Zhang.
> 
> 
> Bugs: MESOS-6629
>     https://issues.apache.org/jira/browse/MESOS-6629
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> We need to do necessary validation for the conflicts of role, roles
> and MULTI_ROLE capability. It complies with following matrix:
> 
> -- MULTI_ROLE is NOT set -
>         |-------|---------|
>         |Roles  |No Roles |
> |-------|-------|---------|
> |Role   | Error |  None   |
> |-------|-------|---------|
> |No Role| Error |  None   |
> |-------|-------|---------|
> 
> --- MULTI_ROLE is set ----
>         |-------|---------|
>         |Roles  |No Roles |
> |-------|-------|---------|
> |Role   | Error |  Error  |
> |-------|-------|---------|
> |No Role| None  |  None   |
> |-------|-------|---------|
> 
> Two test cases are added, one is for validateRoles method and another
> ensures that the master rejects subscription when provided invalid
> roles.
> 
> 
> Diffs
> -----
> 
>   src/master/master.cpp e03a2e8025943825a2902102c43dc0eb66bacb6a 
>   src/master/validation.hpp b8389460f34b3531f2b6ff93f18f496c01e1a079 
>   src/master/validation.cpp 42d9b4a8784c2a161b74d7b46619cc22272e14e3 
>   src/tests/master_validation_tests.cpp 
> f893067859425967654401f3226149268b51cf57 
> 
> Diff: https://reviews.apache.org/r/54062/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Jay Guo
> 
>

Reply via email to