mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
death to format (#1281)
* get rid of old format stuff, utils usage, fix up for fdk2.0 interface * pure agent format removal, TODO remove format field, fix up all tests * shitter's clogged * fix agent tests * start rolling through server tests * tests compile, some failures * remove json / content type detection on invoke/httptrigger, fix up tests * remove hello, fixup system tests the fucking status checker test just hangs and it's testing that it doesn't work so the test passes but the test doesn't pass fuck life it's not worth it * fix migration * meh * make dbhelper shut up about dbhelpers not being used * move fail status at least into main thread, jfc * fix status call to have FN_LISTENER also turns off the stdout/stderr blocking between calls, because it's impossible to debug without that (without syslog), now that stdout and stderr go to the same place (either to host stderr or nowhere) and isn't used for function output this shouldn't be a big fuss really * remove stdin * cleanup/remind: fixed bug where watcher would leak if container dies first * silence system-test logs until fail, fix datastore tests postgres does weird things with constraints when renaming tables, took the easy way out system-tests were loud as fuck and made you download a circleci text file of the logs, made them only yell when they goof * fix fdk-go dep for test image. fun * fix swagger and remove test about format * update all the gopkg files * add back FN_FORMAT for fdks that assert things. pfft * add useful error for functions that exit this error is really confounding because containers can exit for all manner of reason, we're just guessing that this is the most likely cause for now, and this error message should very likely change or be removed from the client path anyway (context.Canceled wasn't all that useful either, but anyway, I'd been hunting for this... so found it). added a test to avoid being publicly shamed for 1 line commits (beware...).
This commit is contained in:
@@ -16,19 +16,6 @@ const (
|
||||
TypeAsync = "async"
|
||||
)
|
||||
|
||||
const (
|
||||
// FormatDefault ...
|
||||
FormatDefault = "default"
|
||||
// FormatHTTP ...
|
||||
FormatHTTP = "http"
|
||||
// FormatHTTPStream
|
||||
FormatHTTPStream = "http-stream"
|
||||
// FormatJSON ...
|
||||
FormatJSON = "json"
|
||||
// FormatCloudEvent ...
|
||||
FormatCloudEvent = "cloudevent"
|
||||
)
|
||||
|
||||
var possibleStatuses = [...]string{"delayed", "queued", "running", "success", "error", "cancelled"}
|
||||
|
||||
// Call is a representation of a specific invocation of a fn.
|
||||
@@ -84,9 +71,6 @@ type Call struct {
|
||||
// Type indicates whether a task is to be run synchronously or asynchronously.
|
||||
Type string `json:"type,omitempty" db:"-"`
|
||||
|
||||
// Format is the format to pass input into the function.
|
||||
Format string `json:"format,omitempty" db:"-"`
|
||||
|
||||
// Payload for the call. This is only used by async calls, to store their input.
|
||||
// TODO should we copy it into here too for debugging sync?
|
||||
Payload string `json:"payload,omitempty" db:"-"`
|
||||
|
||||
@@ -155,6 +155,12 @@ var (
|
||||
code: http.StatusBadRequest,
|
||||
error: errors.New("Async functions are not supported on this server"),
|
||||
}
|
||||
|
||||
// TODO consider removal. see rationale at uses, or remove if none.
|
||||
ErrContainerExitedEarly = err{
|
||||
code: http.StatusBadGateway,
|
||||
error: errors.New("container exited early, please ensure you are using the latest fdk / format and check the logs"),
|
||||
}
|
||||
)
|
||||
|
||||
// APIError any error that implements this interface will return an API response
|
||||
|
||||
@@ -61,10 +61,6 @@ var (
|
||||
code: http.StatusBadRequest,
|
||||
error: errors.New("Invalid Fn image"),
|
||||
}
|
||||
ErrFnsInvalidFormat = err{
|
||||
code: http.StatusBadRequest,
|
||||
error: errors.New("Invalid format on Fn"),
|
||||
}
|
||||
ErrFnsInvalidTimeout = err{
|
||||
code: http.StatusBadRequest,
|
||||
error: fmt.Errorf("timeout value is out of range, must be between 0 and %d", MaxTimeout),
|
||||
@@ -107,11 +103,6 @@ type Fn struct {
|
||||
CreatedAt common.DateTime `json:"created_at,omitempty" db:"created_at"`
|
||||
// UpdatedAt is the UTC timestamp of the last time this func was modified.
|
||||
UpdatedAt common.DateTime `json:"updated_at,omitempty" db:"updated_at"`
|
||||
|
||||
// TODO wish to kill but not yet ?
|
||||
// Format is the container protocol the function will accept,
|
||||
// may be one of: json | http | cloudevent | default
|
||||
Format string `json:"format" db:"format"`
|
||||
}
|
||||
|
||||
// ResourceConfig specified resource constraints imposed on a function execution.
|
||||
@@ -133,10 +124,6 @@ func (f *Fn) SetDefaults() {
|
||||
f.Memory = DefaultMemory
|
||||
}
|
||||
|
||||
if f.Format == "" {
|
||||
f.Format = FormatDefault
|
||||
}
|
||||
|
||||
if f.Config == nil {
|
||||
// keeps the json from being nil
|
||||
f.Config = map[string]string{}
|
||||
@@ -181,12 +168,6 @@ func (f *Fn) Validate() error {
|
||||
return ErrFnsMissingImage
|
||||
}
|
||||
|
||||
switch f.Format {
|
||||
case FormatDefault, FormatHTTP, FormatHTTPStream, FormatJSON, FormatCloudEvent:
|
||||
default:
|
||||
return ErrFnsInvalidFormat
|
||||
}
|
||||
|
||||
if f.Timeout <= 0 || f.Timeout > MaxTimeout {
|
||||
return ErrFnsInvalidTimeout
|
||||
}
|
||||
@@ -233,7 +214,6 @@ func (f1 *Fn) Equals(f2 *Fn) bool {
|
||||
eq = eq && f1.AppID == f2.AppID
|
||||
eq = eq && f1.Image == f2.Image
|
||||
eq = eq && f1.Memory == f2.Memory
|
||||
eq = eq && f1.Format == f2.Format
|
||||
eq = eq && f1.Timeout == f2.Timeout
|
||||
eq = eq && f1.IdleTimeout == f2.IdleTimeout
|
||||
eq = eq && f1.Config.Equals(f2.Config)
|
||||
@@ -255,7 +235,6 @@ func (f1 *Fn) EqualsWithAnnotationSubset(f2 *Fn) bool {
|
||||
eq = eq && f1.AppID == f2.AppID
|
||||
eq = eq && f1.Image == f2.Image
|
||||
eq = eq && f1.Memory == f2.Memory
|
||||
eq = eq && f1.Format == f2.Format
|
||||
eq = eq && f1.Timeout == f2.Timeout
|
||||
eq = eq && f1.IdleTimeout == f2.IdleTimeout
|
||||
eq = eq && f1.Config.Equals(f2.Config)
|
||||
@@ -286,9 +265,6 @@ func (f *Fn) Update(patch *Fn) {
|
||||
if patch.IdleTimeout != 0 {
|
||||
f.IdleTimeout = patch.IdleTimeout
|
||||
}
|
||||
if patch.Format != "" {
|
||||
f.Format = patch.Format
|
||||
}
|
||||
if patch.Config != nil {
|
||||
if f.Config == nil {
|
||||
f.Config = make(Config)
|
||||
|
||||
@@ -43,7 +43,6 @@ func fnFieldGenerators(t *testing.T) map[string]gopter.Gen {
|
||||
fieldGens["Annotations"] = annotationGenerator()
|
||||
fieldGens["CreatedAt"] = datetimeGenerator()
|
||||
fieldGens["UpdatedAt"] = datetimeGenerator()
|
||||
fieldGens["Format"] = gen.AlphaString()
|
||||
|
||||
fnFieldCount := fnReflectType().NumField()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user