mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
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
This commit is contained in:
1
api/datastore/sql/migrations/3_add_call_error.down.sql
Normal file
1
api/datastore/sql/migrations/3_add_call_error.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE calls DROP COLUMN error;
|
||||
1
api/datastore/sql/migrations/3_add_call_error.up.sql
Normal file
1
api/datastore/sql/migrations/3_add_call_error.up.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE calls ADD error text;
|
||||
@@ -4,6 +4,8 @@
|
||||
// 1_add_route_created_at.up.sql
|
||||
// 2_add_call_stats.down.sql
|
||||
// 2_add_call_stats.up.sql
|
||||
// 3_add_call_error.down.sql
|
||||
// 3_add_call_error.up.sql
|
||||
// DO NOT EDIT!
|
||||
|
||||
package migrations
|
||||
@@ -86,7 +88,7 @@ func _1_add_route_created_atDownSql() (*asset, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1_add_route_created_at.down.sql", size: 43, mode: os.FileMode(420), modTime: time.Unix(1510786558, 0)}
|
||||
info := bindataFileInfo{name: "1_add_route_created_at.down.sql", size: 43, mode: os.FileMode(420), modTime: time.Unix(1511259011, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
@@ -106,7 +108,7 @@ func _1_add_route_created_atUpSql() (*asset, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1_add_route_created_at.up.sql", size: 40, mode: os.FileMode(420), modTime: time.Unix(1510786558, 0)}
|
||||
info := bindataFileInfo{name: "1_add_route_created_at.up.sql", size: 40, mode: os.FileMode(420), modTime: time.Unix(1511259011, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
@@ -126,7 +128,7 @@ func _2_add_call_statsDownSql() (*asset, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "2_add_call_stats.down.sql", size: 37, mode: os.FileMode(420), modTime: time.Unix(1511225799, 0)}
|
||||
info := bindataFileInfo{name: "2_add_call_stats.down.sql", size: 37, mode: os.FileMode(420), modTime: time.Unix(1511259011, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
@@ -146,7 +148,47 @@ func _2_add_call_statsUpSql() (*asset, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "2_add_call_stats.up.sql", size: 34, mode: os.FileMode(420), modTime: time.Unix(1511225651, 0)}
|
||||
info := bindataFileInfo{name: "2_add_call_stats.up.sql", size: 34, mode: os.FileMode(420), modTime: time.Unix(1511259011, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var __3_add_call_errorDownSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x4e\xcc\xc9\x29\x56\x70\x09\xf2\x0f\x50\x70\xf6\xf7\x09\xf5\xf5\x53\x48\x2d\x2a\xca\x2f\xb2\xe6\x02\x04\x00\x00\xff\xff\xc1\x14\x26\x51\x25\x00\x00\x00")
|
||||
|
||||
func _3_add_call_errorDownSqlBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
__3_add_call_errorDownSql,
|
||||
"3_add_call_error.down.sql",
|
||||
)
|
||||
}
|
||||
|
||||
func _3_add_call_errorDownSql() (*asset, error) {
|
||||
bytes, err := _3_add_call_errorDownSqlBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "3_add_call_error.down.sql", size: 37, mode: os.FileMode(420), modTime: time.Unix(1511265731, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var __3_add_call_errorUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x4e\xcc\xc9\x29\x56\x70\x74\x71\x51\x48\x2d\x2a\xca\x2f\x52\x28\x49\xad\x28\xb1\xe6\x02\x04\x00\x00\xff\xff\xaf\xba\x27\xcd\x22\x00\x00\x00")
|
||||
|
||||
func _3_add_call_errorUpSqlBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
__3_add_call_errorUpSql,
|
||||
"3_add_call_error.up.sql",
|
||||
)
|
||||
}
|
||||
|
||||
func _3_add_call_errorUpSql() (*asset, error) {
|
||||
bytes, err := _3_add_call_errorUpSqlBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "3_add_call_error.up.sql", size: 34, mode: os.FileMode(420), modTime: time.Unix(1511265909, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
@@ -207,6 +249,8 @@ var _bindata = map[string]func() (*asset, error){
|
||||
"1_add_route_created_at.up.sql": _1_add_route_created_atUpSql,
|
||||
"2_add_call_stats.down.sql": _2_add_call_statsDownSql,
|
||||
"2_add_call_stats.up.sql": _2_add_call_statsUpSql,
|
||||
"3_add_call_error.down.sql": _3_add_call_errorDownSql,
|
||||
"3_add_call_error.up.sql": _3_add_call_errorUpSql,
|
||||
}
|
||||
|
||||
// AssetDir returns the file names below a certain
|
||||
@@ -254,6 +298,8 @@ var _bintree = &bintree{nil, map[string]*bintree{
|
||||
"1_add_route_created_at.up.sql": &bintree{_1_add_route_created_atUpSql, map[string]*bintree{}},
|
||||
"2_add_call_stats.down.sql": &bintree{_2_add_call_statsDownSql, map[string]*bintree{}},
|
||||
"2_add_call_stats.up.sql": &bintree{_2_add_call_statsUpSql, map[string]*bintree{}},
|
||||
"3_add_call_error.down.sql": &bintree{_3_add_call_errorDownSql, map[string]*bintree{}},
|
||||
"3_add_call_error.up.sql": &bintree{_3_add_call_errorUpSql, map[string]*bintree{}},
|
||||
}}
|
||||
|
||||
// RestoreAsset restores an asset under the given directory
|
||||
|
||||
@@ -66,6 +66,7 @@ var tables = [...]string{`CREATE TABLE IF NOT EXISTS routes (
|
||||
app_name varchar(256) NOT NULL,
|
||||
path varchar(256) NOT NULL,
|
||||
stats text,
|
||||
error text,
|
||||
PRIMARY KEY (id)
|
||||
);`,
|
||||
|
||||
@@ -78,7 +79,7 @@ var tables = [...]string{`CREATE TABLE IF NOT EXISTS routes (
|
||||
|
||||
const (
|
||||
routeSelector = `SELECT app_name, path, image, format, memory, type, timeout, idle_timeout, headers, config, created_at FROM routes`
|
||||
callSelector = `SELECT id, created_at, started_at, completed_at, status, app_name, path, stats FROM calls`
|
||||
callSelector = `SELECT id, created_at, started_at, completed_at, status, app_name, path, stats, error FROM calls`
|
||||
)
|
||||
|
||||
type sqlStore struct {
|
||||
@@ -587,7 +588,8 @@ func (ds *sqlStore) InsertCall(ctx context.Context, call *models.Call) error {
|
||||
status,
|
||||
app_name,
|
||||
path,
|
||||
stats
|
||||
stats,
|
||||
error
|
||||
)
|
||||
VALUES (
|
||||
:id,
|
||||
@@ -597,7 +599,8 @@ func (ds *sqlStore) InsertCall(ctx context.Context, call *models.Call) error {
|
||||
:status,
|
||||
:app_name,
|
||||
:path,
|
||||
:stats
|
||||
:stats,
|
||||
:error
|
||||
);`)
|
||||
|
||||
_, err := ds.db.NamedExecContext(ctx, query, call)
|
||||
|
||||
Reference in New Issue
Block a user