Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix volume CreatedAt being altered on initialization#44719

Merged
thaJeztah merged 1 commit into
moby:mastermoby/moby:masterfrom
vvoland:fix-volume-createdatvvoland/moby:fix-volume-createdatCopy head branch name to clipboard
Jan 3, 2023
Merged

Fix volume CreatedAt being altered on initialization#44719
thaJeztah merged 1 commit into
moby:mastermoby/moby:masterfrom
vvoland:fix-volume-createdatvvoland/moby:fix-volume-createdatCopy head branch name to clipboard

Conversation

@vvoland

@vvoland vvoland commented Dec 30, 2022

Copy link
Copy Markdown
Contributor

The CreatedAt date was determined from the volume's _data directory (/var/lib/docker/volumes/<volumename>/_data). However, when initializing a volume, this directory is updated, causing the date to change.

Instead of using the _data directory, use its root directory, which is not updated afterwards, and should reflect the time that the volume was created.

This is basically the same as the original PR, but uses rootPath directly instead of manipulating the path.

- Description for the changelog
Volume's CreatedAt doesn't change when volume content is modified.

@vvoland
vvoland requested a review from cpuguy83 December 30, 2022 12:40
@vvoland

vvoland commented Dec 30, 2022

Copy link
Copy Markdown
Contributor Author

@cpuguy83 PTAL


func (v *localVolume) CreatedAt() (time.Time, error) {
fileInfo, err := os.Stat(v.path)
fileInfo, err := os.Stat(v.rootPath)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, interesting; not sure why I didn't pick rootPath at the time; perhaps I wasn't sure if "rootPath" could have a different meaning. 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OH! 😂 I added it; d393033 (#43632)

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! 🤗

Comment thread integration/volume/volume_test.go
The CreatedAt date was determined from the volume's `_data`
directory (`/var/lib/docker/volumes/<volumename>/_data`).
However, when initializing a volume, this directory is updated,
causing the date to change.

Instead of using the `_data` directory, use its parent directory,
which is not updated afterwards, and should reflect the time that
the volume was created.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland
vvoland force-pushed the fix-volume-createdat branch from 9c98d13 to 01fd23b Compare January 3, 2023 15:57
@thaJeztah
thaJeztah merged commit fcb5245 into moby:master Jan 3, 2023
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.

docker volume inspect : 'CreatedAt' Docker volume CreatedAt time is not really the date of creation

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.