Skip to content

Support the native snapshotter on FreeBSD#4858

Merged
mxpv merged 2 commits intocontainerd:masterfrom
samuelkarp:freebsd-native-snapshotter
Jan 11, 2021
Merged

Support the native snapshotter on FreeBSD#4858
mxpv merged 2 commits intocontainerd:masterfrom
samuelkarp:freebsd-native-snapshotter

Conversation

@samuelkarp
Copy link
Copy Markdown
Member

This PR adds support for the native snapshotter on FreeBSD using FreeBSD nullfs.

The native snapshotter passes its test suite and is able to unpack an image for the freebsd/amd64 platform:

% freebsd-version
12.1-RELEASE-p4
% pwd
/home/sam/go/src/github.com/containerd/containerd/snapshots/native
% sudo go test -v -test.root .
[...trimmed output...]
--- PASS: TestNaive (0.01s)                                                                                                                                              
    --- PASS: TestNaive/Basic (0.03s)                                                                                                                                    
    --- PASS: TestNaive/128LayersMount (4.04s)                                                                                                                           
    --- PASS: TestNaive/RootPermission (0.01s)                                                                                                                           
    --- PASS: TestNaive/CloseTwice (0.00s)                                                                                                                               
    --- PASS: TestNaive/StatInWalk (0.01s)                                                                                                                               
    --- PASS: TestNaive/ViewReadonly (0.01s)                                                                                                                             
    --- SKIP: TestNaive/Rename (0.00s)                                                                                                                                   
    --- PASS: TestNaive/MoveFileFromLowerLayer (0.03s)                                                                                                                   
    --- PASS: TestNaive/DeletedFilesInChildSnapshot (0.03s)                                                                                                              
    --- PASS: TestNaive/RemoveIntermediateSnapshot (0.01s)                                                                                                               
    --- PASS: TestNaive/DirectoryPermissionOnCommit (0.04s)                                                                                                              
    --- PASS: TestNaive/Chown (0.03s)                                                                                                                                    
    --- PASS: TestNaive/RemoveDirectoryInLowerLayer (0.04s)                                                                                                              
    --- PASS: TestNaive/LayerFileupdate (3.85s)                                                                                                                          
    --- PASS: TestNaive/Walk (0.01s)                                                                                                                                     
    --- PASS: TestNaive/Remove (0.01s)                                                                                                                                   
    --- PASS: TestNaive/Update (0.03s)                                                                                                                                   
    --- PASS: TestNaive/PreareViewFailingtest (0.01s)                                                                                                                    
    --- PASS: TestNaive/TransitivityTest (0.01s)                                                                                                                         
    --- PASS: TestNaive/StatComitted (0.01s)                                                                                                                             
    --- PASS: TestNaive/StatActive (0.01s)                                                                                                                               
PASS
ok      github.com/containerd/containerd/snapshots/native       8.226s
% sudo ctr i ls
REF     TYPE                                    DIGEST                                                                  SIZE      PLATFORMS     LABELS 
freebsd application/vnd.oci.image.index.v1+json sha256:960c76846cd112e09032c88914458faee8d03c04b8260dfbc4da70b25227534a 236.8 MiB freebsd/amd64 -

Comment thread mount/mount_freebsd.go Outdated
Comment on lines 54 to 60
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The behavior around ECHILD and retries is copied from mount_linux.go. There isn't (yet) a shim on FreeBSD, so I don't know if the logic is really necessary, but I left it in to start. If there's a preference to remove it, I'm happy to do so.

Comment thread mount/mount_freebsd.go Outdated
Comment on lines 92 to 98
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Similarly, the behavior around EBUSY and retries is copied from mount_linux.go. Again, I don't know if the logic is really necessary, but I left it in to start. If there's a preference to remove it, I'm happy to do so.

@samuelkarp samuelkarp force-pushed the freebsd-native-snapshotter branch from 8e9280b to 2fb04a0 Compare December 17, 2020 08:31
Comment thread mount/mount_freebsd.go Outdated
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 there any reason not to use mount(2) syscall directly?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

See the comment on line 37:

// The "syscall" and "golang.org/x/sys/unix" packages do not define a Mount
// function for FreeBSD, so instead we execute mount(8) and trust it to do
// the right thing

We could use syscall.RawSyscall but using mount(8) felt more reliable to me.

Comment thread mount/mount_freebsd.go Outdated
Copy link
Copy Markdown
Member

@kzys kzys Dec 17, 2020

Choose a reason for hiding this comment

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

  1. You haven't used this constant on the PR.
  2. Would it be ErrNotImplemented or ErrNotImplementedOnPlatform? This might be useful for other non-Unix platforms.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This constant is pre-existing (was in mount/mount_unix.go) and used elsewhere in the codebase when compiled for FreeBSD (specifically in pkg/os/mount_unix.go). I left the name as-is to avoid touching other places in the codebase.

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.

Oh I see. LGTM then.

@samuelkarp samuelkarp force-pushed the freebsd-native-snapshotter branch from 2fb04a0 to b667c15 Compare December 18, 2020 17:51
@samuelkarp
Copy link
Copy Markdown
Member Author

samuelkarp force-pushed the samuelkarp:freebsd-native-snapshotter branch from 2fb04a0 to b667c15

Rebased on top of the current master; no changes to the diff.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Dec 18, 2020

Build succeeded.

@samuelkarp samuelkarp force-pushed the freebsd-native-snapshotter branch from b667c15 to b624486 Compare December 23, 2020 05:26
@samuelkarp
Copy link
Copy Markdown
Member Author

samuelkarp force-pushed the samuelkarp:freebsd-native-snapshotter branch from b667c15 to b624486

Rebased on top of the current master; no changes to the diff.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Dec 23, 2020

Build succeeded.

@samuelkarp
Copy link
Copy Markdown
Member Author

I believe the devicemapper failures are unrelated to my change as the only change on Linux is a reordering of mount options for the native snapshotter.

@mxpv mxpv merged commit 04df60d into containerd:master Jan 11, 2021
@kzys kzys mentioned this pull request Mar 25, 2021
6 tasks
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