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

Fix/fs 11 to 12 suppress error #151

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fs-repo-11-to-12/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/ipfs/fs-repo-migrations/tools v0.0.0-20211209222258-754a2dcb82ea
github.com/ipfs/go-cid v0.0.7
github.com/ipfs/go-datastore v0.4.5
github.com/ipfs/go-ds-badger v0.2.7-0.20211210151007-a2805355dcf5 // indirect
github.com/ipfs/go-ds-badger v0.2.7-0.20220117180822-159330558612 // indirect
github.com/ipfs/go-filestore v1.0.0
github.com/ipfs/go-ipfs v0.8.0
github.com/ipfs/go-ipfs-ds-help v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions fs-repo-11-to-12/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ github.com/ipfs/go-ds-badger v0.0.7/go.mod h1:qt0/fWzZDoPW6jpQeqUjR5kBfhDNB65jd9
github.com/ipfs/go-ds-badger v0.2.1/go.mod h1:Tx7l3aTph3FMFrRS838dcSJh+jjA7cX9DrGVwx/NOwE=
github.com/ipfs/go-ds-badger v0.2.3/go.mod h1:pEYw0rgg3FIrywKKnL+Snr+w/LjJZVMTBRn4FS6UHUk=
github.com/ipfs/go-ds-badger v0.2.6/go.mod h1:02rnztVKA4aZwDuaRPTf8mpqcKmXP7mLl6JPxd14JHA=
github.com/ipfs/go-ds-badger v0.2.7-0.20211210151007-a2805355dcf5 h1:ovdpQk2ZVK6eQLzMCZy1z2tJae7yvE8xaPUw4Pr1RqI=
github.com/ipfs/go-ds-badger v0.2.7-0.20211210151007-a2805355dcf5/go.mod h1:02rnztVKA4aZwDuaRPTf8mpqcKmXP7mLl6JPxd14JHA=
github.com/ipfs/go-ds-badger v0.2.7-0.20220117180822-159330558612 h1:Uvp2/ZNlR3YmH04XJGv4YsPabhPzRPyeroLltVKBSr8=
github.com/ipfs/go-ds-badger v0.2.7-0.20220117180822-159330558612/go.mod h1:02rnztVKA4aZwDuaRPTf8mpqcKmXP7mLl6JPxd14JHA=
github.com/ipfs/go-ds-flatfs v0.4.5 h1:4QceuKEbH+HVZ2ZommstJMi3o3II+dWS3IhLaD7IGHs=
github.com/ipfs/go-ds-flatfs v0.4.5/go.mod h1:e4TesLyZoA8k1gV/yCuBTnt2PJtypn4XUlB5n8KQMZY=
github.com/ipfs/go-ds-leveldb v0.0.1/go.mod h1:feO8V3kubwsEF22n0YRQCffeb79OOYIykR4L04tMOYc=
Expand Down
34 changes: 32 additions & 2 deletions fs-repo-11-to-12/migration/swapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package mg11

import (
"errors"
"os"
"strconv"
"sync"
"sync/atomic"

Expand All @@ -19,6 +21,32 @@ var SyncSize uint64 = 20 * 1024 * 1024 // 20MiB
// migration.
var NWorkers int = 4

func init() {
workerEnvVar := "IPFS_FS_MIGRATION_11_TO_12_NWORKERS"
syncSizeEnvVar := "IPFS_FS_MIGRATION_11_TO_12_SYNC_SIZE_BYTES"
if nworkersStr, nworkerInEnv := os.LookupEnv(workerEnvVar); nworkerInEnv {
nworkers, err := strconv.Atoi(nworkersStr)
if err != nil {
panic(err)
}
if nworkers < 1 {
panic("number of workers must be at least 1")
}
NWorkers = nworkers
}

if syncSizeStr, syncSizeInEnv := os.LookupEnv(syncSizeEnvVar); syncSizeInEnv {
syncSize, err := strconv.ParseUint(syncSizeStr, 10, 64)
if err != nil {
panic(err)
}
if syncSize < 1 {
panic("sync size bytes must be at least 1")
}
SyncSize = syncSize
}
}

// Swap holds the datastore keys for the original CID and for the
// destination Multihash.
type Swap struct {
Expand Down Expand Up @@ -114,9 +142,11 @@ func (cswap *CidSwapper) swapWorker(dryRun bool, resultsCh <-chan query.Result)
oldKey := ds.NewKey(res.Key)
c, err := dsKeyToCid(ds.NewKey(oldKey.BaseNamespace())) // remove prefix
if err != nil {
// complain if we find anything that is not a CID but
// complain if we find anything that is not a CID or multihash but
// leave it as it is.
log.Log("could not parse %s as a Cid", oldKey)
if _, err := dshelp.DsKeyToMultihash(ds.NewKey(oldKey.BaseNamespace())); err != nil {
log.Log("could not parse %s as a Cid or Multihash", oldKey)
}
continue
}
if c.Version() == 0 { // CidV0 are multihashes, leave them.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fs-repo-11-to-12/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ github.com/ipfs/go-datastore/mount
github.com/ipfs/go-datastore/namespace
github.com/ipfs/go-datastore/query
github.com/ipfs/go-datastore/sync
# github.com/ipfs/go-ds-badger v0.2.7-0.20211210151007-a2805355dcf5
# github.com/ipfs/go-ds-badger v0.2.7-0.20220117180822-159330558612
## explicit
github.com/ipfs/go-ds-badger
# github.com/ipfs/go-ds-flatfs v0.4.5
Expand Down
6 changes: 4 additions & 2 deletions sharness/t0030-simple-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ test_description="Simple fs-repo-migrations tests"

. lib/test-lib.sh

latestRepoVersion="12"

test_expect_success "fs-repo-migrations binary is here" '
test -f "$LOCAL_FS_REPO_MIG"
'
Expand All @@ -13,7 +15,7 @@ test_expect_success "'fs-repo-migrations -v' works" '
'

test_expect_success "'fs-repo-migrations -v' output looks good" '
echo "11" >expected &&
echo "$latestRepoVersion" >expected &&
test_cmp expected actual
'

Expand All @@ -30,7 +32,7 @@ test_expect_success "'fs-repo-migrations -v' works" '
'

test_expect_success "'fs-repo-migrations -v' output looks good" '
echo "11" >expected &&
echo "$latestRepoVersion" >expected &&
test_cmp expected actual
'

Expand Down