Commit Graph

2729 Commits

Author SHA1 Message Date
Tolga Ceylan
4ccde8897e fn: lb and pure-runner with non-blocking agent (#989)
* fn: lb and pure-runner with non-blocking agent

*) Removed pure-runner capacity tracking code. This did
not play well with internal agent resource tracker.
*) In LB and runner gRPC comm, removed ACK. Now,
upon TryCall, pure-runner quickly proceeds to call
Submit. This is good since at this stage pure-runner
already has all relevant data to initiate the call.
*) Unless pure-runner emits a NACK, LB immediately
streams http body to runners.
*) For retriable requests added a CachedReader for
http.Request Body.
*) Idempotenty/retry is similar to previous code.
After initial success in Engament, after attempting
a TryCall, unless we receive NACK, we cannot retry
that call.
*) ch and naive places now wraps each TryExec with
a cancellable context to clean up gRPC contexts
quicker.

* fn: err for simpler one-time read GetBody approach

This allows for a more flexible approach since we let
users to define GetBody() to allow repetitive http body
read. In default LB case, LB executes a one-time io.ReadAll
and sets of GetBody, which is detected by RunnerCall.RequestBody().

* fn: additional check for non-nil req.body

* fn: attempt to override IO errors with ctx for TryExec

* fn: system-tests log dest

* fn: LB: EOF send handling

* fn: logging for partial IO

* fn: use buffer pool for IO storage in lb agent

* fn: pure runner should use chunks for data msgs

* fn: required config validations and pass APIErrors

* fn: additional tests and gRPC proto simplification

*) remove ACK/NACK messages as Finish message type works
OK for this purpose.
*) return resp in api tests for check for status code
*) empty body json test in api tests for lb & pure-runner

* fn: buffer adjustments

*) setRequestBody result handling correction
*) switch to bytes.Reader for read-only safety
*) io.EOF can be returned for non-nil Body in request.

* fn: clarify detection of 503 / Server Too Busy
2018-05-17 12:09:03 -07:00
CI
1083623045 fnserver: 0.3.447 release [skip ci] 0.3.447 2018-05-17 12:15:30 +00:00
Mark Godfrey
ac4e6c5a03 Replace panic on enqueue for LB agent with error. (#1004) 2018-05-17 13:05:47 +01:00
CI
0c022558a8 fnserver: 0.3.446 release [skip ci] 0.3.446 2018-05-16 21:35:13 +00:00
Tomas Knappek
f6d47fd0ed add DELETE to allowed cors methods (#1001) 2018-05-16 14:25:02 -07:00
CI
c7aaf732fe fnserver: 0.3.445 release [skip ci] 0.3.445 2018-05-16 18:55:35 +00:00
Tolga Ceylan
eab85dfab0 fn: agent MaxRequestSize limit (#998)
* fn: agent MaxRequestSize limit

Currently, LimitRequestBody() exists to install a
http request body size in http/gin server. For production
enviroments, this is expected to be used. However, in agents
we may need to verify/enforce these size limits and to be
able to assert in case of missing limits is valuable.
With this change, operators can define an agent env variable
to limit this in addition to installing Gin/Http handler.

http.MaxBytesReader is superior in some cases as it sets
http headers (Connection: close) to guard against subsequent
requests.

However, NewClampReadCloser() is superior in other cases,
where it can cleanly return an API error for this case alone
(http.MaxBytesReader() does not return a clean error type
for overflow case, which makes it difficult to use it without
peeking into its implementation.)

For lb agent, upcoming changes rely on such limits enabled
and using gin/http handler (http.MaxBytesReader) makes such
checks/safety validations difficult.

* fn: read/write clamp code adjustment

In case of overflows, opt for simple implementation
of a partial write followed by return error.
2018-05-16 11:45:57 -07:00
CI
7a64ec9db5 fnserver: 0.3.444 release [skip ci] 0.3.444 2018-05-15 18:10:16 +00:00
Reed Allman
cbe0d5e9ac add user syslog writers to app (#970)
* add user syslog writers to app

users may specify a syslog url[s] on apps now and all functions under that app
will spew their logs out to it. the docs have more information around details
there, please review those (swagger and operating/logging.md), tried to
implement to spec in some parts and improve others, open to feedback on
format though, lots of liberty there.

design decision wise, I am looking to the future and ignoring cold containers.
the overhead of the connections there will not be worth it, so this feature
only works for hot functions, since we're killing cold anyway (even if a user
can just straight up exit a hot container).

syslog connections will be opened against a container when it starts up, and
then the call id that is logged gets swapped out for each call that goes
through the container, this cuts down on the cost of opening/closing
connections significantly. there are buffers to accumulate logs until we get a
`\n` to actually write a syslog line, and a buffer to save some bytes when
we're writing the syslog formatting as well. underneath writers re-use the
line writer in certain scenarios (swapper). we could likely improve the ease
of setting this up, but opening the syslog conns against a container seems
worth it, and is a different path than the other func loggers that we create
when we make a call object. the Close() stuff is a little tricky, not sure how
to make it easier and have the ^ benefits, open to idears.

this does add another vector of 'limits' to consider for more strict service
operators. one being how many syslog urls can a user add to an app (infinite,
atm) and the other being on the order of number of containers per host we
could run out of connections in certain scenarios. there may be some utility
in having multiple syslog sinks to send to, it could help with debugging at
times to send to another destination or if a user is a client w/ someone and
both want the function logs, e.g. (have used this for that in the past,
specifically).

this also doesn't work behind a proxy, which is something i'm open to fixing,
but afaict will require a 3rd party dependency (we can pretty much steal what
docker does). this is mostly of utility for those of us that work behind a
proxy all the time, not really for end users.

there are some unit tests. integration tests for this don't sound very fun to
maintain. I did test against papertrail with each protocol and it works (and
even times out if you're behind a proxy!).

closes #337

* add trace to syslog dial
2018-05-15 11:00:26 -07:00
CI
e269f965a4 fnserver: 0.3.443 release [skip ci] 0.3.443 2018-05-15 17:13:40 +00:00
Tomas Knappek
19f09b3a6c Added FN_API_CORS_HEADERS for configuring CORS headers (#997) 2018-05-15 18:03:01 +01:00
CI
37354838b4 fnserver: 0.3.442 release [skip ci] 0.3.442 2018-05-11 21:44:50 +00:00
Tolga Ceylan
cba3fc14e7 fn: rename vars for clarity (#992) 2018-05-11 14:35:13 -07:00
Tolga Ceylan
6226f54f58 fn: docker compose fixups (#985)
* fn: docker compose fixups

1) FN_DOCKER_NETWORKS for fnserver to place the functions in
2) mysql should be in sync with test.sh/api_test.sh mysql version to avoid errors such as
    msg="couldn't ping db" error="this authentication plugin is not supported" url="root:root@tcp(db:3306)/funcs

TODO: fix/investigate why fnserver fails on latest mysql.

* fn: docker-compose network should be explicit
2018-05-10 11:14:18 -07:00
CI
1c2740819b fnserver: 0.3.441 release [skip ci] 0.3.441 2018-05-10 15:17:45 +00:00
Tolga Ceylan
8e440c835e fn: fixup undeterministic test (#986) 2018-05-10 08:08:10 -07:00
CI
f2be72a266 fnserver: 0.3.440 release [skip ci] 0.3.440 2018-05-10 14:55:49 +00:00
Tolga Ceylan
860e306580 fn: system tests should default to hot/json (#983) 2018-05-10 07:45:04 -07:00
CI
0e781d3859 fnserver: 0.3.439 release [skip ci] 0.3.439 2018-05-10 02:32:08 +00:00
Tolga Ceylan
508d9e18c7 fn: nonblocking resource manager tests (#987) 2018-05-09 19:23:10 -07:00
CI
f6bca655df fnserver: 0.3.438 release [skip ci] 0.3.438 2018-05-09 22:03:15 +00:00
Tolga Ceylan
a69a930eb8 fn: doc update for FN_DOCKER_NETWORKS (#984) 2018-05-09 14:53:01 -07:00
CI
85681e6413 fnserver: 0.3.437 release [skip ci] 0.3.437 2018-05-09 19:34:08 +00:00
Tolga Ceylan
0f50537150 fn: allow specified docker networks in functions (#982)
* fn: allow specified docker networks in functions

If FN_DOCKER_NETWORK is specified with a list of
networks, then agent driver picks the least used
network to place functions on.

* add mutex comment
2018-05-09 12:24:15 -07:00
CI
1c00782a6c fnserver: 0.3.436 release [skip ci] 0.3.436 2018-05-09 15:58:38 +00:00
Tolga Ceylan
676c87f9a5 fn: pure-runner violates io Writer contract (#981)
We must copy the data slice.
2018-05-09 16:48:55 +01:00
CI
6cabd7e8bf fnserver: 0.3.435 release [skip ci] 0.3.435 2018-05-09 14:15:16 +00:00
jan grant
91e58afa55 The opencensus API changes between 0.6.0 and 0.9.0 (#980)
We get some useful features in later versions; update so as to not
pin downstream consumers (extensions) to an older version.
2018-05-09 14:55:00 +01:00
CI
feab2f0e0f fnserver: 0.3.434 release [skip ci] 0.3.434 2018-05-09 13:08:12 +00:00
Travis Reeder
999820d15b Moves main into cmd dir. (#977) 2018-05-09 10:52:52 +03:00
CI
b81ac1d2d2 fnserver: 0.3.433 release [skip ci] 0.3.433 2018-05-08 05:32:26 +00:00
Reed Allman
1f1624782b related: https://github.com/fnproject/fdk-go/pull/26 (#968)
adds a test for the protocol dumping of a request to the containert stdin.
there are a number of vectors to test for a cloud event, but since we're going
to change that behavior soon it's probably a waste of time to go about doing
so. in any event, this was pretty broken. my understanding of the cloud event
spec is deepening and the json stuff overall seems a little weird.

* fixes content type issue around json checking (since a string is also a json
value, we can just decode it, even though it's wasteful it's more easily
correct)
* doesn't force all json values to be map[string]interface{} and lets them be
whoever they want to be. maybe their dads are still proud.

closes #966
2018-05-07 22:22:53 -07:00
CI
fe2c3daee3 fnserver: 0.3.432 release [skip ci] 0.3.432 2018-05-07 19:00:30 +00:00
Tolga Ceylan
f0f9a6d945 fn: LB ch and naive fixes (#942)
* fn: LB ch and naive fixes

*) Naive is now a naive RR algorithm.
*) Both now checks for ctx/timeout in each attempt.

* fn: test fix
2018-05-07 11:50:16 -07:00
CI
878524ea6c fnserver: 0.3.431 release [skip ci] 0.3.431 2018-05-07 18:20:46 +00:00
Denis Makogon
7ee47f13bb Expose Agent (#892)
with server.Agent developers can access more transport-agnostic API to call the functions
2018-05-07 11:10:23 -07:00
Chad Arimura
aa2dbf80e9 tutorials link (#875) 2018-05-07 10:58:36 -07:00
CI
f155098a5b fnserver: 0.3.430 release [skip ci] 0.3.430 2018-05-04 17:40:14 +00:00
Reed Allman
9d721f8327 remove flaky tests (#972)
if we want them back, we can dig them out of git instead of some poor soul
uncommenting them 10 years from now and spending 3 months on failing CI builds
trying to figure out how a test that breaks doesn't mean the code's broke.

these tests are notoriously flaky and hard to understand/fix, they also test
very specific agent behaviors all the way through the front end when it may be
easier to test them in unit tests instead (should we so choose). at least,
since the behaviors tested aren't being changed very often, these are only
serving to provide negative value in time wasted re-running the test suite
[since them failing doesn't really indicate the code being wrong].

the `IOPipes` test is partially covered by `TestPipesAreClear` which hasn't
cropped up as being as flaky, but it tests less behaviors. it is not easy tt o
understand, either. while i think we learned a lot from these tests, they
haven't been a great citizen of our test suite at large, i figure if we need
to change runner behavior in the future we can maybe make another go at it.
2018-05-04 10:30:49 -07:00
CI
7f1b721602 fnserver: 0.3.429 release [skip ci] 0.3.429 2018-05-03 20:02:56 +00:00
Reed Allman
7607c003cf improve private auth docs a little (#971) 2018-05-03 12:52:58 -07:00
CI
e3e4c061d4 fnserver: 0.3.428 release [skip ci] 0.3.428 2018-04-30 20:22:54 +00:00
Srinidhi Chokkadi Puranik
e0b82519aa Last middleware should use the request passed by preceding middleware. (#965)
This is useful when preceding middleware reads httpRequest.Body to
perform some logic, and assigns a new ReadCloser to httpRequest.Body
(as body can be read only once).
2018-04-30 13:13:24 -07:00
CI
1124c014ec fnserver: 0.3.427 release [skip ci] 0.3.427 2018-04-25 05:09:49 +00:00
Tolga Ceylan
54ba49be65 fn: non-blocking resource tracker and notification (#841)
* fn: non-blocking resource tracker and notification

For some types of errors, we might want to notify
the actual caller if the error is directly 1-1 tied
to that request. If hotLauncher is triggered with
signaller, then here we send a back communication
error notification channel. This is passed to
checkLaunch to send back synchronous responses
to the caller that initiated this hot container
launch.

This is useful if we want to run the agent in
quick fail mode, where instead of waiting for
CPU/Mem to become available, we prefer to fail
quick in order not to hold up the caller.
To support this, non-blocking resource tracker
option/functions are now available.

* fn: test env var rename tweak

* fn: fixup merge

* fn: rebase test fix

* fn: merge fixup

* fn: test tweak down to 70MB for 128MB total

* fn: refactor token creation and use broadcast regardless

* fn: nb description

* fn: bugfix
2018-04-24 21:59:33 -07:00
CI
51197d4985 fnserver: 0.3.426 release [skip ci] 0.3.426 2018-04-24 18:25:24 +00:00
Travis Reeder
977976fa52 Update cloudevents.md 2018-04-24 11:15:01 -07:00
CI
da58c857eb fnserver: 0.3.425 release [skip ci] 0.3.425 2018-04-24 16:34:59 +00:00
Owen Cliffe
1918d87842 make annotations nullable to fix migration (#917)
make app.annotations  and routes.annotations non-null  always

This resolves a schema ambiguity that arrose in the annotations layer that would result in different schemas depending on whether you started afresh or migrated up.
2018-04-24 17:07:15 +01:00
CI
45383d94d3 fnserver: 0.3.424 release [skip ci] 0.3.424 2018-04-23 23:15:01 +00:00