Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Add volumes cleanup - #142

Merged
davidxia merged 19 commits into
spotify:masterfrom
rccrdpccl:master
May 23, 2018
Merged

davidxia merged 19 commits into
spotify:masterfrom
rccrdpccl:master

Conversation

@rccrdpccl

Copy link
Copy Markdown
Contributor

Sorry if I did not ask about this feature before doing the PR, but we are using this feature to extend docker-gc so I had to write it anyway.

@imkin

imkin commented Dec 22, 2016 •

Copy link
Copy Markdown

Is there a timeline on which this would be merged and?

@rccrdpccl

Copy link
Copy Markdown
Contributor Author

@imkin This is integrated in my fork https://github.com/rccrdpccl/docker-gc/ , but there is no timeline to merge it in this repo

@sgerrand sgerrand left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Some typos here and there, but the functionality is useful. We've got workarounds in place to do this on top of docker-gc. It'd be great to have this exist within the app itself.

Comment thread README.md Outdated
drunk_goodall
```

### Excluding Volumes From Gargbage Collection

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🙋 Typo: "Garbage Collection"

Comment thread README.md Outdated

### Excluding Volumes From Gargbage Collection

There can be occasions where you dont want to remove a dangling volume.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🙋 Typo: "don't"

Comment thread README.md Outdated
### Excluding Volumes From Gargbage Collection

There can be occasions where you dont want to remove a dangling volume.
In such case, you can create `/etc/docker-gc-exclude-volumes` (or specify

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"To enable this functionality you can create a file named /etc/docker-gc-exclude-volumes"

@rccrdpccl

Copy link
Copy Markdown
Contributor Author

@sgerrand Thanks for the feedback, I have fixed the typos now!

@vdice

vdice commented May 25, 2017

Copy link
Copy Markdown

Hoping to add support for this feature in the official spotify/docker-gc binary/docker image. Anything stopping getting this in?

Comment thread docker-gc
fi
else
if [[ -z "$VOLUME_DELETE_ONLY_DRIVER" ]]; then
$DOCKER volume ls --filter "dangling=true" -q | grep -v -f $EXCLUDE_VOLUMES_IDS_FILE > volumes.reap

@vdice vdice May 25, 2017 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

My only suggestion would be to either check to make sure $EXCLUDE_VOLUMES_IDS_FILE exists (if not, don't bother grepping) or follow the examples set previously with the image/container excludes logic where if file doesn't exist, filepath just set to /dev/null. (See here)

That way, we can maintain tradition of opting in for volume removal but not having to supply an exclusion file (in such case, we'd assume all unused/dangling volumes are intended to be removed.)

Otherwise, definitely excited for this addition! (Have been testing locally w/ forked ricc/docker-gc image...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, I've gone for setting filepath to /dev/null. Please let me know if I can improve it further!

@vdice vdice May 31, 2017 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great, thanks @rccrdpccl. LGTM -- that was my one suggested change. Now let's get this in! ping @sgerrand

@mattnworb mattnworb 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.

looks good to me overall, and thanks for the contribution. I just have two questions below:

Comment thread docker-gc
set +e
$DOCKER volume ls --filter "dangling=true" -q &> /dev/null
VOLUMES=$?
set -e

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.

just curious - why do you need to set and unset e here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here we use set and unset e because docker volume was added in docker 1.9, so I wanted the program to stop and fail. (if I recall correctly this project used to use an older version at the time I have started with this feature). It might be not necessary now, as the image of docker-gc is currently build on a newer version....

Comment thread docker-gc Outdated
EXCLUDE_DEAD=${EXCLUDE_DEAD:=0}
REMOVE_VOLUMES=${REMOVE_VOLUMES:=0}
EXCLUDE_VOLUMES_IDS_FILE=${EXCLUDE_VOLUMES_IDS_FILE:=/etc/docker-gc-exclude-volumes}
VOLUME_DELETE_ONLY_DRIVER=${VOLUME_DELETE_ONLY_DRIVER:=locale}

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.

why does this default to locale?

@rccrdpccl rccrdpccl May 31, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, good question: it should be local. This was a pretty nasty bug too, because if you would not specify any value for VOLUME_DETE_ONLY_DRIVER it would not actually remove any volume... It is now fixed.

@mvisonneau

Copy link
Copy Markdown

any other reason not to merge this one ?

@paulRbr

paulRbr commented Sep 15, 2017

Copy link
Copy Markdown

The changes on this MR looks good to me. Would me great to have a maintainer taking a look at it :)

@paulRbr

paulRbr commented Sep 15, 2017

Copy link
Copy Markdown

@rccrdpccl could you squash your commits in understandable unit of work please?

@rccrdpccl

Copy link
Copy Markdown
Contributor Author

@paulRbr I agree with you that messages should have been cleaned up, however this is not my private tree anymore. I would rather squash it on merge: although there are a few messages, I think this feature is small enough to be collapsed to one single commit. What do you think?

@paulRbr

paulRbr commented Sep 18, 2017

Copy link
Copy Markdown

@rccrdpccl yes one single commit seems reasonable 👍

@Constantin07

Copy link
Copy Markdown

when this PR will be merged ?

@lainekendall

Copy link
Copy Markdown

is there an update on the status of this? would like to see it!

@davidxia
davidxia merged commit 7ce3b44 into spotify:master May 23, 2018
@davidxia

Copy link
Copy Markdown
Contributor

Thanks, @rccrdpccl. Sorry for the delay.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.