hooks: Fix monitoring of multiple directories

This isn't an issue with podman, which will only ever use one
directory.  But CRI-O generally uses two directories, and we want to
make sure that changes to the fallback directory are not clobbering
hooks configured in the override directory.  More background in [1].

I've split the handling into a single-directory block and a
multiple-directory block so we don't waste time polling the filesystem
for single-directory removals.

I'm using the single-directory block for the the zero-directory case
as well.  Managers with zero directories should not be receiving
fsnotify events, so I don't think it really matters which block
handles them.  If we want to handle this case robustly (because we're
concerned about something in the hook package adjusted the private
.directories property on the fly?), then we'll probably want to add an
explicit zero-directory block in future work.

[1]: https://github.com/kubernetes-incubator/cri-o/pull/1470

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

Closes: #757
Approved by: rhatdan
This commit is contained in:
W. Trevor King
2018-05-11 12:08:06 -07:00
committed by Atomic Bot
parent 4704c138ae
commit c45d4c6d5c
3 changed files with 236 additions and 15 deletions

View File

@ -1,4 +1,4 @@
// Package hooks implements CRI-O's hook handling.
// Package hooks implements hook configuration and handling for CRI-O and libpod.
package hooks
import (