> On 七月 27, 2016, 2:15 a.m., Guangya Liu wrote:
> > src/slave/containerizer/docker.cpp, line 1333
> > <https://reviews.apache.org/r/50123/diff/1/?file=1445669#file1445669line1333>
> >
> >     1) s/allocator.get().allocate(requested)/allocator->allocate(requested)
> >     
> >     2) I think it is not right to use `Option` here as the 
> > `allocator->allocate(requested)` is returning a `Future`.
> >     
> >     One proposal is as following:
> >     ```
> >     allocator->allocate(requested)
> >       .then(defer(...));
> >     ```
> >     
> >     You can also refer to 
> > https://github.com/apache/mesos/blob/master/src/slave/containerizer/mesos/isolators/gpu/isolator.cpp#L356
> >  to get some detail.
> 
> Yubo Li wrote:
>     `Future.get()` will block the host threading and wait for the 
> sub-threading return its value. For docker containerizer, we need to wait  
> `Option<set<Gpu>> allocated` return, and pass it to mesos-docker-executor, 
> it's hard to follow the async calling style. For mesos containerizer, it uses 
> cgroup to set device control directly, so the async call is fine.

Since here we must block the host threading to get GPU allocated results, The 
logic fixed as:
+  if (requested > 0) {
+    // Some GPUs requested.
+    Future<set<Gpu>> future = allocator->allocate(requested);
+
+    // We block the code until the GPU allocation finished.
+    // For docker containerizer, we must wait for GPUs allocated
+    // completed, and pass allocated GPUs to mesos-docker-executor.
+    future.await();
+    if (!future.isReady()) {
+      return Failure("GPU allocator allocating GPU failed");
+    }
+
+    set<Gpu> allocated = future.get();
+
+    foreach (const Gpu& gpu, allocated) {
+      container->gpuAllocated.push_back(gpu);
+    }
The logic should be safe because I refer to: 
https://github.com/liyubobj/mesos/blob/master/src/slave/containerizer/fetcher.cpp#L326


- Yubo


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


On 七月 18, 2016, 9:17 a.m., Yubo Li wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/50123/
> -----------------------------------------------------------
> 
> (Updated 七月 18, 2016, 9:17 a.m.)
> 
> 
> Review request for mesos, Benjamin Mahler, Kevin Klues, and Rajat Phull.
> 
> 
> Bugs: MESOS-5795
>     https://issues.apache.org/jira/browse/MESOS-5795
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This added 'NvidiaGpuAllocator' to docker containerizer so that the
> docker containerizer can use it to allocate GPUs to the task with 'gpus'
> resource. Also, allocated GPUs will automatically deallocated after the
> job destroyed.
> 
> 
> Diffs
> -----
> 
>   src/slave/containerizer/docker.hpp 43ca4317d608b3b43dd7bd0d1b55c721e7364885 
>   src/slave/containerizer/docker.cpp f1ecf3b25d85597f6c3dcaa47968860ed119dbd5 
> 
> Diff: https://reviews.apache.org/r/50123/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Yubo Li
> 
>

Reply via email to