Commit Graph

195 Commits

Author SHA1 Message Date
Reed Allman
2d8c528b48 S3 loggyloo (#511)
* add minio-go dep, update deps

* add minio s3 client

minio has an s3 compatible api and is an open source project and, notably, is
not amazon, so it seems best to use their client (fwiw the aws-sdk-go is a
giant hair ball of things we don't need, too). it was pretty easy and seems
to work, so rolling with it. also, minio is a totally feasible option for fn
installs in prod / for demos / for local.

* adds 's3' package for s3 compatible log storage api, for use with storing
logs from calls and retrieving them.
* removes DELETE /v1/apps/:app/calls/:call/log endpoint
* removes internal log deletion api
* changes the GetLog API to use an io.Reader, which is a backwards step atm
due to the json api for logs, I have another branch lined up to make a plain
text log API and this will be much more efficient (also want to gzip)
* hooked up minio to the test suite and fixed up the test suite
* add how to run minio docs and point fn at it docs

some notes: notably we aren't cleaning up these logs. there is a ticket
already to make a Mr. Clean who wakes up periodically and nukes old stuff, so
am punting any api design around some kind of TTL deletion of logs. there are
a lot of options really for Mr. Clean, we can notably defer to him when apps
are deleted, too, so that app deletion is fast and then Mr. Clean will just
clean them up later (seems like a good option).

have not tested against BMC object store, which has an s3 compatible API. but
in theory it 'just works' (the reason for doing this). in any event, that's
part of the service land to figure out.

closes #481
closes #473

* add log not found error to minio land
2017-11-20 17:39:45 -08:00
Travis Reeder
ab18e467fa updates functions -> fnserver (#516)
* updates functions -> fn-server and fnlb -> fn-lb

* changed to fnserver and fnlb
2017-11-17 15:53:44 -08:00
Nigel Deakin
910612d0b1 Docker stats to Prometheus (#486)
* Docker stats to Prometheus

* Fix compilation error in docker_test

* Refactor docker driver Run function to wait for  the container to have stopped before stopping the colleciton of statistics

* Fix go fmt errors

* Updates to sending docker stats to Prometheus

* remove new test TestWritResultImpl because we changes to support multiple waiters have been removed

* Update docker.Run to use channels not contextrs to shut down stats collector
2017-11-16 11:02:33 -08:00
Travis Reeder
96cfc9f5c1 Update json (#463)
* wip

* wip

* Added more fields to JSON and added blank line between objects.

* Update tests.

* wip

* Updated to represent recent discussions.

* Fixed up the json test

* More docs

* Changed from blank line to bracket, newline, open bracket.

* Blank line added back, easier for delimiting.
2017-11-16 09:59:13 -08:00
Derek Schultz
c281f96486 K8s docs update (#499)
* split fn-ui to its own service

* add fn namespace

* update path

* add namespace flag for kubectl

* simplify grabbing minikube IP and port

* typo: FUNCTIONS -> API_URL
2017-11-16 10:45:25 -07:00
Travis Reeder
d30732e5b8 image was in wrong place. 2017-11-15 08:29:10 -08:00
Reed Allman
61b416a9b5 automagic sql db migrations (#461)
* adds migrations

closes #57

migrations only run if the database is not brand new. brand new
databases will contain all the right fields when CREATE TABLE is called,
this is for readability mostly more than efficiency (do not want to have
to go through all of the database migrations to ascertain what columns a table
has). upon startup of a new database, the migrations will be analyzed and the
highest version set, so that future migrations will be run. this should also
avoid running through all the migrations, which could bork db's easily enough
(if the user just exits from impatience, say).

otherwise, all migrations that a db has not yet seen will be run against it
upon startup, this should be seamless to the user whether they had a db that
had 0 migrations run on it before or N. this means users will not have to
explicitly run any migrations on their dbs nor see any errors when we upgrade
the db (so long as things go well). if migrations do not go so well, users
will have to manually repair dbs (this is the intention of the `migrate`
library and it seems sane), this should be rare, and I'm unsure myself how
best to resolve not having gone through this myself, I would assume it will
require running down migrations and then manually updating the migration
field; in any case, docs once one of us has to go through this.

migrations are written to files and checked into version control, and then use
go-bindata to generate those files into go code and compiled in to be consumed
by the migrate library (so that we don't have to put migration files on any
servers) -- this is also in vcs. this seems to work ok. I don't like having to
use the separate go-bindata tool but it wasn't really hard to install and then
go generate takes care of the args. adding migrations should be relatively
rare anyway, but tried to make it pretty painless.

1 migration to add created_at to the route is done here as an example of how
to do migrations, as well as testing these things ;) -- `created_at` will be
`0001-01-01T00:00:00.000Z` for any existing routes after a user runs this
version. could spend the extra time adding 'today's date to any outstanding
records, but that's not really accurate, the main thing is nobody will have to
nuke their db with the migrations in place & we don't have any prod clusters
really to worry about. all future routes will correctly have `created_at` set,
and plan to add other timestamps but wanted to keep this patch as small as
possible so only did routes.created_at.

there are tests that a spankin new db will work as expected as well as a db
after running all down & up migrations works. the latter tests only run on mysql
and postgres, since sqlite3 does not like ALTER TABLE DROP COLUMN; up
migrations will need to be tested manually for sqlite3 only, but in theory if
they are simple and work on postgres and mysql, there is a good likelihood of
success; the new migration from this patch works on sqlite3 fine.

for now, we need to use `github.com/rdallman/migrate` to move forward, as
getting integrated into upstream is proving difficult due to
`github.com/go-sql-driver/mysql` being broken on master (yay dependencies).
Fortunately for us, we vendor a version of the `mysql` bindings that actually
works, thus, we are capable of using the `mattes/migrate` library with success
due to that. this also will require go1.9 to use the new `database/sql.Conn`
type, CI has been updated accordingly.

some doc fixes too from testing.. and of course updated all deps.

anyway, whew. this should let us add fields to the db without busting
everybody's dbs. open to feedback on better ways, but this was overall pretty
simple despite futzing with mysql.

* add migrate pkg to deps, update deps

use rdallman/migrate until we resolve in mattes land

* add README in migrations package

* add ref to mattes lib
2017-11-14 12:54:33 -08:00
Chad Arimura
cb0ff466a0 small changes 2017-11-13 09:39:24 -08:00
Chad Arimura
5822072bbd few small changes 2017-11-13 09:35:43 -08:00
Travis Reeder
42e8bf1601 Replace arch diagram. 2017-11-13 09:13:21 -08:00
Travis Reeder
6c21103057 Rollback dockerfile (image too big) and add docker run command to docs. (#488) 2017-11-09 16:12:45 +01:00
Derek Schultz
21e42658b3 remove link to outdated swarm doc 2017-11-02 16:18:03 -06:00
Reed Allman
ce252d0448 Merge pull request #424 from fnproject/call-listener
CallListener - replaces RunnerListener
2017-10-26 10:36:14 -07:00
Travis Reeder
633b26594e minor 2017-10-25 14:13:26 +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
0ddb750eaa Send serve_http spans to Prometheus as well. Revamp Grafana dashboard. 2017-10-25 12:58:08 +01:00
Nigel Deakin
7e88d996a5 Export tracing spans to Prometheus 2017-10-20 18:28:42 +01:00
Nigel Deakin
39feaf8b69 Send tracing spans to Prometheus 2017-10-20 16:30:19 +01:00
Denis Makogon
2888606b96 [WIP] Bump swagger spec version 2017-10-19 22:50:44 +03:00
Denis Makogon
511b8e8a88 Bump API doc version 2017-10-19 22:15:13 +03:00
Reed Allman
249b4e1cc1 Merge pull request #440 from fnproject/filter-calls-by-route
Fixing swagger-doc
2017-10-19 11:26:33 -07:00
Denis Makogon
42cd618145 fixing swagger-doc 2017-10-19 19:20:19 +03:00
Travis Reeder
7e5919432e Update clients.md 2017-10-19 13:43:59 +02:00
Owain Lewis
aab98ba59f Fix typo on function-format.md 2017-10-11 16:46:07 +01:00
Denis Makogon
e8dfb04cb1 Adding fdk-python link (#413) 2017-10-10 07:25:20 -07: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
Reed Allman
a4de984f79 add fdk-go to main docs (#412)
* add fdk-go to main docs

* add note about using fdk-go to hot example
2017-10-09 14:43:28 -07:00
Denis Makogon
d3314fa894 Input --> I/O 2017-10-07 03:04:56 +03:00
Denis Makogon
e4684096f7 Fmt and docs 2017-10-07 02:59:08 +03:00
Denis Makogon
5e9bf0d708 Fixing doc 2017-10-07 02:32:42 +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
11e5c80b4f Fixing docs 2017-10-07 01:04:42 +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
Chris Helgert
f511cd27ed fix url in client libraries for java language wrapper (#398) 2017-10-06 13:37:29 +03:00
Aurélien Pupier
f1d82fccaf Fix typo balanacer --> balancer (#384) 2017-10-06 12:29:24 +03:00
Nigel Deakin
99bbe834bd Add screenshot 2017-10-05 17:19:42 +01:00
Travis Reeder
b520567a4c Update apps.md 2017-10-03 17:31:50 -07:00
Matthew Hartman
d0ea620add Correct header 2017-10-03 06:30:52 -04:00
James Jeffrey
c7f3066c75 Update references remove refs to treeder oracle funcy (#376)
* Remove lots of refs to iron and funcy oracle etc..

* more ref replacements

* Replacing more refs. Treeder

* Use Fn not FN
2017-09-29 16:22:15 -07:00
Travis Reeder
5219227393 Updated docs on configuration and required env vars. (#285)
* Updated docs on configuration and required env vars.

* minor
2017-09-29 16:20:46 -07:00
Chad Arimura
45fc86aac7 Merge pull request #372 from fnproject/docs-k8s
update docs for running Fn on k8s
2017-09-29 07:11:46 -07:00
Nigel Deakin
d89c2ada4d Add README for hotfunctions go example and update docs to point to it 2017-09-29 12:13:08 +01:00
Nigel Deakin
1fb9c48867 Add README for hotfunctions go example and update docs to point to it 2017-09-29 12:12:16 +01:00
Nigel Deakin
82d0bcf34a Add README for hotfunctions go example and update docs to point to it 2017-09-29 12:10:53 +01:00
Nigel Deakin
16cdd98a62 Add README for hotfunctions go example and update docs to point to it 2017-09-29 12:01:29 +01:00
Derek Schultz
b9bcb70f51 missed a setting 2017-09-28 13:04:08 -06:00
Derek Schultz
232069cbca updates docs for running fn on k8s
- removes docker swarm doc
2017-09-28 12:59:21 -06:00
Derek Schultz
2f090d0aab remove docker swarm howto 2017-09-28 10:44:16 -06:00
Reed Allman
337e962416 add pagination to all list endpoints
calls, apps, and routes listing were previously returning the entire data set,
which just won't scale. this adds pagination with cursoring forward to each of
these endpoints (see the [docs](docs/definitions.md)).

the patch is really mostly tests, shouldn't be that bad to pick through.

some blarble about implementation is in order:

calls are sorted by ids but allow searching within certain `created_at` ranges
(finally). this is because sorting by `created_at` isn't feasible when
combined with paging, as `created_at` is not guaranteed to be unique -- id's
are (eliding theoreticals). i.e. on a page boundary, if there are 200 calls
with the same `created_at`, providing a `cursor` of that `created_at` will
skip over the remaining N calls with that `created_at`.  also using id will be
better on the index anyway (well, less of them). yay having sortable ids! I
can't discern any issues doing this, as even if 200 calls have the same
created_at, they will have different ids, and the sort should allow paginating
them just fine. ids are also url safe, so the id works as the cursor value
just fine.

apps and routes are sorted by alphabetical order. as they aren't guaranteed to
be url safe, we are base64'ing them in the front end to a url safe format and
then returning them, and then base64 decoding them when we get them. this does
mean that they can be relatively large if the path/app is long, but if we
don't want to add ids then they were going to be pretty big anyway. a bonus
that this kind of obscures them. if somebody has better idea on formatting, by
all means.

notably, we are not using the sql paging facilities, and we are baking our own
based on cursors, which ends up being much more efficient for querying longer
lists of resources. this also should be easy to implement in other non-sql dbs
and the cursoring formats we can change on the fly since we are just exposing
them as opaque strings. the front end deals with the base64 / formatting, etc
and the back end is taking raw values (strfmt.DateTime or the id for calls).
the cursor that is being passed to/by the user is simply the last resource on the
previous page, so in theory we don't even need to return it, but it does make
it a little easier to use, also, cursor being blank on the last page depends
on page full-ness, so sometimes users will get a cursor when there are no
results on next page (1/N chance, and it's not really end of world -- actually
searching for the next thing would make things more complex). there are ample
tests for this behavior.

I've turned off all query parameters allowing `LIKE` queries on certain listing
endpoints, as we should not expose sql behavior through our API in the event
that we end up not using a sql db down the road. I think we should only allow
prefix matching, which sql can support as well as other types of databases
relatively cheaply, but this is not hooked up here as it didn't 'just work'
when I was fiddling with it (can add later, they're unnecessary and weren't
wired in before in front end).

* remove route listing across apps (unused)
* fix panic when doing `/app//`. this is prob possible for other types of
endpoints, out of scope here. added a guard in front of all endpoints for this
* adds `from_time` and `to_time` query parameters to calls, so you can e.g.
list the last hour of tasks. these are not required and default to
oldest/newest.
* hooked back up the datastore tests to the sql db, only run with sqlite atm,
but these are useful, added a lot to them too.
* added a bunch of tests to the front end, so pretty sure this all works now.
* added to swagger, we'll need to re-gen. also wrote some words about
pagination workings, I'm not sure how best to link to these, feedback welcome.
* not sure how we want to manage indexes, but we may need to add some (looking
at created_at, mostly)
* `?route` changed to `?path` in routes listing, to keep consistency with
everything else
* don't 404 when searching for calls where the route doesn't exist, just
return an empty list (it's a query param ffs)

closes #141
2017-09-20 06:50:49 -07:00