podman/libpod
W. Trevor King 4b22913e11 libpod: Add HooksDirNotExistFatal
And add an argument to WithHooksDir to set it.

If the hook dir doesn't exist, the new hooks package considers that a
fatal error.  When a podman caller sets
--hooks-dir-path=/some/typoed/directory, a fatal error is more helpful
than silently not loading any hooks.  However, callers who call podman
without setting --hooks-dir-path may not need hooks at all.  We don't
want to pester those callers with not-exist errors.  With this commit,
we:

* Assume the caller knows what they're doing if they set
  --hooks-dir-path and set HooksDirNotExistFatal.

* If the caller does not explicitly set --hooks-dir-path, assume they
  won't mind if the hook directory is missing and set
  HooksDirNotExistFatal false.

We also considered checking for the directory's existence in the code
calling WithHooksDir or from within WithHooksDir, but checks there
would race with the underlying ioutil.ReadDir in the hooks package.
By pushing the warn/error decision down into libpod's implementation,
we avoid a racy "do we expect this to work once libpod gets to it?"
pre-check.

I've also added a check to error if WithHooksDir is called with an
empty-string argument, because we haven't defined the semantics of
that (is it clearing a previous value?  Is it effectively the same as
the current directory?).  I agree with Matthew that a separate
WithNoHooks, or a *string argument to WithHooks, or some such would be
a better API for clearing previous values [1].  But for now, I'm just
erroring out to fail early for callers who might otherwise be
surprised that libpod ignores empty-string HooksDir.

[1]: https://github.com/projectatomic/libpod/pull/686#issuecomment-385119370

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #686
Approved by: mheon
2018-05-11 16:26:35 +00:00
..
common Change un/pwd handling to match Buildah's 2018-02-06 09:29:23 -05:00
driver Migrate Create|Commit to ginkgo 2018-02-02 22:44:40 +00:00
image podman push should honor registries.conf 2018-05-10 14:56:56 +00:00
layers Initial checkin from CRI-O repo 2017-11-01 11:24:59 -04:00
testdata Add hooks support to podman 2018-04-05 14:13:49 +00:00
boltdb_state.go Check for duplicate names when generating new container and pod names. 2018-03-29 01:55:20 +00:00
boltdb_state_internal.go Ensure container dependencies are part of the same pod 2018-03-29 01:27:40 +00:00
common_test.go Add tests for container graphs 2018-03-29 02:18:45 +00:00
container.go Place Conmon and Container in separate CGroups 2018-05-11 14:43:57 +00:00
container_api.go Optionally init() during container restart 2018-05-04 10:57:50 +00:00
container_attach.go Fix another comparison of a Go interface against nil 2018-04-13 18:43:44 +00:00
container_commit.go Make podman commit to localhost rather then docker.io 2018-05-03 13:12:46 +00:00
container_graph.go Remove a loop in container graph 2018-03-29 02:18:45 +00:00
container_graph_test.go Fix tests 2018-03-29 02:18:45 +00:00
container_inspect.go Retrieve IP addresses for container from DB 2018-04-26 17:26:13 +00:00
container_internal.go libpod: Add HooksDirNotExistFatal 2018-05-11 16:26:35 +00:00
container_top.go Major fixes to systemd cgroup handling 2018-05-11 14:43:57 +00:00
diff.go Stage 4 Image cleanup 2018-03-23 15:35:37 +00:00
errors.go Add schema validation to DB 2017-11-30 18:05:56 +00:00
finished_32.go Make libpod build on 32-bit systems 2018-02-13 15:39:07 +00:00
finished_64.go Make libpod build on 32-bit systems 2018-02-13 15:39:07 +00:00
in_memory_state.go Prevent ctrs not in pods from depending on pod ctrs 2018-03-29 01:27:40 +00:00
info.go Tweak info time format 2018-02-28 18:06:50 +00:00
networking.go networking, userNS: configure the network namespace after create 2018-05-04 17:15:55 +00:00
oci.go Place Conmon and Container in separate CGroups 2018-05-11 14:43:57 +00:00
options.go libpod: Add HooksDirNotExistFatal 2018-05-11 16:26:35 +00:00
pod.go Vendor in latest containers/image and contaners/storage 2018-04-19 14:08:47 +00:00
runtime.go libpod: Add HooksDirNotExistFatal 2018-05-11 16:26:35 +00:00
runtime_ctr.go Remove parent cgroup we create with cgroupfs 2018-05-11 14:43:57 +00:00
runtime_img.go Use buildah commit and bud in podman 2018-04-27 20:51:07 +00:00
runtime_img_test.go regression: tls verify should be set on registries.conf if insecure 2018-04-18 14:07:59 +00:00
runtime_pod.go Check for duplicate names when generating new container and pod names. 2018-03-29 01:55:20 +00:00
state.go Containers in a pod can only join namespaces in that pod 2018-02-12 14:28:07 +00:00
state_test.go Add backend code for generic dependencies 2018-04-03 14:57:16 +00:00
stats.go Major fixes to systemd cgroup handling 2018-05-11 14:43:57 +00:00
storage.go Begin wiring in USERNS Support into podman 2018-05-04 17:15:55 +00:00
util.go Stage 4 Image cleanup 2018-03-23 15:35:37 +00:00
util_test.go Stage3 Image Library 2018-03-14 20:21:31 +00:00
version.go varlink images 2018-04-26 19:14:44 +00:00