-
Notifications
You must be signed in to change notification settings - Fork 104
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
Enable retry and recover for tarfs #538
Open
jiangliu
wants to merge
11
commits into
containerd:main
Choose a base branch
from
jiangliu:tarfs-recover
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5700836
tarfs: remove blobTarFilePath from snapshotStatus
jiangliu 07b9a91
tarfs: remove redundant status check
jiangliu e20fb9d
tarfs: refactor blobProcess()
jiangliu 98990ab
tarfs: retry downloading and converting on failure
jiangliu d5558af
tarfs: avoid redundant merge operation for images with only one layer
jiangliu 4c198ea
tarfs: recover tarfs information on restart
jiangliu cbe04b3
tarfs: import losetup.go from containerd
jiangliu 32f44c3
tarfs: replace go-losetup with the version from containerd
jiangliu 4060f01
tarfs: remount EROFS for existing tarfs instances on startup
jiangliu 54e2afb
tarfs: add unit test cases for tarfs
jiangliu e0124e7
tarfs: fix a data race condition
jiangliu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,14 @@ jobs: | |
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go | ||
- name: Setup Nydus | ||
run: | | ||
# Download nydus components | ||
NYDUS_VER=v$(curl -s "https://api.github.com/repos/dragonflyoss/nydus/releases/latest" | jq -r .tag_name | sed 's/^v//') | ||
wget https://github.com/dragonflyoss/nydus/releases/download/$NYDUS_VER/nydus-static-$NYDUS_VER-linux-amd64.tgz | ||
tar xzvf nydus-static-$NYDUS_VER-linux-amd64.tgz | ||
mkdir -p /usr/bin | ||
sudo mv nydus-static/nydus-image /usr/bin/ | ||
- name: Build | ||
run: | | ||
go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
|
@@ -135,6 +143,14 @@ jobs: | |
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go | ||
- name: Setup Nydus | ||
run: | | ||
# Download nydus components | ||
NYDUS_VER=v$(curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -s "https://api.github.com/repos/dragonflyoss/nydus/releases/latest" | jq -r .tag_name | sed 's/^v//') | ||
wget https://github.com/dragonflyoss/nydus/releases/download/$NYDUS_VER/nydus-static-$NYDUS_VER-linux-amd64.tgz | ||
tar xzvf nydus-static-$NYDUS_VER-linux-amd64.tgz | ||
mkdir -p /usr/bin | ||
sudo mv nydus-static/nydus-image /usr/bin/ | ||
- name: Run unit tests. | ||
run: make cover | ||
- name: Upload coverage to Codecov | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2023. Nydus Developers. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package daemon | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/containerd/nydus-snapshotter/config" | ||
"gotest.tools/assert" | ||
) | ||
|
||
func TestConfigOptions(t *testing.T) { | ||
tmpDir := t.TempDir() | ||
opts := []NewDaemonOpt{ | ||
WithSocketDir("/tmp/socket"), | ||
WithRef(5), | ||
WithLogDir(tmpDir), | ||
WithLogToStdout(true), | ||
WithLogLevel("Warning"), | ||
WithLogRotationSize(1024), | ||
WithConfigDir(tmpDir), | ||
WithMountpoint("/tmp/mnt"), | ||
WithNydusdThreadNum(4), | ||
WithFsDriver("fscache"), | ||
WithDaemonMode("dedicated"), | ||
} | ||
|
||
daemon, err := NewDaemon(opts...) | ||
assert.Assert(t, err) | ||
assert.Equal(t, daemon.States.APISocket, "/tmp/socket/"+daemon.ID()+"/api.sock") | ||
assert.Equal(t, daemon.ref, int32(5)) | ||
assert.Equal(t, daemon.States.LogDir, tmpDir+"/"+daemon.ID()) | ||
assert.Equal(t, daemon.States.LogToStdout, true) | ||
assert.Equal(t, daemon.States.LogLevel, "Warning") | ||
assert.Equal(t, daemon.States.LogRotationSize, 1024) | ||
assert.Equal(t, daemon.States.ConfigDir, tmpDir+"/"+daemon.ID()) | ||
assert.Equal(t, daemon.States.Mountpoint, "/tmp/mnt") | ||
assert.Equal(t, daemon.States.ThreadNum, 4) | ||
assert.Equal(t, daemon.States.FsDriver, "fscache") | ||
assert.Equal(t, string(daemon.States.DaemonMode), "dedicated") | ||
|
||
} | ||
|
||
func String(daemonMode config.DaemonMode) { | ||
panic("unimplemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright (c) 2023. Nydus Developers. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package daemon | ||
|
||
import ( | ||
"testing" | ||
|
||
"gotest.tools/assert" | ||
) | ||
|
||
func TestIdGenerate(t *testing.T) { | ||
id1 := newID() | ||
id2 := newID() | ||
|
||
assert.Assert(t, len(id1) > 0) | ||
assert.Assert(t, len(id2) > 0) | ||
assert.Assert(t, id1 != id2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2022. Nydus Developers. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package rafs | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/containerd/nydus-snapshotter/config" | ||
"github.com/containerd/nydus-snapshotter/internal/constant" | ||
"gotest.tools/assert" | ||
) | ||
|
||
func TestRafsSetEmpty(t *testing.T) { | ||
cache := NewRafsCache() | ||
|
||
assert.Assert(t, cache.Get("rafs1") == nil) | ||
assert.Equal(t, cache.Len(), 0) | ||
assert.Assert(t, cache.Head() == nil) | ||
instances := cache.List() | ||
assert.Equal(t, len(instances), 0) | ||
} | ||
|
||
func TestRafs(t *testing.T) { | ||
tmpDir := t.TempDir() | ||
snapshotterConfig := config.SnapshotterConfig{} | ||
snapshotterConfig.Root = tmpDir | ||
snapshotterConfig.DaemonMode = constant.DaemonModeDedicated | ||
assert.Assert(t, config.ProcessConfigurations(&snapshotterConfig)) | ||
|
||
rafs, err := NewRafs("snapshot1", "image1", "fscache") | ||
assert.Assert(t, err) | ||
assert.Equal(t, rafs, RafsGlobalCache.Get("snapshot1")) | ||
assert.Equal(t, RafsGlobalCache.Len(), 1) | ||
assert.Equal(t, rafs, RafsGlobalCache.Head()) | ||
instances := RafsGlobalCache.List() | ||
assert.Equal(t, len(instances), 1) | ||
assert.Equal(t, instances["snapshot1"].SnapshotID, "snapshot1") | ||
|
||
RafsGlobalCache.Lock() | ||
instances2 := RafsGlobalCache.ListLocked() | ||
RafsGlobalCache.Unlock() | ||
assert.Equal(t, len(instances2), 1) | ||
|
||
RafsGlobalCache.SetIntances(instances) | ||
assert.Equal(t, RafsGlobalCache.Len(), 1) | ||
assert.Equal(t, RafsGlobalCache.Head().SnapshotID, "snapshot1") | ||
|
||
assert.Equal(t, len(rafs.Annotations), 0) | ||
rafs.AddAnnotation("key", "value") | ||
assert.Equal(t, len(rafs.Annotations), 1) | ||
assert.Equal(t, rafs.GetSnapshotDir(), tmpDir+"/snapshots/snapshot1") | ||
assert.Equal(t, rafs.RelaMountpoint(), "/snapshot1") | ||
assert.Equal(t, rafs.FscacheWorkDir(), tmpDir+"/snapshots/snapshot1/fs") | ||
assert.Equal(t, rafs.GetFsDriver(), "fscache") | ||
rafs.SetMountpoint("/tmp/mnt") | ||
assert.Equal(t, rafs.GetMountpoint(), "/tmp/mnt") | ||
_, err = rafs.BootstrapFile() | ||
assert.Assert(t, err != nil) | ||
|
||
RafsGlobalCache.Remove("snapshot1") | ||
assert.Equal(t, RafsGlobalCache.Len(), 0) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No auth is required when requesting the latest version.