appengine icon indicating copy to clipboard operation
appengine copied to clipboard

Using appengine/log with appengine.BackgroundContext() == invalid security ticket on GAE Go/1.11

Open dragonsinth opened this issue 4 years ago • 3 comments

HTTP request logging seems fine since #164. However, logging in background threads using a appengine.BackgroundContext() always fails with:

internal.flushLog: Flush RPC: Call error 3: invalid security ticket: fs-playpen/admin.1.00c61b..."  

Where the last bit is the instance ID. I've dug through the code and it seems to be doing exactly what it's designed to to: flush top level background logs using a well-known instance specific ticket. Only, the ticket is rejected, so we just end up with a pile of these internal.flushLog errors in Stackdriver.

  • Is this supposed to work, or did I just mess something up?

  • Should we just avoid background context appengine/log calls and always log directly to stderr?

Thanks! Scott

dragonsinth avatar Aug 31 '19 00:08 dragonsinth

If you're on GAE Standard then I wouldn't expect this to work because the default security ticket is not associated with a request (the documentation notes that appengine.BackgroundContext() only works on GAE Flex). Are you in fact using Flex?

mtraver avatar Sep 03 '19 16:09 mtraver

If you're on GAE Standard then I wouldn't expect this to work because the default security ticket is not associated with a request (the documentation notes that appengine.BackgroundContext() only works on GAE Flex). Are you in fact using Flex?

Oh.. yikes. My bad. I must have read that and thought "Go 1.11 vs. Go 1.9" rather than Flex vs. Standard.

We'll fix our code.

That said, infinite log spam is probably not an ideal failure mode... it would probably be better if appengine.BackgroundContext() could just panic synchronously on non-FLEX. It would have definitely prevented me from accidentally diving down the wrong path.

dragonsinth avatar Sep 03 '19 20:09 dragonsinth

True, we can probably do better. I'll look into making the error more informative if appengine.BackgroundContext() is used on GAE Standard.

mtraver avatar Sep 03 '19 21:09 mtraver