> On Jan. 8, 2020, 5:43 a.m., Greg Mann wrote:
> > src/slave/slave.cpp
> > Lines 3623 (patched)
> > <https://reviews.apache.org/r/71858/diff/4/?file=2191535#file2191535line3628>
> >
> > Should this be an `Option`? So that we can only set
> > `containerConfig.limits` when limits have actually been set?
>
> Qian Zhang wrote:
> I added a check `if (!executorLimits.empty()) {` before setting
> `containerConfig.limit`, HDYT?
>
> Greg Mann wrote:
> If we use an option, then the type in the function signature more
> precisely expresses the semantics of the function, which improves readability
> IMO.
I actually thought about it before, but it may make the code a bit more
complicated. Here is the code where we call `launchExecutor()`:
```
defer(
self(),
&Self::launchExecutor,
lambda::_1,
frameworkId,
executorInfo_,
executorLimits,
taskGroup.isNone() ? task.get() : Option<TaskInfo>::none()));
```
The type of the variable `executorLimits` is `google::protobuf::Map` rather
than `Option<google::protobuf::Map>`. So if we change the type of the parameter
`executorLimits` of the `launchExecutor` method to
`Option<google::protobuf::Map>`, its `isSome()` will actually always be true
since a map `executorLimits` will always be passed to it, that means checking
`executorLimits.isSome()` in `launchExecutor` is actually redundant. To make it
not redundant, I may need to change the type of the variable `executorLimits`
from `google::protobuf::Map` to `Option<google::protobuf::Map>`in the caller's
code and define another local variable of type `google::protobuf::Map` and set
`executorLimits` to that variable when we need to set executor's resource
limits, I think it is bit more complicated than the current code in this patch.
Another option would be set the default value of the `executorLimits` parameter
to an empty map (i.e. `{}`), like:
```
const google::protobuf::Map<string, Value::Scalar>& executorLimits = {},
```
Does it help?
- Qian
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/71858/#review219154
-----------------------------------------------------------
On Jan. 8, 2020, 10:40 a.m., Qian Zhang wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/71858/
> -----------------------------------------------------------
>
> (Updated Jan. 8, 2020, 10:40 a.m.)
>
>
> Review request for mesos, Andrei Budnik and Greg Mann.
>
>
> Bugs: MESOS-10046
> https://issues.apache.org/jira/browse/MESOS-10046
>
>
> Repository: mesos
>
>
> Description
> -------
>
> WIP: Set resource limits when launching executor container.
>
>
> Diffs
> -----
>
> src/slave/slave.hpp 77b5bc0082c6bb73fbd48a2ebe812629921645cb
> src/slave/slave.cpp 3839a120446339fea8aa857f431a2dba28ed4002
>
>
> Diff: https://reviews.apache.org/r/71858/diff/6/
>
>
> Testing
> -------
>
>
> Thanks,
>
> Qian Zhang
>
>