Skip to content

Commit 28bbe67

Browse files
Merge branch 'master' into connection-timeout
2 parents 97f2d71 + 835e86e commit 28bbe67

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+979
-730
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@master
11+
- uses: actions/checkout@v2
1212

13-
- name: Set up Go 1.12
13+
- name: Set up Go 1.14
1414
uses: actions/setup-go@v1
1515
with:
16-
version: 1.12
17-
id: go
16+
go-version: 1.14
1817

1918
- name: Build
2019
run: script/cibuild
20+
21+
- name: Upload gh-ost binary artifact
22+
uses: actions/upload-artifact@v1
23+
with:
24+
name: gh-ost
25+
path: bin/gh-ost

.github/workflows/replica-tests.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@master
11+
- uses: actions/checkout@v2
1212

13-
- name: Set up Go 1.12
13+
- name: Set up Go 1.14
1414
uses: actions/setup-go@v1
1515
with:
16-
version: 1.12
17-
id: go
16+
go-version: 1.14
1817

1918
- name: migration tests
2019
run: script/cibuild-gh-ost-replica-tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/bin/
33
/libexec/
44
/.vendor/
5+
.idea/

Dockerfile.packaging

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22

3-
FROM golang:1.12.6
3+
FROM golang:1.14.7
44

55
RUN apt-get update
66
RUN apt-get install -y ruby ruby-dev rubygems build-essential

Dockerfile.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.12.1
1+
FROM golang:1.14.7
22
LABEL maintainer="[email protected]"
33

44
RUN apt-get update

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Please see [Coding gh-ost](doc/coding-ghost.md) for a guide to getting started d
9494

9595
[Download latest release here](https://github.com/github/gh-ost/releases/latest)
9696

97-
`gh-ost` is a Go project; it is built with Go `1.12` and above. To build on your own, use either:
97+
`gh-ost` is a Go project; it is built with Go `1.14` and above. To build on your own, use either:
9898
- [script/build](https://github.com/github/gh-ost/blob/master/script/build) - this is the same build script used by CI hence the authoritative; artifact is `./bin/gh-ost` binary.
9999
- [build.sh](https://github.com/github/gh-ost/blob/master/build.sh) for building `tar.gz` artifacts in `/tmp/gh-ost`
100100

@@ -109,3 +109,4 @@ Generally speaking, `master` branch is stable, but only [releases](https://githu
109109
- [@shlomi-noach](https://github.com/shlomi-noach)
110110
- [@jessbreckenridge](https://github.com/jessbreckenridge)
111111
- [@gtowey](https://github.com/gtowey)
112+
- [@timvaillancourt](https://github.com/timvaillancourt)

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ function build {
1818
GOOS=$3
1919
GOARCH=$4
2020

21-
if ! go version | egrep -q 'go(1\.1[234])' ; then
22-
echo "go version must be 1.12 or above"
21+
if ! go version | egrep -q 'go(1\.1[456])' ; then
22+
echo "go version must be 1.14 or above"
2323
exit 1
2424
fi
2525

go/base/context.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
"github.com/github/gh-ost/go/mysql"
2121
"github.com/github/gh-ost/go/sql"
22+
"github.com/outbrain/golib/log"
2223

2324
"gopkg.in/gcfg.v1"
2425
gcfgscanner "gopkg.in/gcfg.v1/scanner"
@@ -119,6 +120,7 @@ type MigrationContext struct {
119120
ThrottleAdditionalFlagFile string
120121
throttleQuery string
121122
throttleHTTP string
123+
IgnoreHTTPErrors bool
122124
ThrottleCommandedByUser int64
123125
HibernateUntil int64
124126
maxLoad LoadMap
@@ -216,6 +218,25 @@ type MigrationContext struct {
216218
ForceTmpTableName string
217219

218220
recentBinlogCoordinates mysql.BinlogCoordinates
221+
222+
Log Logger
223+
}
224+
225+
type Logger interface {
226+
Debug(args ...interface{})
227+
Debugf(format string, args ...interface{})
228+
Info(args ...interface{})
229+
Infof(format string, args ...interface{})
230+
Warning(args ...interface{}) error
231+
Warningf(format string, args ...interface{}) error
232+
Error(args ...interface{}) error
233+
Errorf(format string, args ...interface{}) error
234+
Errore(err error) error
235+
Fatal(args ...interface{}) error
236+
Fatalf(format string, args ...interface{}) error
237+
Fatale(err error) error
238+
SetLevel(level log.LogLevel)
239+
SetPrintStackTrace(printStackTraceFlag bool)
219240
}
220241

221242
type ContextConfig struct {
@@ -250,6 +271,7 @@ func NewMigrationContext() *MigrationContext {
250271
pointOfInterestTimeMutex: &sync.Mutex{},
251272
ColumnRenameMap: make(map[string]string),
252273
PanicAbort: make(chan error),
274+
Log: NewDefaultLogger(),
253275
}
254276
}
255277

@@ -574,6 +596,13 @@ func (this *MigrationContext) SetThrottleHTTP(throttleHTTP string) {
574596
this.throttleHTTP = throttleHTTP
575597
}
576598

599+
func (this *MigrationContext) SetIgnoreHTTPErrors(ignoreHTTPErrors bool) {
600+
this.throttleHTTPMutex.Lock()
601+
defer this.throttleHTTPMutex.Unlock()
602+
603+
this.IgnoreHTTPErrors = ignoreHTTPErrors
604+
}
605+
577606
func (this *MigrationContext) GetMaxLoad() LoadMap {
578607
this.throttleMutex.Lock()
579608
defer this.throttleMutex.Unlock()

go/base/default_logger.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package base
2+
3+
import (
4+
"github.com/outbrain/golib/log"
5+
)
6+
7+
type simpleLogger struct{}
8+
9+
func NewDefaultLogger() *simpleLogger {
10+
return &simpleLogger{}
11+
}
12+
13+
func (*simpleLogger) Debug(args ...interface{}) {
14+
log.Debug(args[0].(string), args[1:])
15+
return
16+
}
17+
18+
func (*simpleLogger) Debugf(format string, args ...interface{}) {
19+
log.Debugf(format, args...)
20+
return
21+
}
22+
23+
func (*simpleLogger) Info(args ...interface{}) {
24+
log.Info(args[0].(string), args[1:])
25+
return
26+
}
27+
28+
func (*simpleLogger) Infof(format string, args ...interface{}) {
29+
log.Infof(format, args...)
30+
return
31+
}
32+
33+
func (*simpleLogger) Warning(args ...interface{}) error {
34+
return log.Warning(args[0].(string), args[1:])
35+
}
36+
37+
func (*simpleLogger) Warningf(format string, args ...interface{}) error {
38+
return log.Warningf(format, args...)
39+
}
40+
41+
func (*simpleLogger) Error(args ...interface{}) error {
42+
return log.Error(args[0].(string), args[1:])
43+
}
44+
45+
func (*simpleLogger) Errorf(format string, args ...interface{}) error {
46+
return log.Errorf(format, args...)
47+
}
48+
49+
func (*simpleLogger) Errore(err error) error {
50+
return log.Errore(err)
51+
}
52+
53+
func (*simpleLogger) Fatal(args ...interface{}) error {
54+
return log.Fatal(args[0].(string), args[1:])
55+
}
56+
57+
func (*simpleLogger) Fatalf(format string, args ...interface{}) error {
58+
return log.Fatalf(format, args...)
59+
}
60+
61+
func (*simpleLogger) Fatale(err error) error {
62+
return log.Fatale(err)
63+
}
64+
65+
func (*simpleLogger) SetLevel(level log.LogLevel) {
66+
log.SetLevel(level)
67+
return
68+
}
69+
70+
func (*simpleLogger) SetPrintStackTrace(printStackTraceFlag bool) {
71+
log.SetPrintStackTrace(printStackTraceFlag)
72+
return
73+
}

go/base/utils.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
gosql "database/sql"
1616
"github.com/github/gh-ost/go/mysql"
17-
"github.com/outbrain/golib/log"
1817
)
1918

2019
var (
@@ -86,7 +85,7 @@ func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig,
8685
}
8786

8887
if connectionConfig.Key.Port == port || (extraPort > 0 && connectionConfig.Key.Port == extraPort) {
89-
log.Infof("connection validated on %+v", connectionConfig.Key)
88+
migrationContext.Log.Infof("connection validated on %+v", connectionConfig.Key)
9089
return version, nil
9190
} else if extraPort == 0 {
9291
return "", fmt.Errorf("Unexpected database port reported: %+v", port)

0 commit comments

Comments
 (0)