X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/42966c194493f8e42e26e3d64880e5c93a9c3251..d71c797d3bbfd26d571fb46a14262b5c01b95ff4:/lib/dispatchcloud/dispatcher.go diff --git a/lib/dispatchcloud/dispatcher.go b/lib/dispatchcloud/dispatcher.go index 12c60ecb11..731c6d25d7 100644 --- a/lib/dispatchcloud/dispatcher.go +++ b/lib/dispatchcloud/dispatcher.go @@ -148,6 +148,7 @@ func (disp *dispatcher) initialize() { } else { mux := httprouter.New() mux.HandlerFunc("GET", "/arvados/v1/dispatch/containers", disp.apiContainers) + mux.HandlerFunc("POST", "/arvados/v1/dispatch/containers/kill", disp.apiInstanceKill) mux.HandlerFunc("GET", "/arvados/v1/dispatch/instances", disp.apiInstances) mux.HandlerFunc("POST", "/arvados/v1/dispatch/instances/hold", disp.apiInstanceHold) mux.HandlerFunc("POST", "/arvados/v1/dispatch/instances/drain", disp.apiInstanceDrain) @@ -232,6 +233,20 @@ func (disp *dispatcher) apiInstanceKill(w http.ResponseWriter, r *http.Request) } } +// Management API: send SIGTERM to specified container's crunch-run +// process now. +func (disp *dispatcher) apiContainerKill(w http.ResponseWriter, r *http.Request) { + uuid := r.FormValue("container_uuid") + if uuid == "" { + httpserver.Error(w, "container_uuid parameter not provided", http.StatusBadRequest) + return + } + if !disp.pool.KillContainer(uuid, "via management API: "+r.FormValue("reason")) { + httpserver.Error(w, "container not found", http.StatusNotFound) + return + } +} + func (disp *dispatcher) apiInstanceIdleBehavior(w http.ResponseWriter, r *http.Request, want worker.IdleBehavior) { id := cloud.InstanceID(r.FormValue("instance_id")) if id == "" {