Repository navigation
Fix nested client filesync incorrect deduplication - #7943
Conversation
Ah, I actually just remembered that there's a really big tradeoff with relying on hostnames (separate from ones I originally had in mind), which is that it results in CNI network namespaces not being re-usable, which adds likely meaningful performance overhead... I guess I will just go with the persistent host identifier approach after all. Also, on my first try here I did get a flake in the |
cc23177 to
049be82
Compare
This were hidden from the normal Debug log level during previous attempts to de-noise our logs, but in retrospect they aren't *that* noisy and are generally very useful for understanding when filesync and cache volume refs are being re-used vs. newly initialized. That in turn helps understand all sorts of performance-related behavior and is just generally useful for debugging. Signed-off-by: Erik Sipsma <[email protected]>
Including the caller client ID, the call itself and the nested client id for a given container execution can be extremely useful for following the progression of nested client/module execution in the logs. Signed-off-by: Erik Sipsma <[email protected]>
These logs only show up on ExtraDebug level but can still be useful when it's hard to get output from various internal processes (like codegen containers). Before this, nested clients were getting these logs cutoff early because the context was getting canceled after the first request that initializes the client ended. Now, the logs will continue printing until the session as a whole is cleaned up. Signed-off-by: Erik Sipsma <[email protected]>
922b875 to
f80f961
Compare
|
Currently letting |
|
Locally:
In CI:
So at least seems to have fixed the expected flake, though sad the others are still going to require their own investigation. Gonna keep looping in CI a bit more to be extra sure. |
a36aff7 to
9f35308
Compare
9f35308 to
515ec69
Compare
|
Had to do lots of re-runs after other unrelated flakes, but never saw |
jedevc
left a comment
There was a problem hiding this comment.
Aside from the note that this likely won't work on windows right now (haven't tested to be sure), this looks good to me 🎉
insane deep dive, nice job 🥳
| defer os.Remove(tmpFile.Name()) | ||
| defer tmpFile.Close() | ||
|
|
||
| if err := tmpFile.Chown(uid, gid); err != nil { |
There was a problem hiding this comment.
Hello, welcome to windows hell again 🎉 File.Chown always fails on Windows: https://pkg.go.dev/os#File.Chown 😱
There was a problem hiding this comment.
Oi, I had not encountered that "fun" fact previously, thanks for the pointer! I'll patch this up quick; I actually can drop the chown for now. It was added in an earlier iteration where I was trying to run this code in nested execs too (and thus needed to deal with different uid/gid), but I ended up backing out of that for simplicity.
As detailed in issue 7900, certain obscure corner cases can result in separate clients on separate hosts (or separate nested exec containers) from re-using each others' filesync cache refs unexpectedly and, if files happen to match metadata precisely, end up with incorrect file contents being used in the sync. The requirements for this to happen are as obscure as it gets, but it is impacting our CI and causing flakes, so needs a fix. It is *technically* possible for users to hit this too, so may as well solve it for them. Previously part of the cause here was that we used hostname as a semi-stable host identifier, but nested clients mostly have the same default container hostname. * There was much more to it than this, but this is the part we can address. The fix here replaces the hostname with an ID that is persisted in the client's XDG state dir (i.e. `~/.local/state/dagger/`). It's random when newly initialized but re-used after that. That solves this problem for non-nested clients. For nested clients, we just set this to a random ID in each exec for now. * It would also be possible to try to persist this in the nested exec, but it's not clear yet if that's worth the complication in that case, so keeping it simple for now. Signed-off-by: Erik Sipsma <[email protected]>
515ec69 to
baa0bed
Compare
As detailed in #7900, certain obscure corner cases can result in
separate clients on separate hosts (or separate nested exec containers)
from re-using each others' filesync cache refs unexpectedly and, if
files happen to match metadata precisely, end up with incorrect
file contents being used in the sync.
The requirements for this to happen are as obscure as it gets, but it is
impacting our CI and causing flakes, so needs a fix. It is technically
possible for users to hit this too, so may as well solve it for them.
Previously part of the cause here was that we used hostname as a
semi-stable host identifier, but nested clients mostly have the same
default container hostname.
address.
The fix here replaces the hostname with an ID that is persisted in the
client's XDG state dir (i.e.
~/.local/state/dagger/). It's random whennewly initialized but re-used after that.
That solves this problem for non-nested clients. For nested clients, we
just set this to a random ID in each exec for now.
but it's not clear yet if that's worth the complication in that case,
so keeping it simple for now.