----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/50841/#review152277 -----------------------------------------------------------
src/slave/containerizer/docker.cpp (lines 643 - 696) <https://reviews.apache.org/r/50841/#comment221241> I was thinking for how to make less code change but need to make sure build passed on mac. How about the following? ``` Future<Nothing> DockerContainerizerProcess::allocateNvidiaGpus( const size_t count, const ContainerID& containerId) { #ifdef __linux__ if (!nvidiaGpuAllocator.isSome()) { return Failure("The 'allocateNvidiaGpus' function was called" " without an 'NvidiaGpuAllocator' set"); } if (!containers_.contains(containerId)) { return Failure("Container is already destroyed"); } return nvidiaGpuAllocator->allocate(count) .then(defer( self(), &Self::_allocateNvidiaGpus, lambda::_1, containerId)); #else return Nothing(); #endif } Future<Nothing> DockerContainerizerProcess::_allocateNvidiaGpus( const set<Gpu>& allocated, const ContainerID& containerId) { #ifdef __linux__ if (!containers_.contains(containerId)) { return nvidiaGpuAllocator->deallocate(allocated) .onFailed([](const string& message) { return Failure("Failed to deallocate GPUs allocated" " to destroyed container: " + message); }); } containers_.at(containerId)->gpus = allocated; #endif return Nothing(); } Future<Nothing> DockerContainerizerProcess::deallocateNvidiaGpus( const ContainerID& containerId) { #ifdef __linux__ if (!nvidiaGpuAllocator.isSome()) { return Failure("The 'deallocateNvidiaGpus' function was called" " without an 'NvidiaGpuAllocator' set"); } return nvidiaGpuAllocator->deallocate(containers_.at(containerId)->gpus) .then(defer( self(), &Self::_deallocateNvidiaGpus, containerId)); #else return Nothing(); #endif } ``` Then we need to update the comments of `allocateNvidiaGpus` and `deallocateNvidiaGpus` by identifying that those two APIs return Nothing if GPU is not enabled. - Guangya Liu On 十月 11, 2016, 8:16 a.m., Yubo Li wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/50841/ > ----------------------------------------------------------- > > (Updated 十月 11, 2016, 8:16 a.m.) > > > Review request for mesos, Benjamin Mahler, Guangya Liu, Kevin Klues, and > Rajat Phull. > > > Bugs: MESOS-5795 > https://issues.apache.org/jira/browse/MESOS-5795 > > > Repository: mesos > > > Description > ------- > > Added control logic to allocate/deallocate GPUs to GPU-related task > when the task is started/terminated. > > > Diffs > ----- > > src/slave/containerizer/docker.hpp 8da63101f951892e673612134770fc155d86112d > src/slave/containerizer/docker.cpp 1d27761fcb3f310cf954d45ed41f4c89ecbd5982 > > Diff: https://reviews.apache.org/r/50841/diff/ > > > Testing > ------- > > make check > > > Thanks, > > Yubo Li > >
