Skip to content

snapshots/overlay: add overlay cleanup#1833

Merged
stevvooe merged 2 commits intocontainerd:masterfrom
dmcgowan:snapshot-gc-3rd-phase
Mar 13, 2018
Merged

snapshots/overlay: add overlay cleanup#1833
stevvooe merged 2 commits intocontainerd:masterfrom
dmcgowan:snapshot-gc-3rd-phase

Conversation

@dmcgowan
Copy link
Copy Markdown
Member

@dmcgowan dmcgowan commented Nov 30, 2017

Updates overlay remove to simply remove the reference and adds a cleanup method for discarding the directory. Updates snapshot create to setup the directory structure while in the transaction to prevent cleanup from removing directories which are part of a create.

This effectively adds a 3rd phase to the garbage collection which completes all the on disk snapshot cleanup. During this disk cleanup the snapshotter will be unlocked to allow for the management of snapshots. The garbage collection scheduler will still wait for the completion of this 3rd phase, however it will not consider it when calculating pause time.

Added options to overlay snapshotter to allow configuring the asynchronous removal of keeping remove synchronous

@codecov-io
Copy link
Copy Markdown

codecov-io commented Nov 30, 2017

Codecov Report

Merging #1833 into master will decrease coverage by 0.12%.
The diff coverage is 36.63%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1833      +/-   ##
==========================================
- Coverage   45.37%   45.25%   -0.13%     
==========================================
  Files          96       96              
  Lines        9447     9511      +64     
==========================================
+ Hits         4287     4304      +17     
- Misses       4449     4491      +42     
- Partials      711      716       +5
Flag Coverage Δ
#linux 50.1% <38.14%> (-0.18%) ⬇️
#windows 40.2% <10%> (-0.09%) ⬇️
Impacted Files Coverage Δ
snapshots/storage/bolt.go 59.71% <0%> (-2.18%) ⬇️
metadata/snapshot.go 45.8% <40%> (-0.16%) ⬇️
snapshots/overlay/overlay.go 52.52% <43.2%> (-3.61%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba61af6...1fd2b57. Read the comment docs.

@dnephin
Copy link
Copy Markdown
Contributor

dnephin commented Nov 30, 2017

the API not having guaranteed behavior, in this case to use the overlay snapshotter directly, the snapshotter would have to be cast in order to actually remove disk content.

Is extending the API to include Cleanup() not an option?

@stevvooe stevvooe changed the title WIP: Add overlay cleanup [WIP] Add overlay cleanup Dec 1, 2017
@stevvooe stevvooe added this to the 1.0.1 milestone Dec 1, 2017
@stevvooe
Copy link
Copy Markdown
Member

stevvooe commented Jan 3, 2018

Moving this off of 1.0.1 as this seems like a larger change.

@stevvooe stevvooe modified the milestones: 1.0.1, 1.1 Jan 3, 2018
@dmcgowan dmcgowan force-pushed the snapshot-gc-3rd-phase branch from c36d3fd to 28de574 Compare January 6, 2018 01:06
Updates overlay remove to simply remove the reference, adds
a cleanup method for discarding the directory.
Updates snapshot create to setup the directory structure while
in the transaction, to prevent cleanup from removing directories
which are part of a create.

Signed-off-by: Derek McGowan <[email protected]>
@dmcgowan dmcgowan force-pushed the snapshot-gc-3rd-phase branch from 28de574 to de54478 Compare February 1, 2018 22:27
Allow configuring the overlay snapshotter to synchronously
or asynchronously do cleanup. When the driver is integrated
into a garbage collection system, the asynchronous cleanup
can reduce the time of removal and allow the longer disk
cleanup to be handled without locking the snapshotter.

Signed-off-by: Derek McGowan <[email protected]>
@dmcgowan dmcgowan force-pushed the snapshot-gc-3rd-phase branch from de54478 to 1fd2b57 Compare February 1, 2018 22:56
@dmcgowan dmcgowan changed the title [WIP] Add overlay cleanup snapshots/overlay: add overlay cleanup Feb 1, 2018
@dmcgowan
Copy link
Copy Markdown
Member Author

dmcgowan commented Feb 1, 2018

Remove WIP tag, added options to for configuring the snapshotter, but the registered plugin will use the asynchronous mode

return nil, err
}

defer t.Rollback()
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.

is this correct to always rollback?

Copy link
Copy Markdown
Member Author

@dmcgowan dmcgowan Feb 22, 2018

Choose a reason for hiding this comment

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

Yes, readonly transactions must always be rolled back.

In this case, even though the function is cleaning up, it is not making any alterations to the database, only to the disk. While the readonly transaction is open it figured out which directories must be removed, then after the transaction is done (rolled back in this case), it will perform the more expensive directory removals.

@crosbymichael
Copy link
Copy Markdown
Member

LGTM

@dmcgowan
Copy link
Copy Markdown
Member Author

Discussed the possibility with @tonistiigi of also running the cleanup in NewSnapshotter to handle cases where an unclean shutdown occurred which resulted in directory being created for a new id, but the transaction for that new id not being created. This is a classic two phase commit problem, here we could easily clean up on startup using the new function though. The problem with waiting for GC to do this is that GC may run after the API has become a available and failures may happen before then attempting to use the ID which failed creation.

@stevvooe
Copy link
Copy Markdown
Member

LGTM

@stevvooe stevvooe merged commit 220a479 into containerd:master Mar 13, 2018
@dmcgowan dmcgowan deleted the snapshot-gc-3rd-phase branch June 5, 2018 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants