Skip to content

Commit ca15a0a

Browse files
authored
Add git revision to migration-verifier. (#70)
This will help debugging cases where migration-verifier may have been built from an old revision.
1 parent e783c4f commit ca15a0a

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

.github/workflows/all.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
run: yes | m stable && dirname $(readlink $(which mongod)) > .metapath
8484

8585
- name: Build
86-
run: go build main/migration_verifier.go
86+
run: ./build.sh
8787

8888
- name: Start clusters
8989
run: |-

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ _This Repository is NOT an officially supported MongoDB product. This tool reduc
66

77

88
```
9-
go build main/migration_verifier.go
9+
./build.sh
1010
```
1111

12-
13-
1412
# Operational UX Once Running
1513

1614
_Assumes no port set, default port for operation webserver is 27020_

build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
commit=$(git show --no-patch --format='%H')
4+
5+
go build -ldflags="-X 'main.Revision=$commit'" main/migration_verifier.go

main/migration_verifier.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ const (
4343
pprofInterval = "pprofInterval"
4444
)
4545

46+
// This gets set at build time.
47+
var Revision = "Unknown; build with build.sh."
48+
4649
func main() {
4750
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
4851

@@ -154,9 +157,10 @@ func main() {
154157
}
155158

156159
app := &cli.App{
157-
Name: "migration-verifier",
158-
Usage: "verify migration correctness",
159-
Flags: flags,
160+
Name: "migration-verifier",
161+
Usage: "verify migration correctness",
162+
Version: Revision,
163+
Flags: flags,
160164
Before: func(cCtx *cli.Context) error {
161165
confFile := cCtx.String(configFileFlag)
162166

@@ -203,6 +207,10 @@ func handleArgs(ctx context.Context, cCtx *cli.Context) (*verifier.Verifier, err
203207

204208
v := verifier.NewVerifier(verifierSettings, logPath)
205209

210+
v.GetLogger().Info().
211+
Str("revision", Revision).
212+
Msg("migration-verifier started.")
213+
206214
err := v.SetSrcURI(ctx, cCtx.String(srcURI))
207215
if err != nil {
208216
return nil, err

0 commit comments

Comments
 (0)