Commit Graph

115 Commits

Author SHA1 Message Date
Reed Allman
c0aed2fbb0 mask errors in api response, log real error
we had this _almost_ right, in that we were trying, but we weren't masking the
error from the user response for any error we don't intend to show. this also
adds a stack trace from any internal server errors, so that we might be able
to track them down in the future (looking at you, 'context deadline
exceeded'). in addition, this adds a new `models.APIError` interface which all
of the errors in `models` now implement, and can be caught easily / added to
easily.

the front end now does no status rewriting based on api errors, now when we
get a non-nil error we can call `handleResponse(c, err)` with it and if it's a
proper error, return it to the user with the right status code, otherwise log
a stack trace and return `internal server error`. this cleans up a lot of the
front end code.

also rewrites start task ctx deadline exceeded as timeout. with iw we had
async tasks so we could start the clock later and it didn't matter, but now
with sync tasks time out sometimes just making docker calls, and we want the
task status to show up as timed out. we may want to just catch all this above
in addition to this, but this seems like the right thing to do.

remove squishing together errors. this was weird, now we return the first
error for the purposes of using the new err interface.

removed a lot of 5xx errors that really should have been 4xx errors. changed
some of the 400 errors to 409 errors, since they are from sending in
conflicting info and not a malformed request.

removed unused errors / useless errors (many were used for logging, and didn't
provide any context. now with stack traces we don't need context as much in
the logs).
2017-07-14 03:44:16 -07:00
Travis Reeder
98539fba8a Updated deps 2017-07-12 14:08:59 -07:00
Reed Allman
4e52c595d2 merge datastores into sqlx package
replace default bolt option with sqlite3 option. the story here is that we
just need a working out of the box solution, and sqlite3 is just fine for that
(actually, likely better than bolt).

with sqlite3 supplanting bolt, we mostly have sql databases. so remove redis
and then we just have one package that has a `sql` implementation of the
`models.Datastore` and lean on sqlx to do query rewriting. this does mean
queries have to be formed a certain way and likely have to be ANSI-SQL (no
special features) but we weren't using them anyway and our base api is
basically done and we can easily extend this api as needed to only implement
certain methods in certain backends if we need to get cute.

* remove bolt & redis datastores (can still use as mqs)
* make sql queries work on all 3 (maybe?)
* remove bolt log store and use sqlite3
* shove the FnLog shit into the datastore shit for now (free pg/mysql logs...
just for demos, etc, not prod)
* fix up the docs to remove bolt references
* add sqlite3, sqlx dep
* fix up tests & mock stuff, make validator less insane
* remove put & get in datastore layer as nobody is using.

this passes tests which at least seem like they test all the different
backends. if we trust our tests then this seems to work great. (tests `make
docker-test-run-with-*` work now too)
2017-07-07 01:30:02 -07:00
James Jeffrey
81e39b210d Add go fmt 2017-07-07 10:14:08 -07:00
Travis Reeder
8800ecc5c2 Merge branch 'func_logs2' into 'master'
Func logs feature

See merge request !66
2017-06-20 11:51:26 -07:00
Travis Reeder
8c96d3ba2f Fixes async payload passing for #68. 2017-06-20 11:32:51 -07:00
James
8a3edb8309 All of the changes for func logs 2017-06-19 11:38:11 -07:00
Reed Allman
9edacae928 clean up hotf(x) concurrency, rm max c
this patch gets rid of max concurrency for functions altogether, as discussed,
since it will be challenging to support across functions nodes. as a result of
doing so, the previous version of functions would fall over when offered 1000
functions, so there was some work needed in order to push this through.
further work is necessary as docker basically falls over when trying to start
enough containers at the same time, and with this patch essentially every
function can scale infinitely. it seems like we could add some kind of
adaptive restrictions based on task run length and configured wait time so
that fast running functions will line up to run in a hot container instead of
them all creating new hot containers.

this patch takes a first cut at whacking out some of the insanity that was the
previous concurrency model, which was problematic in that it limited
concurrency significantly across all functions since every task went through
the same unbuffered channel, which could create blocking issues for all
functions if the channel is not picked off fast enough (it's not apparent that
this was impossible in the previous implementation). in any event, each
request has a goroutine already, there's no reason not to use it. not too hard
to wrap a map in a lock, not sure what the benefits were (added insanity?) in effect
this is marginally easier to understand and less insane (marginally). after
getting rid of max c this adds a blocking mechanism for the first invocation
of any function so that all other hot functions will wait on the first one to
finish to avoid a herd issue (was making docker die...) -- this could be
slightly improved, but works in a pinch. reduced some memory usage by having
redundant maps of htfnsvr's and task.Requests (by a factor of 2!). cleaned up
some of the protocol stuff, need to clean this up further. anyway, it's a
first cut. have another patch that rewrites all of it but was getting into
rabbit hole territory, would be happy to oblige if anybody else has problems
understanding this rat's nest of channels. there is a good bit of work left to
make this prod ready (regardless of removing max c).

a warning that this will break the db schemas, didn't put the effort in to add
migration stuff since this isn't deployed anywhere in prod...

TODO need to clean out the htfnmgr bucket with LRU
TODO need to clean up runner interface
TODO need to unify the task running paths across protocols
TODO need to move the ram checking stuff into worker for noted reasons
TODO need better elasticity of hot f(x) containers
2017-06-05 20:04:13 -07:00
Denis Makogon
3f065ce6bf [Feature] Function status 2017-06-06 14:12:50 -07:00
Travis Reeder
961d17bdb8 Uses SetDefaults as it does in create too. 2017-05-18 14:18:16 -07:00
Travis Reeder
2696a8a917 Fixed idle timeout bug 2017-05-18 13:24:49 -07:00
Denis Makogon
7603e6e8fa Add idle_timeout to routes API (#603)
* Add inactivity_timeout to routes API

Closes: #544

* Fix failing datastore tests

* Rename inactivity_timeout to idle_timeout

* Update swagger doc

* Update hot fn doc

* Fix json tags

* Add function timeouts docs

* Rewording
2017-03-25 18:28:53 +01:00
Jordan Krage
1d0ba54b35 server updates (#566)
* server updates

- improved route create/update validation/defaults
- improved/added route test cases

* cleanup

* negative concurrency check
2017-03-03 09:33:19 -06:00
Jordan Krage
06171800e2 Datastore validator (#565)
* add datastore validator; adapt mock and tests

* adapt bolt datastore to common validator

* adapt postgres datastore to validator

* adapt redis datastore to common validator
2017-03-02 14:43:53 -08:00
Jordan Krage
17e18d872b mock datastore tests (#562) 2017-03-01 22:04:04 -08:00
Jordan Krage
3fd3da87f3 Datastore tests (#551)
* common datastore tests

* fix Datastore.UpdateApp

* remove extra datastore tests

* datastore test fixes
2017-03-01 08:40:08 -08:00
Pedro Nasser
a5eeacdadb fix runner response (#517) 2017-02-11 03:36:56 +01:00
Seif Lotfy سيف لطفي
ab9428a937 Unskip tests (#516)
* Unskip tests

* fix fn output for errors

* Change Error model and add fn routes call return on error
2017-02-09 22:31:39 -02:00
Travis Reeder
d5116397b6 API extension points (#473)
* API endpoint extensions working.

extensions example.

* Added server.NewEnv and some docs for the API extensions example.

extensions example.
example main.go.

* Uncommented special handler stuff.

* Added section in docs for extending API linking to example main.go.

* Commented out special_handler test

* Changed to NewFromEnv
2017-01-30 12:14:28 -08:00
Pedro Nasser
5367a3ef99 Fix API inconsistencies (#404)
* fix api inconsistencies

* handling empty format cases

* code style
2016-12-07 17:16:48 -02:00
C Cirello
3b16b7f1d8 functions: application updates no longer accept name in the body (#391)
* functions: application updates no longer accept name in the body

AppUpdate was initially conceived as an upsert endpoint for apps.
It turns out that it created an inconsistency regarding updates:
updates with names divergent with URL would not actually change
application's name.

This commit atempts to address the issue by returning an HTTP
error when trying to update an application name. In swagger.yml,
application names are already `readOnly:true`. Thus there is no
change from expected behavior.

Fixes #380

* functions: use specific error value for name change
2016-12-07 19:54:21 +01:00
C Cirello
66d446b148 functions: returns HTTP error in case of route update attempt (#396)
Ensure that attempts to update route's path are properly handled
with a HTTP error. Moreover, updates swagger file to make it
explicit that routes are immutable.

Fixes #381
2016-12-07 19:54:09 +01:00
Pedro Nasser
9382f0b133 fix datastore Put and added tests (#402) 2016-12-07 08:59:54 -08:00
C Cirello
a7a466f968 functions: fix route timeout (#349)
* functions: add route-level timeout configuration options

* functions: harmonize defaults
2016-11-28 20:53:11 -02:00
C Cirello
ac0044f7d9 functions: hot containers (#332)
* functions: modify datastore to accomodate hot containers support

* functions: protocol between functions and hot containers

* functions: add hot containers clockwork

* fn: add hot containers support
2016-11-28 15:45:35 -02:00
Pedro Nasser
01d5a81389 Add appfilter and tests (#337)
add appfilter and tests
2016-11-24 03:46:42 -02:00
Pedro Nasser
c14bc323f9 added ctx to datastore and improve mock (#329)
Added ctx to datastore and improved mock
2016-11-22 03:33:44 -02:00
C Cirello
da96ef471a api: add support for deleting apps (#327)
* api: add support for deleting apps

Fixes #274

* functions: improve error name and description

* functions: fix test regression
2016-11-22 01:07:30 +01:00
Pedro Nasser
0343c4990c server.New signature changes and test fixes. (#324)
* ctx middleware should always be the first added to router

* plugable enqueue func, changed server.New signature

* fix tests

* remove ctx/ctx.Done from server
2016-11-21 17:11:01 +01:00
Pedro Nasser
7593480d4b fix route update (#295)
Fix route update, ensure image exists
2016-11-16 19:46:56 -02:00
Travis Reeder
616112b349 swagger fixes and appname -> app_name (#294)
* swagger fixes and appname -> app_name

* Swagger errors fixed
2016-11-15 08:13:53 -08:00
Pedro Nasser
7aa1981fba Datastore refactor and added postgres tests (#259)
* fix apps & routes creation/update

* refactor datastore and added postgres tests

* added test-datastore and fixed circleci test
2016-11-14 15:03:10 -02:00
Carlos C
d5fb1afda7 Revert "Assert License (#224)"
This reverts commit a61c4dab78.
2016-11-06 09:25:12 -08:00
C Cirello
a61c4dab78 Assert License (#224)
* license: assert license for Go code
* license: add in shell scripts
* license: assert license for Ruby code
* license: assert license to individual cases
* license: assert license to Dockerfile
2016-11-05 23:33:07 +01:00
Seif Lotfy سيف لطفي
e85a31b715 Add missing swagger spec (#175)
* Add missing swagger spec

* More cleaning up of the swagger.yml and removing unused structs

* Add TaskWrapper
2016-10-19 12:22:41 -07:00
Seif Lotfy سيف لطفي
0270eca460 remove unused ApplyAppFilter which always returns true (#177) 2016-10-17 11:37:31 -07:00
C Cirello
42efb2ed6b Improve routes query (#172) 2016-10-14 21:52:25 +02:00
Travis Reeder
75383d060f Updated route_name in json to app_name. 2016-10-13 20:24:06 -07:00
Travis Reeder
25f582b180 Updated README and simplified/cleaned up some code. 2016-10-13 20:24:06 -07:00
Pedro Nasser
2e12e2c700 Fix input async tasks + tests (#137) 2016-10-12 22:23:34 +02:00
C Cirello
3ca137a01c Upgrade to Go 1.7 (#128)
* Upgrade to stdlib context package
* Modernized syntax
2016-10-06 20:10:00 +02:00
Carlos C
0ecb6ca5cc Add context do models.MessageQueue interface 2016-10-03 23:49:08 +02:00
Seif Lotfy
54f66c7b09 update glide 2016-09-26 12:59:18 +02:00
Seif Lotfy
92df53b144 Add support for Async worker 2016-09-24 10:06:57 +02:00
Seif Lotfy
b623fc27e4 Initial work on async functions 2016-09-24 10:06:51 +02:00
Pedro Nasser
f461312553 add required memory configuration to Route 2016-09-09 00:53:46 -03:00
Pedro Nasser
2782a6db54 added config to apps and routes 2016-08-26 23:04:57 -03:00
Henrique Chehad
459620f9b4 fix runner to use global instance 2016-08-22 20:12:02 -03:00
Henrique Chehad
148d52c890 updates after runner factored 2016-08-22 19:17:58 -03:00
Henrique Chehad
e11a1896fd rebase/merging runner 2016-08-22 18:21:59 -03:00