Commit Graph

925 Commits

Author SHA1 Message Date
Travis Reeder
a67d5a6290 Drop viper dependency (#550)
* Removed viper dependency.

* removed from glide files
2017-11-28 15:46:17 -08:00
CI
1529dff810 fnserver: 0.3.206 release [skip ci] 2017-11-28 18:29:50 +00:00
CI
3a2abbff28 fnserver: 0.3.205 release [skip ci] 2017-11-28 17:38:09 +00:00
Reed Allman
892c843d87 add error to call model (#539)
* add error to call model

closes #331

previously, for async this error was being masked completely even if it was
something useful like the image not existing. for sync, the error was returned
in the http request but now it's also being stored. this error itself can
cover a lot of landscape, it could be an error in getting a slot, pulling an
image, running a container, among other things. anyway, no longer being
masked. we can likely improve it in certain cases we run into in the future,
but it's open ended at the moment and not being masked like some errors in
sync http request returns (503 non-models.APIError) for now.

* tucks in callTrigger stuff to keep api clean
* adds swagger
* adds migration
* adds tests for datastore and agent to ensure behavior

* pull images before tests are ran

* gofmt migrations file
2017-11-28 11:21:39 -06:00
CI
adb9872921 fnserver: 0.3.204 release [skip ci] 2017-11-28 16:32:54 +00:00
Nigel Deakin
954f69e74a Add appname to basic metrics (#547)
* Add app labels to queued/running/completed/failed metrics

* Add app labels to queued/running/completed/failed metrics

* Add app labels to queued/running/completed/failed metrics
2017-11-28 10:17:24 -06:00
CI
93ab1f0bc2 fnserver: 0.3.203 release [skip ci] 2017-11-27 15:09:20 +00:00
Reed Allman
c9198b8525 add per call stats field as histogram (#528)
* add per call stats field as histogram

this will add a histogram of up to 240 data points of call data, produced
every second, stored at the end of a call invocation in the db. the same
metrics are also still shipped to prometheus (prometheus has the
not-potentially-reduced version). for the API reference, see the updates to
the swagger spec, this is just added onto the get call endpoint.

this does not add any extra db calls and the field for stats in call is a json
blob, which is easily modified to add / omit future fields. this is just
tacked on to the call we're making to InsertCall, and expect this to add very
little overhead; we are bounding the set to be relatively small, planning to
clean out the db of calls periodically, functions will generally be short, and
the same code used at a previous firm did not cause a notable db size increase
with production workload that is worse, wrt histogram size (I checked). the
code changes are really small aside from changing to strfmt.DateTime,
adding a migration and implementing sql.Valuer; needed to slightly modify the
swap function so that we can safely read `call.Stats` field to upload at end.

with the full histogram in hand, we can compute max/min/average/median/growth
rate/bernoulli distributions/whatever very easily in a UI or tooling. in
particular, this data is easily chartable [for a UI], which is beneficial.

* adds swagger spec of api update to calls endpoint
* adds migration for call.stats field
* adds call.stats field to sql queries
* change swapping of hot logger to exec, so we know that call.Stats is no
longer being modified after `exec` [in call.End]
* throws out docker stats between function invocations in hot functions (no
call to store them on, we could change this later for debug; they're in prom)
* tested in tests and API

closes #19

* add format of ints to swag
2017-11-27 08:52:53 -06:00
CI
3adf478530 fnserver: 0.3.202 release [skip ci] 2017-11-24 16:48:55 +00:00
Denis Makogon
347edea56e Use valid call type instead in protocol (#534) 2017-11-24 10:32:17 -06:00
CI
19df15bd9b fnserver: 0.3.201 release [skip ci] 2017-11-22 20:17:21 +00:00
Tolga Ceylan
89dc79f0b0 fn: remove redundant httprouter code (#532)
*) tree from https://github.com/julienschmidt/httprouter
is already in Gin and this only seems to be parsing
parameters from URI.
2017-11-22 13:58:10 -06:00
CI
c2a0f83467 fnserver: 0.3.200 release [skip ci] 2017-11-22 15:43:11 +00:00
CI
7548ab44d5 fnserver: 0.3.199 release [skip ci] 2017-11-21 20:57:31 +00:00
Tolga Ceylan
2551be446a fn: introducing 503 responses for out of capacity case (#518)
* fn: introducing 503 responses for out of capacity case

*) Adding 503 with Retry-After header case if request failed
during waiting for slots.
*) TODO: return 503 without Retry-After if the request can
never be met by this fn server.
*) fn: runner test docker pull fixup
*) fn: MaxMemory for routes is now a variable to allow
testing and adjusting it according to fleet memory sizes.
2017-11-21 12:42:02 -08:00
CI
cd80ae0a3a fnserver: 0.3.198 release [skip ci] 2017-11-21 19:00:20 +00:00
CI
7764f99a63 fnserver: 0.3.197 release [skip ci] 2017-11-21 01:55:54 +00:00
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
CI
79994d43a8 fnserver: 0.3.196 release [skip ci] 2017-11-18 16:02:30 +00:00
CI
37fb96ed0e fnserver: 0.3.195 release [skip ci] 2017-11-18 15:25:24 +00:00
CI
228fbd559e fn-server: 0.3.194 release [skip ci] 2017-11-18 04:46:58 +00:00
Reed Allman
f08ea57bc0 add docker health check waiter to start (#434)
before returning the cookie in the driver, wait for health checks
https://docs.docker.com/engine/reference/builder/#healthcheck if provided.
for images that don't have health checks, this will have no affect (an added
call to inspect container, for hot it's small potatoes).

this will be useful for containers so that they can pull large files or do
setup that takes a while before accepting tasks. since this is before start,
it won't run into the idle timeout. we could likely use these for hot
containers in general and check between runs or something, but didn't do that
here.

one nascient concern is that for hot if the containers never become healthy
I don't think we will ever kill them and the slot will 'leak'. this is true
for this and for other cases (pulling image) I think, we should probably
recycle hot containers every hour or something which would also close this.
anyway, not a huge blocker I don't think, there will likely be 1 user of this
feature for a bit, it's not documented since we're not sure we want to support
it.

closes #336
2017-11-17 20:31:33 -08:00
CI
5b2b5ea201 fn-server: 0.3.193 release [skip ci] 2017-11-18 00:09:00 +00: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
CI
9281941bbb fn-server: 0.3.192 release [skip ci] 2017-11-17 23:41:14 +00:00
Tolga Ceylan
17d4271ffb fn: move memory/token code into resource (#512)
*) bugfix: fix nil ptr access in docker registry RoundTrip
*) move async and ram token related code into resource.go
2017-11-17 15:25:53 -08:00
CI
f1d4387f23 fn-server: 0.3.191 release [skip ci] 2017-11-17 21:02:20 +00:00
Tolga Ceylan
57b24d63c3 fn: prometheus collector concurrent map access (#510)
* fn: prometheus collector concurrent map access

*) Added mutex to guard against concurrent access to maps

* fn: prometheus collector method receivers should be ptr

* fn: prometheus collector concurrent map access

*) Moved the mutex into getHistogramVec()
2017-11-17 12:46:53 -08:00
CI
5693f7dc53 fn-server: 0.3.190 release [skip ci] 2017-11-17 20:01:24 +00:00
CI
71eb32820b fn-server: 0.3.189 release [skip ci] 2017-11-17 19:40:33 +00:00
CI
5f308829b0 functions: 0.3.188 release [skip ci] 2017-11-17 16:15:08 +00:00
CI
5440789e08 functions: 0.3.187 release [skip ci] 2017-11-17 15:13:15 +00:00
CI
ca30310352 functions: 0.3.186 release [skip ci] 2017-11-16 23:52:13 +00:00
CI
20c50bc9da functions: 0.3.185 release [skip ci] 2017-11-16 20:15:01 +00: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
CI
db3d76fd1b functions: 0.3.184 release [skip ci] 2017-11-16 18:25:15 +00:00
CI
0f3b64867f functions: 0.3.183 release [skip ci] 2017-11-16 18:15:31 +00: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
CI
86fb89d250 functions: 0.3.182 release [skip ci] 2017-11-16 17:55:59 +00:00
CI
a8a0345090 functions: 0.3.181 release [skip ci] 2017-11-16 15:48:31 +00:00
Alexander Bransby-Sharples
c5ec0cc41e Add CORS support to fn api (#455)
The Gin middleware is being used if one or more Origins are specified. Default setup for each Origin is as follows:

- GET,POST, PUT, HEAD methods allowed
- Credentials share disabled
- Preflight requests cached for 12 hours

Which are the defaults gin-contrib/cors comes with out of the box.

Gin-cors will return a 403 if it gets a request with an Origin header that isn't on its' list. If no Origin header is specified then it will just return the servers response.

Start fn with CORS enabled:

`API_CORS="http://localhost:4000, http://localhost:3000" make run`
2017-11-16 15:37:26 +00:00
CI
406267a040 functions: 0.3.180 release [skip ci] 2017-11-16 00:17:55 +00:00
CI
92c68e3665 functions: 0.3.179 release [skip ci] 2017-11-15 16:40:04 +00:00
CI
3031a465a2 functions: 0.3.178 release [skip ci] 2017-11-14 21:05:21 +00: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
CI
bfbc6096ee functions: 0.3.177 release [skip ci] 2017-11-14 02:08:26 +00:00
Tolga Ceylan
af8eed098d fn: graceful shutdown adjustments (#498)
Graceful shutdown should wait for Shutdown call instead of
ListenAndServe. This is because ListenAndServe returns
immediately upon Shutdown call.
2017-11-13 17:58:15 -08:00
CI
42e7143ed4 functions: 0.3.176 release [skip ci] 2017-11-13 17:49:52 +00:00
CI
3e4ebbda33 functions: 0.3.175 release [skip ci] 2017-11-13 17:46:21 +00:00
CI
be844de01d functions: 0.3.174 release [skip ci] 2017-11-13 17:23:46 +00:00