Skip to content

Unify windows snapshotters & add support to store scratch layers in different directory#27

Merged
ambarve merged 5 commits intokevpar:fork/masterfrom
ambarve:unify_snapshotters
Nov 22, 2021
Merged

Unify windows snapshotters & add support to store scratch layers in different directory#27
ambarve merged 5 commits intokevpar:fork/masterfrom
ambarve:unify_snapshotters

Conversation

@ambarve
Copy link
Copy Markdown
Collaborator

@ambarve ambarve commented Oct 18, 2021

Motivation:
In some cases it is desirable to store scratch VHDs of WCOW/LCOW containers on a different volume. Right now the scratch VHDs of containers and the image layers are all stored under the same directory (snapshots). If there are containers doing heavy IO to their scratch disks and containerd is also pulling and extracting several images at the same time then the disk on which all of these snapshots are stored starts hitting IO limits and these snapshot operations take long time than usual to complete.

Solution:
Current approach is to provide a config option to containerd that will specify path to a different directory (which can be on a different volume) on which all scratch snapshots should be stored. We achieve this by creating the directory for scratch snapshots under this new path but we create a symlink to this directory under the default snapshots directory.

Commit description:
The change mentioned above needed to be done for both WCOW and LCOW snapshotters and it seems that both WCOW and LCOW snapshotters have a lot of duplicated code. The first commit adds a new common base snapshotter for both WCOW & LCOW snapshotters.
Second commit actually adds the changes required for supporting storing snapshots in a different directory.

Both LCOW & WCOW snapshotters have many functions that are identical and some other
functions have common code. This change refactors those snapshotters to remove duplicate
code.
This refactor will also help when adding other features like storing scratch snapshots in a
different location.

Signed-off-by: Amit Barve <ambarve@microsoft.com>
Some containers do heavy IO to the scratch, in case of LCOW/WCOW the scratch itself is a
VHD that is stored on the same disk as that of other snapshots (including the image
layers). If containerd is pulling multiple images and one or more containers are doing
heavy IO to the scratch at the same time, that causes disk contention and related
issues. This changes allows the user to set a config (either in containerd.toml or in the
container configuration) that specifies another directory inside which the scratch of all
containers (or that specific container) should be stored.

Signed-off-by: Amit Barve <ambarve@microsoft.com>
@dcantah
Copy link
Copy Markdown
Collaborator

dcantah commented Oct 19, 2021

It'd be nice to have a PR description here (even if the commits go into detail)

Comment thread pkg/cri/config/config.go Outdated
Comment thread snapshots/windows/common.go Outdated
Comment thread snapshots/windows/lcow.go Outdated
Comment thread snapshots/snapshotter.go Outdated
Comment thread snapshots/windows/common.go Outdated
Comment thread snapshots/lcow/lcow.go
ic.Meta.Platforms = append(ic.Meta.Platforms, ocispec.Platform{
OS: "linux",
Architecture: "amd64",
Architecture: runtime.GOARCH,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any reason for this change?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think in upstream they changed this and when I was comparing the changes with upstream I must have copied that. I can change it back.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This commit: containerd@bb8aac3

Signed-off-by: Amit Barve <ambarve@microsoft.com>
@ambarve
Copy link
Copy Markdown
Collaborator Author

ambarve commented Nov 1, 2021

@dcantah / @msscotb PTAL.

Comment thread snapshots/windows/common.go
@ambarve ambarve assigned anmaxvl and unassigned kevpar Nov 10, 2021
@helsaawy helsaawy self-requested a review November 10, 2021 20:32
Comment thread snapshots/windows/common.go Outdated
Comment thread snapshots/windows/lcow.go
Comment thread snapshots/windows/common.go Outdated
Comment thread snapshots/windows/common.go Outdated
Comment thread snapshots/windows/lcow.go Outdated
Comment thread snapshots/wcow/wcow.go
Comment thread snapshots/windows/lcow.go Outdated
Signed-off-by: Amit Barve <ambarve@microsoft.com>
Signed-off-by: Amit Barve <ambarve@microsoft.com>
@helsaawy
Copy link
Copy Markdown
Collaborator

lgtm

Copy link
Copy Markdown
Collaborator

@dcantah dcantah left a comment

Choose a reason for hiding this comment

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

lgtm

@ambarve ambarve merged commit 333a72b into kevpar:fork/master Nov 22, 2021
ambarve added a commit that referenced this pull request Jan 25, 2022
…ifferent directory (#27) (#30)

* Refactor windows snapshotters

Both LCOW & WCOW snapshotters have many functions that are identical and some other
functions have common code. This change refactors those snapshotters to remove duplicate
code.
This refactor will also help when adding other features like storing scratch snapshots in a
different location.

* Support to override scratch snapshot location

Some containers do heavy IO to the scratch, in case of LCOW/WCOW the scratch itself is a
VHD that is stored on the same disk as that of other snapshots (including the image
layers). If containerd is pulling multiple images and one or more containers are doing
heavy IO to the scratch at the same time, that causes disk contention and related
issues. This change allows the user to set a config (either in containerd.toml or in the
container configuration) that specifies another directory inside which the scratch of all
containers (or that specific container) should be stored.

Signed-off-by: Amit Barve <ambarve@microsoft.com>
(cherry picked from commit 333a72b)
Signed-off-by: Amit Barve <ambarve@microsoft.com>
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