Skip to content

Commit

Permalink
First steps on migrating to a new version of mongo.
Browse files Browse the repository at this point in the history
We're going to write a helper binary for this in Go, because:

- The currently maintained driver package supports mongo versions back
  to 2.6 (what we're using), which is not true for most other languages.
- We already have go in our toolchain for boringssl's test suite.
- The build is unlikely to break due to bitrot re: Go's toolchain.
- The generated binary is static, so all else fails we can just bundle
  the executable, though I don't anticipate that.
- I will be much more productive than in something else.
  • Loading branch information
zenhack committed Jul 31, 2022
1 parent bf47ef3 commit 9cbde21
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions make-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ fi
# Extract bin/mongo and bin/mongod from the old sandstorm bundle, and place them in bundle/.
tar xf $OLD_BUNDLE_PATH --transform=s/^${OLD_BUNDLE_BASE}/bundle/ $OLD_MONGO_FILES

# Copy in our helper to move over to newer versions of mongo:
cp tmp/sandstorm-migrate-mongo bundle/bin/

cp $(which zip unzip xz gpg) bundle/bin

# 'node-fibers' depends on a package (detect-libc) that uses various heuristics
Expand Down
26 changes: 26 additions & 0 deletions src/sandstorm-migrate-mongo/go.ekam-rule
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

top=$PWD
module_dir="$(dirname $0)"

echo findProvider special:ekam-interceptor
read INTERCEPTOR

if test "$INTERCEPTOR" = ""; then
echo "error: couldn't find intercept.so." >&2
exit 1
fi

# The go toolchain itself is statically linked, so we can't just
# run `go build` with the interceptor. But we can just use find.
# Note: it would be tempting at this point to skip the interceptor
# alltogether, but we want to also re-run if new sources files are
# added, even if none of the old ones references them.
LD_PRELOAD=$INTERCEPTOR find $module_dir -type f -name '*.go'
LD_PRELOAD=$INTERCEPTOR find $module_dir -type f -name go.mod

echo newOutput sandstorm-migrate-mongo
read OUTPUT_DISK_PATH

cd $module_dir
go build -o $top/$OUTPUT_DISK_PATH
3 changes: 3 additions & 0 deletions src/sandstorm-migrate-mongo/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/sandstorm-io/sandstorm/src/sandstorm-migrate-mongo

go 1.18
7 changes: 7 additions & 0 deletions src/sandstorm-migrate-mongo/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Hello, World!")
}

0 comments on commit 9cbde21

Please sign in to comment.