Commit Graph

169 Commits

Author SHA1 Message Date
Travis Reeder
965630af15 Remove error returns. 2017-10-26 11:12:08 +02:00
Reed Allman
91d2a89e19 Merge pull request #447 from fnproject/tracing_to_prometheus
Tracing to prometheus
2017-10-25 10:58:07 -07:00
Reed Allman
7ba2dc005e fix debug logger output (#458)
our dear friend mr. funclogger was bypassing calls to our multi writer since
we were embedding a *bytes.Buffer, it was using ReadFrom and WriteString which
would never call the stderr logger's Write method (or, as I learned, other
things trying to wrap that buffer's Write method...).

the tl;dr is many times DEBUG lines don't get spat out, from async tasks
especially (few people using this).

I think the final solution is probably to make funclogger a 'more robust'
interface that we understand instead of trying to minimize it to an
io.ReaderWriterCloser, much like how bytes.Buffer has all kinds of
methods implemented on it, we can implement things like ReadFrom and
WriteString most likely. not a big fan of how things are now (and it's my own
doing) with the readerwritercloser coming from multiple places but meh,
will get to it some day soon, the log stuff will be a pretty hot path.
2017-10-25 16:25:59 +02:00
Travis Reeder
d30bcb0397 Fix lost error 2017-10-25 14:41:18 +02:00
Travis Reeder
de04562b8e Pushed triggers into start() and end() 2017-10-25 14:14:31 +02:00
Travis Reeder
d080c23981 First draft of modifying RunnerListener to CallListener to get it closer to the action (and named better). 2017-10-25 14:13:25 +02:00
Nigel Deakin
39feaf8b69 Send tracing spans to Prometheus 2017-10-20 16:30:19 +01:00
Denis Makogon
ce25adfddb JSON protocol updating (#426)
* JSON protocol updating

 this patch adds HTTP query string into payload (see more TODOs in code)
 adds one more test to verify query

* Fixing FMT
2017-10-12 23:10:21 +03:00
Nigel Deakin
1646d25c01 Merge pull request #396 from fnproject/add_prometheus_metrics
Add Prometheus statistics and an example to showcase them using Grafana
2017-10-10 09:37:28 +01:00
Denis Makogon
22b5140f56 Do not expect function to set response code 2017-10-07 03:07:21 +03:00
Denis Makogon
e4684096f7 Fmt and docs 2017-10-07 02:59:08 +03:00
Denis Makogon
6141344e5f Error before sending json object if something bad happend with reading a request body 2017-10-07 02:33:43 +03:00
Denis Makogon
6682de4768 Addressing comments 2017-10-07 02:28:56 +03:00
Denis Makogon
e8f317abd4 Addressing more comments
tests do assertion on request data and headers
 doc fixed
2017-10-07 02:24:07 +03:00
Denis Makogon
181ccf54b4 Addressing more comments + tests 2017-10-07 02:11:49 +03:00
Denis Makogon
9f3bfa1005 Read request body and see if it's not empty then decide whether write it or not 2017-10-07 01:24:43 +03:00
Denis Makogon
b4b5302a44 Addressing certain comments from last review 2017-10-07 01:20:53 +03:00
Denis Makogon
de7b4e6067 Returning error instead of writing it to a response writer 2017-10-07 00:52:01 +03:00
Denis Makogon
7dd9b5a4cd We still can write JSON request object in parts
except just copying content from request body to STDIN
  we need to write encoded data,
  so we're using STDIN JSON stream encoder.
2017-10-07 00:43:09 +03:00
Denis Makogon
588d9e523b Do not forget to close request body 2017-10-07 00:43:09 +03:00
Denis Makogon
c2ee67fb21 Revisiting request body processing 2017-10-07 00:43:09 +03:00
Denis Makogon
1f589d641e Let function write headers to a response 2017-10-07 00:43:09 +03:00
Denis Makogon
caf1488dd9 Make Dispatch cleaner 2017-10-07 00:43:09 +03:00
Denis Makogon
2250e1d08c Get rid of content-length-based copying 2017-10-07 00:43:08 +03:00
Denis Makogon
1cdd241920 Trying to avoid buffers and write directly to pipe
this change makes Dispatch write request body and
 http headers directly to pipe one by one
 in case of non-empty request body,
 if not - write headers and close finalize JSON
2017-10-07 00:43:08 +03:00
Denis Makogon
955b294bc6 Trying to avoid any buffering 2017-10-07 00:43:08 +03:00
Denis Makogon
da9629d8dc Use STDIN as writer for encoding func's JSON input data instead of buffering 2017-10-07 00:43:08 +03:00
Denis Makogon
0316cd90a1 Dismiss redundant function 2017-10-07 00:43:08 +03:00
Denis Makogon
3fb040f293 Addressing comments
What's new?
  - unmarshal JSON response only in case of HTTP response writer
2017-10-07 00:43:07 +03:00
Denis Makogon
783490dc79 Addressing certain comments
What's new?
 - better error handling
 - still need to decode JSON from function because we need status code and body
 - prevent request body to be a problem by deferring its close
 - moving examples around: putting http and json samples into one folder
2017-10-07 00:43:07 +03:00
Denis Makogon
1882845a61 Respond with any error that happends during JSON dispatching 2017-10-07 00:43:07 +03:00
Denis Makogon
3da9ad4328 Using io.LimitReader as the way to control size of request body with respect to content length 2017-10-07 00:43:07 +03:00
Denis Makogon
ecaa5eefbf Cleaning up code
Getting rid of request url, call id, method: all of them are
 redundant and available through env
2017-10-07 00:43:07 +03:00
amykang2020
b6b9b55ca9 apply/make Travis's json-format branch prototype to work with latest restructured master; added StatusCode to JSONOutput server-function contract 2017-10-07 00:43:07 +03:00
Reed Allman
8a59654582 go vet yourself (#397)
go vet caught some nifty bugs. so fixed those here, and also made it so that
we vet everything from now on since the robots seem to do a better job of
vetting than we have managed to.

also adds gofmt check to circle. could move this to the test.sh script (didn't
want a script calling a script, because $reasons) and it's nice and isolated
in its own little land as it is. side note, changed the script so it runs in
100ms instead of 3s, i think find is a lot faster than go list.

attempted some minor cleanup of various scripts
2017-10-06 08:42:33 -07:00
Nigel Deakin
ae31944224 Add Prometheus statistics and an example to showcase them using Grafana 2017-10-05 16:21:31 +01:00
Reed Allman
caba9e0ec6 more strict configuration of routes
* idle_timeout max of 1h
* timeout max of 120s for sync, 1h for async
* max memory of 8GB
* do full route validation before call invocation
* ensure that idle_timeout >= timeout

we are now doing validation of updating route inside of the database
transaction, which is what we should have been doing all along really.
we need this behavior to ensure that the idle timeout is longer than the
timeout, among other benefits (like not updating the most recent version of
the existing struct and overwriting previous updates, yay). since we have
this, we can get rid of the weird skipZero behavior on validate too and
validate the real deal holyfield.

validating the route before making the call is handy so that we don't do weird
things like run a func that wants to use 300GB of RAM and run for 3 weeks.

closes #192
closes #344
closes #162
2017-09-21 04:04:34 -07:00
Reed Allman
b3157401e8 improve ux for ooms
closes #350
2017-09-20 17:10:42 -07:00
Reed Allman
6b7b1e3c63 Merge pull request #354 from fnproject/stats
Extend stats to report Failed calls
2017-09-22 10:50:59 -07:00
Nigel Deakin
54407f7b74 Extend stats to report Failed calls 2017-09-22 17:36:43 +01:00
Travis Reeder
deb2ae8103 Merge branch 'master' into app-yaml 2017-09-20 11:49:33 -07:00
Travis Reeder
904f288ed6 Replace FN_ROUTE with FN_PATH 2017-09-20 11:35:18 -07:00
Reed Allman
22a1b296e3 fix slot races
I'd be pretty surprised if these were happening but meh, a computer running at
capacity can make the runtime scheduler do all kinds of weird shit, so this
locks down the behavior around slot launching.

I didn't load test much as there are cries of 'wolf' running amok, and it's
late, so this could be off a little -- but I think it's about this easy.  cold
is the only one launching slots for itself, so it should always receive its
own slot (provided within time bounds). for hot we just need a way to tell the
ram token allocator that we aren't there anymore, so that somebody can close
the token (important).

If the bug still persists then it seems likely that there is another bug
around timing I'm not aware of (possible, but unlikely) or the more likely
case that it's actually taking up to the timeout to launch a container / find
a ram slot / find a free container. Otherwise, it's not related to the agent
and the http server timeouts may need fiddling with (read / write timeout),
if ruby client is failing to connect though I'm guessing that it's just that
nobody is reading the body (i.e. no function runs) and the error handling
isn't very well done, as we are replying with 504 if we hit a timeout (but if
nobody is listening, they won't get it).
2017-09-20 10:43:12 -07:00
Nigel Deakin
ae69bb37e3 Update global stats charts to show bteakdown by function 2017-09-19 15:05:37 +01:00
Travis Reeder
75e2051169 Example app structure. round 1. 2017-09-18 17:16:59 -07:00
Reed Allman
53ff665d69 not ready for spans yet in hot land 2017-09-08 05:06:35 -07:00
Reed Allman
4ce9163d99 nuke some TODO yey 2017-09-07 20:15:39 -07:00
Reed Allman
1811b4e230 make fn logger more reasonable
something still feels off with this, but i tinkered with it for a day-ish and
didn't come up with anything a whole lot better. doing a lot of the
maneuvering in the caller seemed better but it was just bloating up GetCall so
went back to having it basically like it was, but returning the limited
underlying buffer to read from so we can ship to the db.

some small changes to the LogStore interface, swapped it to take an
io.Reader instead of a string for more flexibility in the future while
essentially maintaining the same level of performance that we have now.
i'm guessing in the not so distant future we'll ship these to some s3 like
service and it would be better to stream them in than carry around a giant
string anyway. also, carrying around up to 1MB buffers in memory isn't great,
we may want to switch to file backed logs for calls, too. using io.Reader for
logs should make #279 more reasonable if/once we move to some s3-like thing,
we can stream from the log storage service direct to clients.

this fixes the span being out of whack and allows the 'right' context to be
used to upload logs (next to inserting the call). deletes the dbWriter we had,
and we just do this in call.End now (which makes sense to me at least).
removes the dupe code for making an stderr for hot / cold and simplifies the
way to get a func logger (no more 7 param methods yay).

closes #298
2017-09-07 20:15:39 -07:00
Reed Allman
1d0a63ca99 add id to all call invocation logs 2017-09-07 18:37:22 -07:00
Reed Allman
700078ccb9 bubble up some docker errors to user
currently:

* container ran out of memory (code 137)
* container exited with other code != 0
* unable to pull image (auth/404)

there may be others but this is a good start (the most common). notably, for
both hot and cold these should bubble up (if deterministic, which hub isn't
always), and these are useful for users to use in debugging why things aren't
working.

added tests to make sure that these behaviors are working.

also changed the behavior such that when the container exits we return a 502
instead of a 503, just to be able to distinguish the fact that fn is working
as expected but the container is acting funky (400 is weird here, so idk).

removed references to old IsUserVisible crap and slightly changed the
interface for RunResult for plumbing reasons (to get the error type,
specifically).

fixed an issue where if ~/.docker/config.json exists sometimes pulling images
wouldn't work deterministically (should be more inline w/ expectations now)

closes #275
2017-09-07 11:55:50 -07:00