crete-dev icon indicating copy to clipboard operation
crete-dev copied to clipboard

Ensure vm-node to crete-run port file is not reused

Open moralismercatus opened this issue 8 years ago • 0 comments

Scenario:

  1. vm-node starts the VM image
  2. The VM silently fails
  3. vm-node writes the port to file that the VM is expected to use
  4. vm-node waits indefinitely for crete-run to connect (also a separate issue)
  5. vm-node is restarted manually
  6. crete-run reads the old port file when the VM starts before vm-node has written a new one

Solution:

A fix should be simple. Just ensure the port file is removed before the VM image is started. This could be done in VMNodeFSM's ctor (or equivalent). A more robust solution is to follow the core guidelines R.1.

The present implementation is lacking sufficient resource (i.e., the port file) management:

// ...write port_file...
server->open_connection_wait();
fs::remove(port_file_path);

Clearly, this is inadequate. If open_connection_wait() throws, or vm-node is terminated between these two invocations, fs::remove() is not invoked, thus causing the same problem.

moralismercatus avatar Dec 22 '16 21:12 moralismercatus