Commit Graph

2742 Commits

Author SHA1 Message Date
CI
d7188c792a fnserver: 0.3.409 release [skip ci] 0.3.409 2018-04-05 22:15:51 +00:00
Tolga Ceylan
584e4e75eb Experimental Pre-fork Pool: Recycle net ns (#890)
* fn: experimental prefork recycle and other improvements

*) Recycle and do not use same pool container again option.
*) Two state processing: initializing versus ready (start-kill).
*) Ready state is exempt from rate limiter.

* fn: experimental prefork pool multiple network support

In order to exceed 1023 container (bridge port) limit, add
multiple networks:

    for i in fn-net1 fn-net2 fn-net3 fn-net4
    do
            docker network create $i
    done

to Docker startup, (eg. dind preentry.sh), then provide this
to prefork pool using:

    export FN_EXPERIMENTAL_PREFORK_NETWORKS="fn-net1 fn-net2 fn-net3 fn-net4"

which should be able to spawn 1023 * 4 containers.

* fn: fixup tests for cfg move

* fn: add ipc and pid namespaces into prefork pooling

* fn: revert ipc and pid namespaces for now

Pid/Ipc opens up the function container to pause container.
2018-04-05 15:07:30 -07:00
CI
629559ecc8 fnserver: 0.3.408 release [skip ci] 0.3.408 2018-04-05 21:51:59 +00:00
Tolga Ceylan
81954bcf53 fn: perform call.End() after request is processed (#918)
* fn: perform call.End() after request is processed

call.End() performs several tasks in sequence; insert call,
insert log, (todo) remove mq entry, fireAfterCall callback, etc.
These currently add up to the request latency as return
from agent.Submit() is blocked on these. We also haven't been
able to apply any timeouts on these operations since they are
handled during request processing and it is hard to come up
with a strategy for it. Also the error cases
(couldn't insert call or log) are not propagated to the caller.

With this change, call.End() handling becomes asynchronous where
we perform these tasks after the request is done. This improves
latency and we no longer have to block the call on these operations.
The changes will also free up the agent slot token more quickly
and now we are no longer tied to hiccups in call.End().

Now, a timeout policy is also added to this which can
be adjusted with an env variable. (default 10 minutes)

This accentuates the fact that call/log/fireAfterCall are not
completed when request is done. So, there's a window there where
call is done, but call/log/fireAfterCall are not yet propagated.
This was already the case especially for error cases.

There's slight risk of accumulating call.End() operations in
case of hiccups in these log/call/callback systems.

* fn: address risk of overstacking of call.End() calls.
2018-04-05 14:42:12 -07:00
CI
82bf532fa7 fnserver: 0.3.407 release [skip ci] 0.3.407 2018-04-05 17:56:56 +00:00
Reed Allman
56a2861748 move calls to logstore, implement s3 (#911)
* move calls to logstore, implement s3

closes #482

the basic motivation is that logs and calls will be stored with a very high
write rate, while apps and routes will be relatively infrequently updated; it
follows that we should likely split up their storage location, to back them
with appropriate storage facilities. s3 is a good candidate for ingesting
higher write rate data than a sql database, and will make it easier to manage
that data set. can read #482 for more detailed justification.

summary:

* calls api moved from datastore to logstore
* logstore used in front-end to serve calls endpoints
* agent now throws calls into logstore instead of datastore
* s3 implementation of calls api for logstore
* s3 logs key changed (nobody using / nbd?)
* removed UpdateCall api (not in use)
* moved call tests from datastore to logstore tests
* mock logstore now tested (prev. sqlite3 only)
* logstore tests run against every datastore (mysql, pg; prev. only sqlite3)
* simplify NewMock in tests

commentary:

brunt of the work is implementing the listing of calls in GetCalls for the s3
logstore implementation. the GetCalls API requires returning items in the
newest to oldest order, and the s3 api lists items in lexicographic order
based on created_at. An easy thing to do here seemed to be to reverse the
encoding of our id format to return a lexicographically descending order,
since ids are time based, reasonably encoded to be lexicographically
sortable, and de-duped (unlike created_at). This seems to work pretty well,
it's not perfect around the boundaries of to_time and from_time and a tiny
amount of results may be omitted, but to me this doesn't seem like a deal
breaker to get 6999 results instead of 7000 when trying to get calls between
3:00pm and 4:00pm Monday 3 weeks ago. Of course, without to_time and
from_time, there are no issues in listing results. We could use created at and
encode it, but it would be an additional marker for point lookup (GetCall)
since we would have to search for a created_at stamp, search for ids around
that until we find the matching one, just to do a point lookup. So, the
tradeoff here seems worth it. There is additional optimization around to_time
to seek over newer results (since we have descending order).

The other complication in GetCalls is returning a list of calls for a given
path. Since the keys to do point lookups are only app_id + call_id, and we
need listing across an app as well, this leads us to the 'marker' collection
which is sorted by app_id + path + call_id, to allow quick listing by path.
All in all, it should be pretty straightforward to follow the implementation
and I tried to be lavish with the comments, please let me know if anything
needs further clarification in the code.

The implementation itself has some glaring inefficiencies, but they're
relatively minute: json encoding is kinda lazy, but workable; s3 doesn't offer
batch retrieval, so we point look up each call one by one in get call; not
re-using buffers -- but the seeking around the keys should all be relatively
fast, not too worried about performance really and this isn't a hot path for
reads (need to make a cut point and turn this in!).

Interestingly, in testing, minio performs significantly worse than pg for
storing both logs and calls (or just logs, I tested that too). minio seems to
have really high cpu consumption, but in any event, we won't be using minio,
we'll be using a cloud object store that implements the s3 api. Anyway, mostly
a knock on using minio for high performance, not really anything to do with
this, just thought it was interesting.

I think it's safe to remove UpdateCall, admittedly this made implementing the
s3 api a lot easier. This operation may also be something we never need, it
was unused at present and was only in the cards for a previous hybrid
implementation, which we've now abandoned. If we need, we can always resurrect
from git.

Also not worried about changing the log key, we need to put a prefix on this
thing anyway, but I don't think anybody is using this anyway. in any event, it
simply means old logs won't show up through the API, but aside from nobody
using this yet, that doesn't seem a big deal breaker really -- new logs will
appear fine.

future:

TODO make logstore implementation optional for datastore, check in front-end
at runtime and offer a nil logstore that errors appropriately

TODO low hanging fruit optimizations of json encoding, re-using buffers for
download, get multiple calls at a time, id reverse encoding could be optimized
like normal encoding to not be n^2

TODO api for range removal of logs and calls

* address review comments

* push id to_time magic into id package
* add note about s3 key sizes
* fix validation check
2018-04-05 10:49:25 -07:00
CI
6ca002973d fnserver: 0.3.406 release [skip ci] 0.3.406 2018-04-04 23:51:02 +00:00
Tolga Ceylan
c58caee78d fn: update minimum docker version required. (#916)
Oracle Linux 7.4 backported versions still having issues
with freezing/terminating containers. 17.10.0-ce seems like
a resonable lowest common denominator.
2018-04-04 16:43:30 -07:00
Reed Allman
f635359ff8 loosen perms on bolt mq (#910)
the bolt mq file should only be used for local dev and isn't necessarily
sensitive, don't think 0655 restriction was necessary and the data isn't
likely all that sensitive anyway.

see https://github.com/fnproject/fn/issues/404#issuecomment-377570626
2018-04-04 15:41:37 -07:00
CI
c96f4c5a5d fnserver: 0.3.405 release [skip ci] 0.3.405 2018-04-03 18:31:37 +00:00
Reed Allman
3a2550d042 change slots when annotations change (#914)
when the annotations change, we need to get a different slot key to launch new
containers with these annotations and let the old containers die off unused.

I started on a test for this, but changing all combinations of each field in
isolation to change is not very fun without reflection, and there's still a
subset of fields we're managing, so it put us in about the same spot as we are
now.
2018-04-03 11:21:56 -07:00
CI
1b0a9e2276 fnserver: 0.3.404 release [skip ci] 0.3.404 2018-04-03 16:00:55 +00:00
jan grant
9633cf022b Bugfix: unsafeBytes slices were getting GCed (#913)
There are alternative formulations of this, for instance see
	https://www.reddit.com/r/golang/comments/5zctpf/unsafe_conversion_between_strings_and_byte_slices/

The problem manifested in the returned values from unsafeBytes occasionally
being broken. It's possible that by keeping a reference to the `a` parameter
alive, the original code would still work - however, this definitely seems like
a fix.

(A cast to `[]byte(a)` looks increasingly attractive, for all that it'll
perform small allocations and copies.)
2018-04-03 16:53:02 +01:00
CI
28edd1779f fnserver: 0.3.403 release [skip ci] 0.3.403 2018-04-03 14:12:57 +00:00
jan grant
88074a42c0 Bugfix/grpc consume eof (#912)
* GRPC streams end with an EOF

The client should ensure that the final packet is followed by a GRPC
EOF. This has the benefit of permitting the client code to clean up resources.

* Don't require an entire HTTP request in RunnerCall

TryExec needs a handle on an incoming ReadCloser containing the body
of a request; however, everything else will already have been extracted
from the HTTP request in the case of lbAgent use.

(The point of this change is to simplify the interface for other uses.)

* Return error from GRPC layer explicitly

As per review
2018-04-03 15:04:21 +01:00
CI
3c536d1e01 fnserver: 0.3.402 release [skip ci] 0.3.402 2018-03-30 16:50:16 +00:00
Andrea Rosa
72a2eb933f Returning Agent on exported func for pureRunner (#905)
pureRunner is a not exported struct and it was set as return value for
few exported method, in this change we return Agent which is the
interface implemented by pureRunner to avoid to leak an unexprted type.
2018-03-30 09:15:55 -07:00
Justin Ko
2e0a22a3e0 Make sure to rebuild protobuf files during build (#908)
I noticed that the Makefile rule to build protobuf files was listing a
non-existent file and that the protobuf files were not getting rebuilt
during builds.
2018-03-30 12:56:28 +01:00
CI
372b046dd7 fnserver: 0.3.401 release [skip ci] 0.3.401 2018-03-29 23:59:00 +00:00
Owen Strain
f03d1c294a Fix to correctly deserialize JSON null value for Route.CPUs (#909) 2018-03-29 16:38:51 -07:00
CI
4b3cd28cb9 fnserver: 0.3.400 release [skip ci] 0.3.400 2018-03-29 17:06:46 +00:00
Andrea Rosa
a1d2b34f8f Change port for local registry (#906)
In one of the test we want a failure due to a 500 error returned by a
not existing local registry, the fake server address is set to localhost:5000
In a typical local env is quite likely to have a local registry running
and the default address usually is localhost:5000 and that will make the
test to return a 4xx error and not the expected 500 error, this change
just set a not standard port for the fake local registry to reduce the
chances to clash with an existing running one.
2018-03-29 09:57:16 -07:00
CI
8092ea7b29 fnserver: 0.3.399 release [skip ci] 0.3.399 2018-03-28 21:48:54 +00:00
Tolga Ceylan
369f2ea17c fn: experimental prefork tests should skip non Linux OSs (#904) 2018-03-28 14:40:51 -07:00
CI
b7e7fb2460 fnserver: 0.3.398 release [skip ci] 0.3.398 2018-03-28 19:43:52 +00:00
Justin Ko
9cb883ca68 Godoc fixes (#898)
Add some godoc comments for the api/agent package and some of its
subpackages.
2018-03-28 10:16:40 -07:00
CI
14af8805de fnserver: 0.3.397 release [skip ci] 0.3.397 2018-03-28 13:06:33 +00:00
Gerardo Viedma
348bbaf36b support runner TLS certificates with specified certificate Common Names (#900)
* support runner TLS certificates with specified certificate Common Names

* removes duplicate constant

* run in insecure mode by default but expose ability to create tls-secured runner pools programmatically

* fixes runner tests to use new tls interfaces
2018-03-28 13:57:15 +01:00
CI
966890ac8f fnserver: 0.3.396 release [skip ci] 0.3.396 2018-03-27 18:37:30 +00:00
Denis Makogon
fe0763825b Fix SQL UP migration (#895) 2018-03-27 11:28:03 -07:00
CI
4537a5eb91 fnserver: 0.3.395 release [skip ci] 0.3.395 2018-03-27 14:42:23 +00:00
Tolga Ceylan
09bfa41da5 fn: file system 'size' option documentation (#889) 2018-03-26 21:30:39 -07:00
CI
ae191628f2 fnserver: 0.3.394 release [skip ci] 0.3.394 2018-03-26 22:52:31 +00:00
Reed Allman
8af605cf3d update thrift, opencensus, others (#893)
* update thrift, opencensus, others

* stats: update to opencensus 0.6.0 view api
2018-03-26 15:43:49 -07:00
CI
0ce5c4500b fnserver: 0.3.393 release [skip ci] 0.3.393 2018-03-26 21:40:53 +00:00
Owen Strain
074e17c83f Log the actual error when gRPC connect/handshake fails (#891) 2018-03-26 14:33:01 -07:00
Reed Allman
a567b88370 dep: lock opencensus to commit (#888)
0.4.0 is too low, no prometheus registry specification.
0.6.0 jaeger is broken. filing ticket w/ them.

closes #886
2018-03-26 12:32:27 -07:00
CI
ef6549b639 fnserver: 0.3.392 release [skip ci] 0.3.392 2018-03-26 18:29:14 +00:00
Denis Makogon
3c15ca6ea6 App ID (#641)
* App ID

* Clean-up

* Use ID or name to reference apps

* Can use app by name or ID

* Get rid of AppName for routes API and model

 routes API is completely backwards-compatible
 routes API accepts both app ID and name

* Get rid of AppName from calls API and model

* Fixing tests

* Get rid of AppName from logs API and model

* Restrict API to work with app names only

* Addressing review comments

* Fix for hybrid mode

* Fix rebase problems

* Addressing review comments

* Addressing review comments pt.2

* Fixing test issue

* Addressing review comments pt.3

* Updated docstring

* Adjust UpdateApp SQL implementation to work with app IDs instead of names

* Fixing tests

* fmt after rebase

* Make tests green again!

* Use GetAppByID wherever it is necessary

 - adding new v2 endpoints to keep hybrid api/runner mode working
 - extract CallBase from Call object to expose that to a user
   (it doesn't include any app reference, as we do for all other API objects)

* Get rid of GetAppByName

* Adjusting server router setup

* Make hybrid work again

* Fix datastore tests

* Fixing tests

* Do not ignore app_id

* Resolve issues after rebase

* Updating test to make it work as it was

* Tabula rasa for migrations

* Adding calls API test

 - we need to ensure we give "App not found" for the missing app and missing call in first place
 - making previous test work (request missing call for the existing app)

* Make datastore tests work fine with correctly applied migrations

* Make CallFunction middleware work again

 had to adjust its implementation to set app ID before proceeding

* The biggest rebase ever made

* Fix 8's migration

* Fix tests

* Fix hybrid client

* Fix tests problem

* Increment app ID migration version

* Fixing TestAppUpdate

* Fix rebase issues

* Addressing review comments

* Renew vendor

* Updated swagger doc per recommendations
2018-03-26 11:19:36 -07:00
CI
4e90844a67 fnserver: 0.3.391 release [skip ci] 0.3.391 2018-03-26 17:34:42 +00:00
Denis Makogon
6393cf6777 API extensions: Route listerens (#887) 2018-03-26 10:25:13 -07:00
CI
7810b3cb9b fnserver: 0.3.390 release [skip ci] 0.3.390 2018-03-23 23:44:15 +00:00
Tolga Ceylan
0addcb8911 fn: pre-fork pool for namespace/network speedup (#874)
* fn: pre-fork pool experimental implementation
2018-03-23 16:35:35 -07:00
CI
0da7d9fcda fnserver: 0.3.389 release [skip ci] 0.3.389 2018-03-23 10:37:14 +00:00
Gerardo Viedma
101236f7d8 Remove npm remnants (#882)
* create an Annotation map of the right size to avoid resizing

* removes all references to deprecated nodepool manager
2018-03-23 10:29:32 +00:00
Gerardo Viedma
0c47dbf26d create an Annotation map of the right size to avoid resizing (#881) 2018-03-23 10:29:07 +00:00
CI
6db99f6ecc fnserver: 0.3.388 release [skip ci] 0.3.388 2018-03-22 20:16:08 +00:00
Dario Domizioli
8df8ed6360 Expose route and app models to RunnerCall for extensions (alternative 2) (#880) 2018-03-22 20:07:39 +00:00
CI
563a4576ef fnserver: 0.3.387 release [skip ci] 0.3.387 2018-03-21 23:08:50 +00:00
Reed Allman
b9ff601098 fix machine id to 48 bits, add test (#877)
another bone head fail here. hopefully can leave this alone meow...

newID does not get inlined, but doesn't allocate to trigger any stack
expansion either. net perf hit on my laptop is 5ns, and we get a test out of
it. it will push a new stack, so it's not negligible overhead and we could
avoid it. we could keep the logic in both places just to have a test for it
separate instead of re-using the function in the hot path. up to us.
2018-03-21 16:01:18 -07:00