Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base layer manipulation #1637

Merged

Conversation

gabriel-samfira
Copy link
Contributor

This PR is just a rebase of #901

@TBBle is currently on sabbatical so I will try to move the two PRs (this one and the one on containerd), forward.

All needed context for this PR is available on #901

@gabriel-samfira gabriel-samfira force-pushed the base-layer-manipulation-rebased branch 2 times, most recently from 0f2ae9b to 417c365 Compare January 31, 2023 16:29
@helsaawy helsaawy self-assigned this Jan 31, 2023
func CreateWCOWBlankBaseLayer(ctx context.Context, t *testing.T) []string {
t.Helper()
tempDir := t.TempDir()
if err := wclayer.ConvertToBaseLayer(context.Background(), tempDir); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

wclayer.ConvertToBaseLayer(ctx tempDir)

TBBle and others added 7 commits February 2, 2023 05:38
This is the inverse of the baseLayerWriter: It walks Files/ and
UtilityVM/Files/ (if present) and ignores the rest of the layer data,
as it will be recreated when the layer is imported.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
This API allows turning any collection of files into a WCOW base layer.

It will create the necessary files in Files/ for
hcsshim.ProcessBaseLayer to function, validate the necessary files for
hcsshim.ProcessUtilityVMImage if UtilityVM/ exists, and then call those
two APIs to complete the process.

Calling this on a directory containing an untarred base layer OCI
tarball, gives a very similar outcome to passing the tar stream through
ociwclayer.ImportLayer.

The new API is used in `TestSCSIAddRemoveWCOW` to create nearly-empty
base layers for the scratch layers attached and removed from the utility
VM.

A wclayer command is also introduced: `makebaselayer` for testing and
validation purposes.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
This change adds functions to generate valid, empty hives.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
@gabriel-samfira gabriel-samfira marked this pull request as ready for review February 4, 2023 12:46
@gabriel-samfira gabriel-samfira requested a review from a team as a code owner February 4, 2023 12:46
internal/wclayer/baselayerreader.go Show resolved Hide resolved
internal/wclayer/baselayerreader.go Outdated Show resolved Hide resolved
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
internal/wclayer/baselayerreader.go Show resolved Hide resolved
internal/wclayer/baselayerreader.go Outdated Show resolved Hide resolved
internal/wclayer/converttobaselayer.go Show resolved Hide resolved
internal/wclayer/converttobaselayer.go Outdated Show resolved Hide resolved
pkg/ociwclayer/export.go Show resolved Hide resolved
  * We can use string instead of *uint16 in the //sys definition and allow
mksyscall to generate the proper boilerplate.
  * do not shadow err if it's not nil

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
@helsaawy helsaawy merged commit 5871d0c into microsoft:main Feb 28, 2023
jsturtevant added a commit to jsturtevant/hcsshim that referenced this pull request Mar 7, 2023
If a project creates a base layer image and wants to directly import the base then this ensure the baseline file are in place.  It is a follow up to microsoft#1637 and enables containerd with ctr image import image.tar of a base layer.

Signed-off-by: James Sturtevant <jstur@microsoft.com>
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 29, 2024
* Simple baseLayerReader to export parentless layers

This is the inverse of the baseLayerWriter: It walks Files/ and
UtilityVM/Files/ (if present) and ignores the rest of the layer data,
as it will be recreated when the layer is imported.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>

* Introduce hcsshim.ConvertToBaseLayer

This API allows turning any collection of files into a WCOW base layer.

It will create the necessary files in Files/ for
hcsshim.ProcessBaseLayer to function, validate the necessary files for
hcsshim.ProcessUtilityVMImage if UtilityVM/ exists, and then call those
two APIs to complete the process.

Calling this on a directory containing an untarred base layer OCI
tarball, gives a very similar outcome to passing the tar stream through
ociwclayer.ImportLayer.

The new API is used in `TestSCSIAddRemoveWCOW` to create nearly-empty
base layers for the scratch layers attached and removed from the utility
VM.

A wclayer command is also introduced: `makebaselayer` for testing and
validation purposes.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>

* Include hard-linked files as hard-links in the tarstream

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>

* Use offline registry library to generate min hive

This change adds functions to generate valid, empty hives.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>

* Rename ofreg.go and close key

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>

* Fix temp dir creation

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>

* Cleanup tests

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>

* Fix ORCloseHive definition

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>

* Remove unused ctx from baseLayerReader

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>

* Use string in sys definition and check for err

  * We can use string instead of *uint16 in the //sys definition and allow
mksyscall to generate the proper boilerplate.
  * do not shadow err if it's not nil

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>

* Close the r.proceed channel

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>

* Return if backup reader is nil

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>

---------

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Co-authored-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.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.

4 participants