-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDS filesystem watches operate on file parent rather than grandparent #13663
Comments
This is basically a dupe of #10979, except I claim the solution here is to watch grandparent, rather than document existing behavior. I think this should work for k8s. |
If /foo/bar/cert.pem # symlink to ..data/cert.pem
/foo/bar/..data # symlink to ..timestamp-1
/foo/bar/..timestamp-1/cert.pem # actual certificate file after symlink swap it would look like /foo/bar/cert.pem # symlink to ..data/cert.pem
/foo/bar/..data # symlink to ..timestamp-2 (updated)
/foo/bar/..timestamp-2/cert.pem # actual certificate file (updated) If watching grantparent |
In this case, I'd argue we should be watching |
We need to have a consistent directory-level symlink to follow to solve #13370 as well I think. |
Inotify watch will get deleted automatically when target gets deleted: (a) If watching (b) If watching and then further notifications are not received anymore. Case (a) is described in #9359 (comment) and (b) in #9359 (comment). |
In my example, the inotify watch is places on |
Sorry, I think I then missed what you meant. If I set inotify watch for file The current behavior is that when SDS config is as following: resources:
- "@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret"
validation_context:
trusted_ca:
filename: /foo/bar/cert.pem inotify is armed to watch all changes on directory |
I'm suggesting we:
|
I think that could work. Some further thoughts: (a) How to do this without breaking current users that rely on K8s Secret updates working with the normal path? (b) The ConfigSource doc says "Envoy will only watch the file path for moves". Should this also be changed to grandparent as well? This statement in the doc predated Envoy 1.14. It does not match runtime config description, but I thought this was intentional and it matched (by coincidence) with Kubernetes symlink implementation. ConfigSource filesystem subscription seemed to be implemented according to this doc, i.e. watching the parent, not grandparent:
(c) I doubt |
(a) this would be a config/runtime option |
There are a few limitations in our existing support for symlink-based key rotation: We don't atomically resolve symlinks, so a single snapshot might have inconsistent symlink resolutions for different watched files. Watches are on parent directories, e.g. for /foo/bar/baz on /foo/bar, which doesn't support common key rotation schemes were /foo/new/baz is rotated via a mv -Tf /foo/new /foo/bar. The solution is to provide a structured WatchedDirectory for Secrets to opt into when monitoring DataSources. SDS will used WatchedDirectory to setup the inotify watch instead of the DataSource path. On update, it will read key/cert twice, verifying file content hash consistency. Risk level: Low (opt-in feature) Testing: Unit and integration tests added. Fixes #13663 Fixes #10979 Fixes #13370 Signed-off-by: Harvey Tuch <[email protected]>
…3721) There are a few limitations in our existing support for symlink-based key rotation: We don't atomically resolve symlinks, so a single snapshot might have inconsistent symlink resolutions for different watched files. Watches are on parent directories, e.g. for /foo/bar/baz on /foo/bar, which doesn't support common key rotation schemes were /foo/new/baz is rotated via a mv -Tf /foo/new /foo/bar. The solution is to provide a structured WatchedDirectory for Secrets to opt into when monitoring DataSources. SDS will used WatchedDirectory to setup the inotify watch instead of the DataSource path. On update, it will read key/cert twice, verifying file content hash consistency. Risk level: Low (opt-in feature) Testing: Unit and integration tests added. Fixes envoyproxy#13663 Fixes envoyproxy#10979 Fixes envoyproxy#13370 Signed-off-by: Harvey Tuch <[email protected]> Signed-off-by: Qin Qin <[email protected]>
#10163 which resolved #9359 added support for inotify watching of directories to catch symlink rotation. I think this might have a bug. Specifically, if we have a cert in
/foo/bar/cert.pem
and perform a symlink rotation onbar
, we don't see any SDS filesystem action.The reason is that the watch is added on
bar
, rather thanfoo
, seeenvoy/source/common/secret/sds_api.cc
Line 68 in f95f539
@tsaarni can you confirm that this is an issue? I'm surprised it worked in your Contour example, but maybe some other feature was triggering the inotify, e.g. the file deletes?
I think the solution is to watch the grandparent, rather than the parent directory.
The text was updated successfully, but these errors were encountered: