Wait for container to be attached before returning from {re}start request
This commit is contained in:
1 parent
b712ba1e04
commit
1e2344341d
2 files changed
+80
-2
No files matched your search
@@ -0,0 +1,24 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type startContainerInterceptor struct{ proxy *Proxy }
|
||||
|
||||
func (i *startContainerInterceptor) InterceptRequest(r *http.Request) error {
|
||||
container, err := inspectContainerInPath(i.proxy.client, r.URL.Path)
|
||||
if err == nil && containerShouldAttach(container) {
|
||||
i.proxy.createWait(r, container.ID)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error {
|
||||
defer i.proxy.removeWait(r.Request)
|
||||
if r.StatusCode < 200 || r.StatusCode >= 300 { // Docker didn't do the start
|
||||
return nil
|
||||
}
|
||||
i.proxy.waitForStart(r.Request)
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user