MountStubsCleaner: preserve timestamps#3149
Conversation
6abd4e1 to
3827376
Compare
3827376 to
7f5cfe4
Compare
7f5cfe4 to
6db57dc
Compare
|
Added windows version of |
6db57dc to
2128b62
Compare
Works for me (for now); perhaps would be good to also upstream it to |
tonistiigi
left a comment
There was a problem hiding this comment.
Not sure I understand this. Iiuc this PR resets the timestamp that was there before the removal of the directory but why didn't the dir timestamp also get updated when the file/dir was added in first place.
I would have expected that timestamp needs to be saved for each parent path when this function is called and then restored in the callback.
@AkihiroSuda Do you also want to take #2884 if you are going over these cases?
Because they are mounted, not added, IIUC |
|
The mountpoint is created before the mount can happen. I believe that is happening in runc. |
2128b62 to
78bb1fa
Compare
| os.Remove(p) | ||
| // Back up the timestamps of the dir for reproducible builds | ||
| // https://github.com/moby/buildkit/issues/3148 | ||
| dir := filepath.Dir(p) |
There was a problem hiding this comment.
What if the parent dir or the mount also did not exist?
There was a problem hiding this comment.
Covered in the test for tmp/foo2/bar
78bb1fa to
4eb66e4
Compare
| "/tmp/foo2", | ||
| "/tmp/foo2/bar", | ||
| }), | ||
| llb.AddMount("/tmp/foo", llb.Scratch(), llb.Tmpfs()), |
There was a problem hiding this comment.
Does this test still pass if you remove this mount?
There was a problem hiding this comment.
Fails 😞
client_test.go:8008:
Error Trace: client_test.go:8008
run.go:86
run.go:189 Error: Not equal: expected: 1234567890
actual : 1667970326
Test: TestIntegration/TestMountStubsTimestamp/worker=oci
Messages: tmp/
There was a problem hiding this comment.
I assume this has been fixed?
There was a problem hiding this comment.
Not really. Hard to cover all corner cases 😞 .
I guess it is ok to just support basic cases such as /etc for now.
There was a problem hiding this comment.
I think we should debug a bit what is happening in #3149 (review) . It shouldn't be that hard to figure out the multi-parent case if it is not working already. If the mountpoint doesn't exist, we should check if the parent exists as well.
There was a problem hiding this comment.
The test turned out to be wrong. Directory entries must have the '/' suffix in their names.
Will update the test.
03eeb56 to
27f95f3
Compare
| } | ||
| mustNotExist := map[string]struct{}{ | ||
| "var/foo": {}, // Created on mounting var/foo, and removed on unmounting it | ||
| "tmp/foo2": {}, // Created on mounting tmp/foo2/bar, and removed on unmounting it |
There was a problem hiding this comment.
I'm a bit confused about what actually removes this parent dir of the mount. The described behavior is correct but I can't find the code that actually does that.
There was a problem hiding this comment.
Me too, shall we remove this check?
There was a problem hiding this comment.
The test turned out to be wrong. Directory entries must have the '/' suffix in their names.
Will update the test.
Fix issue 3148 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
27f95f3 to
0b5a315
Compare
| "etc/": nil, // Parent of file mounts (etc/{resolv.conf, hosts}) | ||
| "var/": nil, // Parent of dir mount (var/foo/) | ||
| "tmp/": nil, // Grandparent of dir mount (tmp/foo2/bar/) | ||
| // No support for reproducing the timestamps of mount point directories such as var/foo/ and tmp/foo2/bar/, |
There was a problem hiding this comment.
Could you try fixing this? #3149 (comment) to check the parents makes sense? Otherwise, we at least need to track it as a separate bug(hopefully in the same milestone).
There was a problem hiding this comment.
I'm not sure how it would be possible.
Maybe, we would need to modify runc to mkdir the mountpoints with the specified SOURCE_DATE_EPOCH.
An alternative way would be to add a new differ opt (in a separate PR) to support if tm > SOURCE_DATE_EPOCH { tm = SOURCE_DATE_EPOCH } #3296
There was a problem hiding this comment.
Not sure I understand. Isn't it just that in
Line 32 in 09b4613
paths if it doesn't exist?
There was a problem hiding this comment.
The timestamp specified in RUN touch is lost when the executor container exits, so it seems hard to retain custom timestamps.
SOURCE_DATE_EPOCH support for mount point dirs (and any arbitrary dirs/files) will be covered in
| if errors.Is(err, io.EOF) { | ||
| break | ||
| } | ||
| require.NoError(t, err) |
There was a problem hiding this comment.
Why did you remove the mustNotExist cases?
There was a problem hiding this comment.
The mustNotExist test was simply wrong.
// WRONG
mustNotExist := map[string]struct{}{
"var/foo": {}, // Created on mounting var/foo, and removed on unmounting it
"tmp/foo2": {}, // Created on mounting tmp/foo2/bar, and removed on unmounting it
}var/foo was a typo of var/foo/, and this mountpoint directory is not removed by BuildKit nor by runc.
Same applies to tmp/foo2 (tmp/foo2/)
tonistiigi
left a comment
There was a problem hiding this comment.
Lets make sure to recheck #3149 (comment) case before GA. Please create an issue for it in the milestone.
Opened an issue #3309 . |

Fix #3148