Skip to content
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

pkg/archive: ignore mtime changes on directories #11422

Merged
merged 1 commit into from
Mar 23, 2015

Conversation

vbatts
Copy link
Contributor

@vbatts vbatts commented Mar 16, 2015

on overlay fs, the mtime of directories changes in a container where new
files are added in an upper layer (e.g. '/etc'). This flags the
directory as a change where there was none.

Related #9874

Ping @jfrazelle

Signed-off-by: Vincent Batts vbatts@redhat.com

@jessfraz
Copy link
Contributor

omg cool!!!!

@LK4D4
Copy link
Contributor

LK4D4 commented Mar 16, 2015

That condition looks awful :E

@vbatts
Copy link
Contributor Author

vbatts commented Mar 16, 2015

@LK4D4 so it goes

@jessfraz
Copy link
Contributor

imma try it on overlay

@vbatts
Copy link
Contributor Author

vbatts commented Mar 16, 2015

this fixes TestDiffEnsureOnlyKmsgAndPtmx and TestSaveDirectoryPermissions for me

@vbatts
Copy link
Contributor Author

vbatts commented Mar 16, 2015

/me looking

@vbatts
Copy link
Contributor Author

vbatts commented Mar 16, 2015

ah, TestChangesDirsMutated

@@ -221,7 +221,7 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
oldStat.Rdev() != newStat.Rdev() ||
// Don't look at size for dirs, its not a good measure of change
(oldStat.Size() != newStat.Size() && oldStat.Mode()&syscall.S_IFDIR != syscall.S_IFDIR) ||
!sameFsTimeSpec(oldStat.Mtim(), newStat.Mtim()) ||
(!sameFsTimeSpec(oldStat.Mtim(), newStat.Mtim()) && oldStat.Mode()&syscall.S_IFDIR != syscall.S_IFDIR) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rewrite it pls?
Like

oldStat.Mode()&syscall.S_IFDIR != 0 &&
    (
        oldStat.Size() != newStat.Size() || 
        !sameFsTimeSpec(oldStat.Mtim(), newStat.Mtim())
    )

@vbatts vbatts force-pushed the vbatts-overlay_dir_mtime_changes branch from 52d30b3 to 3c96c65 Compare March 16, 2015 20:48
@jessfraz
Copy link
Contributor

yayyy this fixed integration tests :D

@vbatts vbatts force-pushed the vbatts-overlay_dir_mtime_changes branch from 3c96c65 to 7e23793 Compare March 16, 2015 20:54
@vbatts
Copy link
Contributor Author

vbatts commented Mar 16, 2015

@LK4D4 updated PTAL

@@ -220,8 +220,8 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
oldStat.Gid() != newStat.Gid() ||
oldStat.Rdev() != newStat.Rdev() ||
// Don't look at size for dirs, its not a good measure of change
(oldStat.Size() != newStat.Size() && oldStat.Mode()&syscall.S_IFDIR != syscall.S_IFDIR) ||
!sameFsTimeSpec(oldStat.Mtim(), newStat.Mtim()) ||
(oldStat.Mode()&syscall.S_IFDIR != syscall.S_IFDIR &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we comparing not with 0? Everywhere in other code we comparing with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, because the line above wasnt comparing to zero... :-)
On Mar 16, 2015 4:55 PM, "Alexander Morozov" notifications@github.com
wrote:

In pkg/archive/changes.go
#11422 (comment):

@@ -220,8 +220,8 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
oldStat.Gid() != newStat.Gid() ||
oldStat.Rdev() != newStat.Rdev() ||
// Don't look at size for dirs, its not a good measure of change

  •           (oldStat.Size() != newStat.Size() && oldStat.Mode()&syscall.S_IFDIR != syscall.S_IFDIR) ||
    
  •           !sameFsTimeSpec(oldStat.Mtim(), newStat.Mtim()) ||
    
  •           (oldStat.Mode()&syscall.S_IFDIR != syscall.S_IFDIR &&
    

Why we comparing not with 0? Everywhere in other code we comparing with
it.


Reply to this email directly or view it on GitHub
https://github.com/docker/docker/pull/11422/files#r26526731.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look, your tests already failing because of this!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh?
On Mar 16, 2015 5:04 PM, "Alexander Morozov" notifications@github.com
wrote:

In pkg/archive/changes.go
#11422 (comment):

@@ -220,8 +220,8 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
oldStat.Gid() != newStat.Gid() ||
oldStat.Rdev() != newStat.Rdev() ||
// Don't look at size for dirs, its not a good measure of change

  •           (oldStat.Size() != newStat.Size() && oldStat.Mode()&syscall.S_IFDIR != syscall.S_IFDIR) ||
    
  •           !sameFsTimeSpec(oldStat.Mtim(), newStat.Mtim()) ||
    
  •           (oldStat.Mode()&syscall.S_IFDIR != syscall.S_IFDIR &&
    

Look, your tests already failing because of this!


Reply to this email directly or view it on GitHub
https://github.com/docker/docker/pull/11422/files#r26527502.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was joke :) But I still don't like it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-) well the parens weren't accepted on new lines, and splitting the next seemed even more confusing

@jessfraz
Copy link
Contributor

you can change to closes #9874 so it actually closes it too :D

@unclejack
Copy link
Contributor

This change needs to be checked with push and import on other graph drivers like aufs. We had some problems a while ago and I'm not sure this won't cause problems there again.

@jessfraz
Copy link
Contributor

hmmm good call i can run it across the matrix

@jessfraz jessfraz added this to the 1.6.0 milestone Mar 16, 2015
@jessfraz
Copy link
Contributor

seems not to fail on aufs or btrfs for me

@jessfraz
Copy link
Contributor

LGTM but @unclejack is the archive master here :)

@unclejack
Copy link
Contributor

I can confirm that the test for the previously fixed issue with permissions is still there and it's still passing.

I'll test this on all graph drivers and comment again to confirm it's OK for the merge as far as I'm concerned.

@jfrazelle Thank you!

on overlay fs, the mtime of directories changes in a container where new
files are added in an upper layer (e.g. '/etc'). This flags the
directory as a change where there was none.

Closes moby#9874

Signed-off-by: Vincent Batts <vbatts@redhat.com>
@vbatts vbatts force-pushed the vbatts-overlay_dir_mtime_changes branch from 7e23793 to 2ce37f6 Compare March 17, 2015 14:53
@vbatts
Copy link
Contributor Author

vbatts commented Mar 17, 2015

also, i just updated the commit message to "closes ..", instead of "related ..."

@vbatts
Copy link
Contributor Author

vbatts commented Mar 20, 2015

@unclejack results?

On Tue, Mar 17, 2015 at 8:49 AM, unclejack notifications@github.com wrote:

I can confirm that the test for the previously fixed issue with
permissions is still there and it's still passing.

I'll test this on all graph drivers and comment again to confirm it's OK
for the merge as far as I'm concerned.

@jfrazelle https://github.com/jfrazelle Thank you!


Reply to this email directly or view it on GitHub
#11422 (comment).

@jessfraz
Copy link
Contributor

I think we should get this in for 1.6

@jessfraz jessfraz modified the milestones: 1.7.0, 1.6.0 Mar 23, 2015
@unclejack
Copy link
Contributor

Overlay is working properly now. Thanks, @vbatts!

LGTM

jessfraz pushed a commit that referenced this pull request Mar 23, 2015
pkg/archive: ignore mtime changes on directories
@jessfraz jessfraz merged commit 9d00d81 into moby:master Mar 23, 2015
@thaJeztah
Copy link
Member

@jfrazelle I see this is merged now, should the milestone be moved back to 1.6?

@jessfraz jessfraz modified the milestones: 1.6.0, 1.7.0 Mar 23, 2015
@jessfraz
Copy link
Contributor

move it thanks @thaJeztah

@vbatts vbatts deleted the vbatts-overlay_dir_mtime_changes branch April 27, 2016 18:03
lowenna pushed a commit to microsoft/docker that referenced this pull request Oct 8, 2018
Signed-off-by: John Howard <jhoward@microsoft.com>

If fixes an error in sameFsTime which was using `==` to compare two times. The correct way is to use go's built-in timea.Equals(timeb).

In changes_windows, it uses sameFsTime to compare mTim of a `system.StatT` to allow TestChangesDirsMutated to operate correctly now.

Note there is slight different between the Linux and Windows implementations of detecting changes. Due to moby#9874,
and the fix at moby#11422, Linux does not consider a change to the directory time as a change. Windows on NTFS
does. See moby#37982 for more information. The result in `TestChangesDirsMutated`, `dir3` is NOT considered a change
in Linux, but IS considered a change on Windows. The test mutates dir3 to have a mtime of +1 second.

With a handful of tests still outstanding, this change ports most of the unit tests under pkg/archive to Windows.

It provides an implementation of `copyDir` in tests for Windows. To make a copy similar to Linux's `cp -a` while preserving timestamps
and links to both valid and invalid targets, xcopy isn't sufficient. So I used robocopy, but had to circumvent certain exit codes that
robocopy exits with which are warnings. Link to article describing this is in the code.
lowenna pushed a commit to microsoft/docker that referenced this pull request Nov 26, 2018
Signed-off-by: John Howard <jhoward@microsoft.com>

If fixes an error in sameFsTime which was using `==` to compare two times. The correct way is to use go's built-in timea.Equals(timeb).

In changes_windows, it uses sameFsTime to compare mTim of a `system.StatT` to allow TestChangesDirsMutated to operate correctly now.

Note there is slight different between the Linux and Windows implementations of detecting changes. Due to moby#9874,
and the fix at moby#11422, Linux does not consider a change to the directory time as a change. Windows on NTFS
does. See moby#37982 for more information. The result in `TestChangesDirsMutated`, `dir3` is NOT considered a change
in Linux, but IS considered a change on Windows. The test mutates dir3 to have a mtime of +1 second.

With a handful of tests still outstanding, this change ports most of the unit tests under pkg/archive to Windows.

It provides an implementation of `copyDir` in tests for Windows. To make a copy similar to Linux's `cp -a` while preserving timestamps
and links to both valid and invalid targets, xcopy isn't sufficient. So I used robocopy, but had to circumvent certain exit codes that
robocopy exits with which are warnings. Link to article describing this is in the code.
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request Nov 27, 2018
Signed-off-by: John Howard <jhoward@microsoft.com>

If fixes an error in sameFsTime which was using `==` to compare two times. The correct way is to use go's built-in timea.Equals(timeb).

In changes_windows, it uses sameFsTime to compare mTim of a `system.StatT` to allow TestChangesDirsMutated to operate correctly now.

Note there is slight different between the Linux and Windows implementations of detecting changes. Due to moby/moby#9874,
and the fix at moby/moby#11422, Linux does not consider a change to the directory time as a change. Windows on NTFS
does. See moby/moby#37982 for more information. The result in `TestChangesDirsMutated`, `dir3` is NOT considered a change
in Linux, but IS considered a change on Windows. The test mutates dir3 to have a mtime of +1 second.

With a handful of tests still outstanding, this change ports most of the unit tests under pkg/archive to Windows.

It provides an implementation of `copyDir` in tests for Windows. To make a copy similar to Linux's `cp -a` while preserving timestamps
and links to both valid and invalid targets, xcopy isn't sufficient. So I used robocopy, but had to circumvent certain exit codes that
robocopy exits with which are warnings. Link to article describing this is in the code.
Upstream-commit: 56b732058e4d55aa5559996cce03fe11e6ff3baa
Component: engine
adhulipa pushed a commit to adhulipa/docker that referenced this pull request Apr 11, 2019
Signed-off-by: John Howard <jhoward@microsoft.com>

If fixes an error in sameFsTime which was using `==` to compare two times. The correct way is to use go's built-in timea.Equals(timeb).

In changes_windows, it uses sameFsTime to compare mTim of a `system.StatT` to allow TestChangesDirsMutated to operate correctly now.

Note there is slight different between the Linux and Windows implementations of detecting changes. Due to moby#9874,
and the fix at moby#11422, Linux does not consider a change to the directory time as a change. Windows on NTFS
does. See moby#37982 for more information. The result in `TestChangesDirsMutated`, `dir3` is NOT considered a change
in Linux, but IS considered a change on Windows. The test mutates dir3 to have a mtime of +1 second.

With a handful of tests still outstanding, this change ports most of the unit tests under pkg/archive to Windows.

It provides an implementation of `copyDir` in tests for Windows. To make a copy similar to Linux's `cp -a` while preserving timestamps
and links to both valid and invalid targets, xcopy isn't sufficient. So I used robocopy, but had to circumvent certain exit codes that
robocopy exits with which are warnings. Link to article describing this is in the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants