-
Notifications
You must be signed in to change notification settings - Fork 42
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
fs-repo-11-to-12: add env vars for configuring the number of workers and the sync size #149
Changes from all commits
4dd1944
09055a5
368fcab
ff44fe3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ package mg11 | |
|
||
import ( | ||
"errors" | ||
"os" | ||
"strconv" | ||
"sync" | ||
"sync/atomic" | ||
|
||
|
@@ -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") | ||
} | ||
Comment on lines
+43
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we set this higher (e.g. 1MB minimum) just so people don't accidentally think 1 == 1MB or something? Similarly is there any use for setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's rename the env var to sync_size_bytes? |
||
SyncSize = syncSize | ||
} | ||
} | ||
|
||
// Swap holds the datastore keys for the original CID and for the | ||
// destination Multihash. | ||
type Swap struct { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ test_description="Simple fs-repo-migrations tests" | |
|
||
. lib/test-lib.sh | ||
|
||
latestRepoVersion="12" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a wacky change to have to do every time we do a release. Probably we could/should just hard code an immutable distpath so that the repo version is fixed, but at the moment we're just trying to get CI to be green. |
||
|
||
test_expect_success "fs-repo-migrations binary is here" ' | ||
test -f "$LOCAL_FS_REPO_MIG" | ||
' | ||
|
@@ -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 | ||
' | ||
|
||
|
@@ -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 | ||
' | ||
|
||
|
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.
We could log an error and fallback to the defaults instead of panicking here, but this seems reasonable to let the user know they did something wrong.