Closed mortya closed 5 years ago
@shishir-a412ed how would you prefer it implemented? Extract information from lvm dynamically or store it in json along with other metadata? I'd submit a PR as we need this implemented.
@shishir-a412ed given the codebase I assumed that extracting creation date from lvdisplay
is preferred approach (as it's backward compatible to to no modifications to persisted metadata file) and submitted a pull request.
Please let me know what do you think of it. I did tested it locally:
$ docker volume create -d lvm --opt size=0.2G --name foobar
$ lvdisplay vg1/foobar
--- Logical volume ---
LV Path /dev/vg1/foobar
LV Name foobar
VG Name vg1
LV UUID HjGYNd-hfyz-fgAi-sMG6-fefY-80Yp-Pma39Y
LV Write Access read/write
LV Creation host, time localhost, 2018-11-18 14:39:40 +1300
LV Status available
# open 0
LV Size 208.00 MiB
Current LE 52
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:7
$ docker volume inspect foobar
[
{
"CreatedAt": "2018-11-18T01:39:40Z",
"Driver": "lvm",
"Labels": null,
"Mountpoint": "/var/lib/docker-lvm-plugin/foobar",
"Name": "foobar",
"Options": null,
"Scope": "local"
}
]
@Ashald Thanks for opening up the PR !
@mortya is right, Fix for #55 (https://github.com/docker/go-plugins-helpers/pull/107) is only suppressing the warning, and not populating CreatedAt
which he would need for his docker prune
usecase.
I am a bit occupied right now, and will try to review it as soon as possible.
Extract information from lvm dynamically or store it in json along with other metadata?
Extracting the date/time from lvdisplay
output should be the correct approach, which is what I believe you are doing.
Fixed via #67 and #68 Closing this now.
I have docker local volumes and lvm volumes. The local volumes set CreatedAt correctly. The lvm volumes don't.
This problem is referenced in #55 . But the focus there seems to be shutting up the warning about this rather than getting a valid value. If I'm misunderstanding and this is a duplicate, my apologies.
The reason I care is that I'm trying to set up pruning for lvm volumes. The default volume prune seems to only work for local volumes. One approach would be to delete all volumes, and rely on the fact that used volumes can't be deleted. But that opens up to a race condition, where a volume is created, the pruning code runs, and then the (no longer existing) volume is referenced. So the new approach is to list all volumes, check for CreatedAt being at least N minutes old, and then try deleting. But that only works if CreatedAt is valid. Which it does not appear to be.