Fix readonly error message and push existing image bug (#4654)

This commit is contained in:
Yan 2018-04-13 19:22:28 +08:00 committed by GitHub
parent dce1896d92
commit ab4018e967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -43,7 +43,7 @@ func filter(req *http.Request, resp http.ResponseWriter) {
}
if matchRepoTagDelete(req) {
resp.WriteHeader(http.StatusServiceUnavailable)
_, err := resp.Write([]byte("The system is in read only mode. Any modification is not prohibited."))
_, err := resp.Write([]byte("The system is in read only mode. Any modification is prohibited."))
if err != nil {
log.Errorf("failed to write response body: %v", err)
}

View File

@ -160,8 +160,9 @@ type readonlyHandler struct {
func (rh readonlyHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if config.ReadOnly() {
if req.Method == http.MethodDelete || req.Method == http.MethodPost || req.Method == http.MethodPatch {
http.Error(rw, marshalError("DENIED", "The system is in read only mode. Any modification is not prohibited."), http.StatusForbidden)
if req.Method == http.MethodDelete || req.Method == http.MethodPost || req.Method == http.MethodPatch || req.Method == http.MethodPut {
log.Warningf("The request is prohibited in readonly mode, url is: %s", req.URL.Path)
http.Error(rw, marshalError("DENIED", "The system is in read only mode. Any modification is prohibited."), http.StatusForbidden)
return
}
}