mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 12:06:37 +00:00
Implement Swarm update handler using PUT
This commit implements an update handler for Docker Swarm, it queries the current spec, updates values in-situ before calling ServiceUpdate. The UpdateConfig FailureAction is set to rollback, so in the event of supplying values to the update that would result in the service failing then the update will be rolled back. The UpdateConfig Parallelism param is set to an explicit value of 1 which will result in functions being updated 1 by 1 rather than all at once. It also moves the restartDelay declaration out of the create and update handlers and into the main server function alongside maxRestarts. And finally this commit uses the PUT HTTP verb for updates rather than the non-HTTP UPDATE verb which was being used initially (also adding it to the Swagger definition). Signed-off-by: John McCabe <john@johnmccabe.net>
This commit is contained in:
@ -92,13 +92,15 @@ func main() {
|
||||
|
||||
// How many times to reschedule a function.
|
||||
maxRestarts := uint64(5)
|
||||
// Delay between container restarts
|
||||
restartDelay := time.Second * 5
|
||||
|
||||
faasHandlers.Proxy = internalHandlers.MakeProxy(metricsOptions, true, dockerClient, &logger)
|
||||
faasHandlers.RoutelessProxy = internalHandlers.MakeProxy(metricsOptions, false, dockerClient, &logger)
|
||||
faasHandlers.ListFunctions = internalHandlers.MakeFunctionReader(metricsOptions, dockerClient)
|
||||
faasHandlers.DeployFunction = internalHandlers.MakeNewFunctionHandler(metricsOptions, dockerClient, maxRestarts)
|
||||
faasHandlers.DeployFunction = internalHandlers.MakeNewFunctionHandler(metricsOptions, dockerClient, maxRestarts, restartDelay)
|
||||
faasHandlers.DeleteFunction = internalHandlers.MakeDeleteFunctionHandler(metricsOptions, dockerClient)
|
||||
faasHandlers.UpdateFunction = internalHandlers.MakeUpdateFunctionHandler(metricsOptions, dockerClient, maxRestarts)
|
||||
faasHandlers.UpdateFunction = internalHandlers.MakeUpdateFunctionHandler(metricsOptions, dockerClient, maxRestarts, restartDelay)
|
||||
|
||||
faasHandlers.Alert = internalHandlers.MakeAlertHandler(internalHandlers.NewSwarmServiceQuery(dockerClient))
|
||||
|
||||
@ -130,7 +132,7 @@ func main() {
|
||||
r.HandleFunc("/system/functions", listFunctions).Methods("GET")
|
||||
r.HandleFunc("/system/functions", faasHandlers.DeployFunction).Methods("POST")
|
||||
r.HandleFunc("/system/functions", faasHandlers.DeleteFunction).Methods("DELETE")
|
||||
r.HandleFunc("/system/functions", faasHandlers.UpdateFunction).Methods("UPDATE")
|
||||
r.HandleFunc("/system/functions", faasHandlers.UpdateFunction).Methods("PUT")
|
||||
|
||||
if faasHandlers.QueuedProxy != nil {
|
||||
r.HandleFunc("/async-function/{name:[-a-zA-Z_0-9]+}/", faasHandlers.QueuedProxy).Methods("POST")
|
||||
|
Reference in New Issue
Block a user