kinvolk/kube-spawn

Check for source file of bind-mount in pkg/nspawntool

Closed this issue · 0 comments

Currently the general structure of pkg/nspawntool has rooms for improvement. One of the main issues is that there's no general way of checking if a certain source mount directory exists. If any source mount file does not exist, systemd-nspawn called with e.g. --bind=INVALID_SRC_FILE will fail silently without any decent error message. That sometimes makes debugging a lot harder than expected. It's also a good source of potential bugs, as any source file could be invalid in the future at any time.

To improve that, we should improve the structure of pkg/nspawntool:

  • Define a list of pre-defined structure to include --bind=, source file, and destination file.
  • Convert each entry of the list into a list of string that can be directly passed to systemd-nspawn.
    • During the conversion, if any source directory doesn't exist, error out immediately.