Project

General

Profile

Idea #9623

Updated by Tom Clegg over 7 years ago

In ContainerRequest#resolve, before creating a new Container, find out whether a Container already exists with 
 * Exactly the same [command, cwd, environment, output_path, container_image, mounts, runtime_constraints] as the Container we're about to create 
 * state in [Queued, Locked, Running, Complete] 
 * (if state=Complete) exit_code==0 

 If multiple matching containers are found, take the first of: 
 * The most recent container with state=Complete 
 * A Running container (order by progress desc, started_at asc -- IOW, most likely to finish soonest) 
 * A Queued or Locked container (order by priority desc, created_at asc -- IOW, most likely to start soonest) 

 In order to efficiently compare equality of serialized fields like mounts, runtime_constraints, and environment, we must: 
 * Recursively sort hash keys before putting them in the database. This can be done in a Container before_save hook. 
 * Recursively sort hash keys before using them in a query like "where mounts=?". This must can be done during ContainerRequest#resolve. (The keys do not need to be sorted in the ContainerRequest's serialized attrs.) "find or create" process described here, which probably also belongs in the Container model. 

 For now, we will *not* implement: 
 * A mechanism allowing a client to skip re-use and force creation of a new container 

Back