-
Notifications
You must be signed in to change notification settings - Fork 22
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
Update the app for GAE Go 1.12+ runtime #37
Conversation
- This is needed if we're dealing with storage engines that need additional operations to be performed (e.g. DB to be closed) - Additionally, rename newConfig to newRuntimeConfig to make it less likely to confuse it with tsbridge.NewConfig
Currently this is just a no-op but is needed to support storage engines that need to close their DB's
bd049f2
to
c99d093
Compare
1.12+ runtime requires the app to use go modules - Remove dep manifest, lock and vendor folder
- Add a .go-version file to use with goenv
AppEngine logging lib is no longer supported in 1.12+ runtimes
1.12+ doesn't support urlfetch
d959c3a
to
9b3b38b
Compare
datadog/metric_test.go
Outdated
code := m.Run() | ||
done() | ||
testCtxCancel() |
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.
The shutdown code in the emulator probably won't be run here, there's a race condition with os.Exit(), the next line.
I'll have a chat with you about how to fix this outside this review.
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.
@dparrish So as discussed I've decided to address this via returning a channel that gets pushed a message into it when it's done - PTAL
datastore/emulator.go
Outdated
func Emulator(ctx context.Context) error { | ||
|
||
// Set log formatter to process newlines since emulator gives a lot of output | ||
log.SetFormatter(&log.TextFormatter{DisableQuote: true}) |
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.
This changes the global logging state, probably not what you want. logrus can create child loggers with different formats which might be good here.
or move this SetFormatter line to main().
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.
Good point. I dug quite a bit through the docs, but couldn't find specifics on child loggers, can you point at an example somewhere?
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.
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.
Fixed it via log.WithContext()
PTAL
a599b0f
to
b97e6c3
Compare
Since we can no longer use AppEngine SDK for it
Working dir is now module root so we need to change some things accordingly
In favour of generic serving, as suggested by the migration guide
- Match the go version with the .go-version - Drop godep - Update CloudSDK
38523ea
to
50bec22
Compare
setProjectID(fakeProjectID) | ||
_, errNoProject := NewConfig(ctx, &ConfigOptions{Filename: "testdata/valid.yaml", Storage: storage}) | ||
|
||
if errNoProject == nil { |
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.
errNoProject
really should just be err
for consistency.
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.
Question - otherwise I'll get the No new variables on left side of :=
- is it ok to use =
to redefine err
?
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.
If you use the single-line form then you can redefine err! e.g. this is valid:
var err error
if err := Operation(); err != nil {
...
}
50bec22
to
fc833a2
Compare
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.
Fixed most of it - just 2 comments outstanding - PTAL.
datadog/metric_test.go
Outdated
if err == nil { | ||
t.Error("expected an error when server returns 404") | ||
} | ||
|
||
// A query needs to return a single time series. | ||
handler.filename = "multiple_ts.json" | ||
_, _, err = m.StackdriverData(testCtx, time.Now().Add(-time.Minute), &datastore.StoredMetricRecord{}) | ||
_, _, err = m.StackdriverData(ctx, time.Now().Add(-time.Minute), &datastore.StoredMetricRecord{Storage: storage}) |
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.
So genuine question here - if I do that - the function legit doesn't fit in my 27inch monitor - is it ok to leave it like this for readability sake?
fc833a2
to
709acff
Compare
- Migrating to use cloud datastore libraries - Add a client field to Datastore.manager and hold the client session info in it - Add a datastore emulator harness (using `gcloud`) for tests as `gaetest` is no longer supported past Go 1.11 - Update tests & mocks fixup
709acff
to
ee76673
Compare
Since
bbolt
which we plan to use as a storage engine requires Go 1.13+, we need to update the app to support GAE 1.12+ runtime (which we would've inevitably needed to do anyway).Rough outline of changes here:
appengine
libNOTE TO REVIEWER:
I know this is a large PR, but the migration scope is pretty large so I want to avoid merging commits that will make the project unbuildable. As such, I've partitioned the PR into small commits that should be limited in scope and easier to review. I plan to squash them after the review is finished.