Skip to content
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

[#10929] Migrate Task Queue API and Logs API to GCP clients #10930

Merged

Conversation

wkurniawan07
Copy link
Member

Fixes #10929

Note: don't be alarmed by the amount of code addition. There is an explanation for that.

In addition, one thing that this PR shows is that separating the services between dev server and staging/production server will be more of a challenge in the future (GAE really did us a favor in this aspect).

@wkurniawan07 wkurniawan07 added the s.ToReview The PR is waiting for review(s) label Jan 23, 2021
@wkurniawan07 wkurniawan07 force-pushed the runtime-upgrade/taskqueue-logging branch from a1bad7e to 51921f6 Compare January 23, 2021 14:33
@madanalogy
Copy link
Contributor

Actually, why not use cloud logging v2 instead?

However, its Java format is not available in any currently published GCP client libraries

It's not the ListLogsRequest class here? https://googleapis.dev/java/google-cloud-logging/latest/index.html

I'm referencing https://cloud.google.com/logging/docs/reference/libraries for the java client library

@wkurniawan07
Copy link
Member Author

That's the request object for the protobuf client and has nothing to do here. The log format that we need is very specifically this: https://cloud.google.com/logging/docs/reference/v2/rpc/google.appengine.logging.v1#google.appengine.logging.v1.RequestLog.

@wkurniawan07 wkurniawan07 force-pushed the runtime-upgrade/taskqueue-logging branch from 8a85f3b to f09a08b Compare February 7, 2021 17:43
LogService logService = LogServiceFactory.getLogService();
private List<LogEntry> getErrorLogs() {
if (Config.isDevServer()) {
// Not supported in dev server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just print out a message to console or something equivalent here? So that developers know logs are not supported in dev environment rather than having to hunt down the code here

Copy link
Member Author

@wkurniawan07 wkurniawan07 Feb 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think printing to console would help. This API is not deliberately used by anyone in production system (cron job doesn't really count as any"one", does it?), and if someone really wants to test this, chances are s/he already knows that this is a GCP-specific feature.

# This indicates whether task queues are active (e.g. items added to task queue will be queued for execution).
# This flag is only used during development mode; in production, task queue will always be active.
# In addition, during development mode, there is no "queueing", i.e. all tasks will be immediately executed.
app.taskqueue.active=true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc once this goes live will need to add lines to build.properties, just fyi for deployment of v7.10

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No: This flag is only used during development mode

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about app.region?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app.region is the other way around: necessary in staging/production but ignored in dev server

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay so that's the one that will need to be added then haha

@madanalogy madanalogy added s.FinalReview The PR is ready for final review and removed s.ToReview The PR is waiting for review(s) labels Feb 8, 2021
@madanalogy madanalogy self-assigned this Feb 8, 2021
@madanalogy madanalogy added this to the V7.10.0 milestone Feb 8, 2021
@madanalogy madanalogy requested review from rrtheonlyone and removed request for rrtheonlyone February 11, 2021 02:11
Copy link
Contributor

@rrtheonlyone rrtheonlyone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

Really nice work parsing the logs using the protobuf - tested on staging environment and works well.

I tried to dig and see if there is a way to do it without generating the bindings by hand but could not find anything. Others seemed to have done the same: https://stackoverflow.com/a/59414384/13750147

LogLevel logLevel = currentLog.getLogLevel();
logLines = reconvertedLog.getLineList();
} catch (InvalidProtocolBufferException e) {
// TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we planning on doing here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wkurniawan07 did you intend for this to be done in this PR or separately (i.e. needs some discussion)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure myself what best to do here. If we do a error-level log here, then this log will be part of the next logs compilation, which will also fail because of the same reason. At best we can do a warn-level log here, but let's be real: that's as good as no logs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I think this will need some discussion and possibly research, maybe settle another time with another PR/issue. We go ahead with what we have for now then

@madanalogy madanalogy mentioned this pull request Feb 15, 2021
4 tasks
@madanalogy madanalogy added the c.Task Other non-user-facing works, e.g. refactoring, adding tests label Feb 15, 2021
@madanalogy madanalogy added s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging and removed s.FinalReview The PR is ready for final review labels Feb 15, 2021
@madanalogy madanalogy merged commit d32428b into TEAMMATES:master Feb 15, 2021
@wkurniawan07 wkurniawan07 deleted the runtime-upgrade/taskqueue-logging branch February 15, 2021 15:07
# This is the deployment region of the app.
# For dev server, this could be anything.
# For staging/production server, this must match the region of your GAE application.
app.region=us-central1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc I forgot to bring your attention to changes needed in the src/main/resources/build.properties file with the release of V7.10.0 which might be the reason for errors in #10974

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. How do I find the region used for the production version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc you can type gcloud app describe --project <project-name> (replace <project-name with the project in GAE)

You should see something like this:

authDomain: gmail.com
codeBucket: staging.myapp-1337.appspot.com
defaultBucket: myapp-1337.appspot.com
defaultHostname: myapp-1337.appspot.com
featureSettings:
  splitHealthChecks: true
gcrDomain: us.gcr.io
id: myapp-1337
locationId: us-central
name: apps/myapp-1337
servingStatus: SERVING

For teammates, we should be us-central - so region should be us-central1 (the docs mention that for this region we have to map the name slightly differently):

Note: Two locations, which are called europe-west and us-central in App Engine commands and in the Google Cloud Console, are called europe-west1 and us-central1, respectively, elsewhere in Google documentation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Thanks both. Will update and deploy again soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c.Task Other non-user-facing works, e.g. refactoring, adding tests s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate Task Queue API and Logs API to GCP clients
4 participants