CodeNow/khronos

Using both swarm and docker

Opened this issue · 1 comments

I'm looking into container.remove and container.delete tasks (https://github.com/CodeNow/khronos/blob/master/lib/tasks/containers/remove.js#L37).
They bot have following logic:

  1. Check if dock exists in Swarm
  2. Talk directly to docker daemon using dockerHost to perform operation.

I'm wondering if we can just talk to Swarm all the time and also skip dockExist check. In the current scenario we make 2 calls: 1 to swarm and 1 to docker daemon. In the new scenario we will have 1 call to swarm.

Benefits:

  1. Less calls (1 < 2)
  2. Jobs become more lightweight since they will not have job.dockerHost property
  3. Jobs can be reused by other systems. E.x. API would be able to enqueue a job for container removal/deletion without specifying dockerHost.

Context:

I'm thinking about removing this piece of code from API (https://github.com/CodeNow/api/blob/master/lib/workers/instance.container.delete.js#L68).
Theoretically API can either enqueue khronos.container.remove job or emit a new even that khronos can pick it up (I think I like second option better but open for your comments)

+1 for moving to swarm. Info is a much more heavy option then delete