mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-11 15:59:06 +08:00
Merge branch 'master' into mq-subscribe
This commit is contained in:
commit
263f1f3d04
@ -23,7 +23,6 @@ spec:
|
|||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
|
app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
|
||||||
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
|
|
||||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
app.kubernetes.io/component: filer
|
app.kubernetes.io/component: filer
|
||||||
template:
|
template:
|
||||||
|
@ -22,7 +22,6 @@ spec:
|
|||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
|
app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
|
||||||
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
|
|
||||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
app.kubernetes.io/component: master
|
app.kubernetes.io/component: master
|
||||||
template:
|
template:
|
||||||
|
@ -16,7 +16,6 @@ spec:
|
|||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
|
app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
|
||||||
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
|
|
||||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
app.kubernetes.io/component: volume
|
app.kubernetes.io/component: volume
|
||||||
template:
|
template:
|
||||||
|
@ -278,7 +278,10 @@ func updateLocalEntry(filerClient filer_pb.FilerClient, dir string, entry *filer
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isMultipartUploadFile(dir string, name string) bool {
|
func isMultipartUploadFile(dir string, name string) bool {
|
||||||
return strings.HasPrefix(dir, "/buckets/") &&
|
return isMultipartUploadDir(dir) && strings.HasSuffix(name, ".part")
|
||||||
strings.Contains(dir, "/"+s3_constants.MultipartUploadsFolder+"/") &&
|
}
|
||||||
strings.HasSuffix(name, ".part")
|
|
||||||
|
func isMultipartUploadDir(dir string) bool {
|
||||||
|
return strings.HasPrefix(dir, "/buckets/") &&
|
||||||
|
strings.Contains(dir, "/"+s3_constants.MultipartUploadsFolder+"/")
|
||||||
}
|
}
|
||||||
|
@ -394,6 +394,10 @@ func genProcessFunction(sourcePath string, targetPath string, excludePaths []str
|
|||||||
glog.V(0).Infof("received %v", resp)
|
glog.V(0).Infof("received %v", resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isMultipartUploadDir(resp.Directory) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(resp.Directory, sourcePath) {
|
if !strings.HasPrefix(resp.Directory, sourcePath) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@ var cmdScaffold = &Command{
|
|||||||
For example, the filer.toml mysql password can be overwritten by environment variable
|
For example, the filer.toml mysql password can be overwritten by environment variable
|
||||||
export WEED_MYSQL_PASSWORD=some_password
|
export WEED_MYSQL_PASSWORD=some_password
|
||||||
Environment variable rules:
|
Environment variable rules:
|
||||||
* Prefix the variable name with "WEED_"
|
* Prefix the variable name with "WEED_".
|
||||||
* Uppercase the reset of variable name.
|
* Uppercase the rest of the variable name.
|
||||||
* Replace '.' with '_'
|
* Replace '.' with '_'.
|
||||||
|
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
|
|||||||
}
|
}
|
||||||
if defaultMux != readonlyMux {
|
if defaultMux != readonlyMux {
|
||||||
handleStaticResources(readonlyMux)
|
handleStaticResources(readonlyMux)
|
||||||
|
readonlyMux.HandleFunc("/healthz", fs.filerHealthzHandler)
|
||||||
readonlyMux.HandleFunc("/", fs.readonlyFilerHandler)
|
readonlyMux.HandleFunc("/", fs.readonlyFilerHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package weed_server
|
package weed_server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -9,7 +10,9 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/filer"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/security"
|
"github.com/seaweedfs/seaweedfs/weed/security"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||||
|
|
||||||
@ -44,7 +47,7 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Access-Control-Allow-Methods", "PUT, POST, GET, DELETE, OPTIONS")
|
w.Header().Set("Access-Control-Allow-Methods", "PUT, POST, GET, DELETE, OPTIONS")
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Method == "OPTIONS" {
|
if r.Method == http.MethodOptions {
|
||||||
OptionsHandler(w, r, false)
|
OptionsHandler(w, r, false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -66,7 +69,7 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
stats.FilerRequestHistogram.WithLabelValues(r.Method).Observe(time.Since(start).Seconds())
|
stats.FilerRequestHistogram.WithLabelValues(r.Method).Observe(time.Since(start).Seconds())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
isReadHttpCall := r.Method == "GET" || r.Method == "HEAD"
|
isReadHttpCall := r.Method == http.MethodGet || r.Method == http.MethodHead
|
||||||
if !fs.maybeCheckJwtAuthorization(r, !isReadHttpCall) {
|
if !fs.maybeCheckJwtAuthorization(r, !isReadHttpCall) {
|
||||||
writeJsonError(w, r, http.StatusUnauthorized, errors.New("wrong jwt"))
|
writeJsonError(w, r, http.StatusUnauthorized, errors.New("wrong jwt"))
|
||||||
return
|
return
|
||||||
@ -75,17 +78,15 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION)
|
w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION)
|
||||||
|
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "GET":
|
case http.MethodGet, http.MethodHead:
|
||||||
fs.GetOrHeadHandler(w, r)
|
fs.GetOrHeadHandler(w, r)
|
||||||
case "HEAD":
|
case http.MethodDelete:
|
||||||
fs.GetOrHeadHandler(w, r)
|
|
||||||
case "DELETE":
|
|
||||||
if _, ok := r.URL.Query()["tagging"]; ok {
|
if _, ok := r.URL.Query()["tagging"]; ok {
|
||||||
fs.DeleteTaggingHandler(w, r)
|
fs.DeleteTaggingHandler(w, r)
|
||||||
} else {
|
} else {
|
||||||
fs.DeleteHandler(w, r)
|
fs.DeleteHandler(w, r)
|
||||||
}
|
}
|
||||||
case "POST", "PUT":
|
case http.MethodPost, http.MethodPut:
|
||||||
// wait until in flight data is less than the limit
|
// wait until in flight data is less than the limit
|
||||||
contentLength := getContentLength(r)
|
contentLength := getContentLength(r)
|
||||||
fs.inFlightDataLimitCond.L.Lock()
|
fs.inFlightDataLimitCond.L.Lock()
|
||||||
@ -102,7 +103,7 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
fs.inFlightDataLimitCond.Signal()
|
fs.inFlightDataLimitCond.Signal()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if r.Method == "PUT" {
|
if r.Method == http.MethodPut {
|
||||||
if _, ok := r.URL.Query()["tagging"]; ok {
|
if _, ok := r.URL.Query()["tagging"]; ok {
|
||||||
fs.PutTaggingHandler(w, r)
|
fs.PutTaggingHandler(w, r)
|
||||||
} else {
|
} else {
|
||||||
@ -111,6 +112,8 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
} else { // method == "POST"
|
} else { // method == "POST"
|
||||||
fs.PostHandler(w, r, contentLength)
|
fs.PostHandler(w, r, contentLength)
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +152,7 @@ func (fs *FilerServer) readonlyFilerHandler(w http.ResponseWriter, r *http.Reque
|
|||||||
stats.FilerRequestHistogram.WithLabelValues(r.Method).Observe(time.Since(start).Seconds())
|
stats.FilerRequestHistogram.WithLabelValues(r.Method).Observe(time.Since(start).Seconds())
|
||||||
}()
|
}()
|
||||||
// We handle OPTIONS first because it never should be authenticated
|
// We handle OPTIONS first because it never should be authenticated
|
||||||
if r.Method == "OPTIONS" {
|
if r.Method == http.MethodOptions {
|
||||||
OptionsHandler(w, r, true)
|
OptionsHandler(w, r, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -162,10 +165,10 @@ func (fs *FilerServer) readonlyFilerHandler(w http.ResponseWriter, r *http.Reque
|
|||||||
w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION)
|
w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION)
|
||||||
|
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "GET":
|
case http.MethodGet, http.MethodHead:
|
||||||
fs.GetOrHeadHandler(w, r)
|
|
||||||
case "HEAD":
|
|
||||||
fs.GetOrHeadHandler(w, r)
|
fs.GetOrHeadHandler(w, r)
|
||||||
|
default:
|
||||||
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,5 +223,10 @@ func (fs *FilerServer) maybeCheckJwtAuthorization(r *http.Request, isWrite bool)
|
|||||||
|
|
||||||
func (fs *FilerServer) filerHealthzHandler(w http.ResponseWriter, r *http.Request) {
|
func (fs *FilerServer) filerHealthzHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION)
|
w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION)
|
||||||
|
if _, err := fs.filer.Store.FindEntry(context.Background(), filer.TopicsDir); err != nil && err != filer_pb.ErrNotFound {
|
||||||
|
glog.Warningf("filerHealthzHandler FindEntry: %+v", err)
|
||||||
|
w.WriteHeader(http.StatusServiceUnavailable)
|
||||||
|
} else {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/operation"
|
"github.com/seaweedfs/seaweedfs/weed/operation"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/security"
|
"github.com/seaweedfs/seaweedfs/weed/security"
|
||||||
@ -119,6 +120,13 @@ func (ms *MasterServer) dirAssignHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
vl := ms.Topo.GetVolumeLayout(option.Collection, option.ReplicaPlacement, option.Ttl, option.DiskType)
|
vl := ms.Topo.GetVolumeLayout(option.Collection, option.ReplicaPlacement, option.Ttl, option.DiskType)
|
||||||
|
|
||||||
|
var (
|
||||||
|
lastErr error
|
||||||
|
maxTimeout = time.Second * 10
|
||||||
|
startTime = time.Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
for time.Now().Sub(startTime) < maxTimeout {
|
||||||
fid, count, dnList, shouldGrow, err := ms.Topo.PickForWrite(requestedCount, option, vl)
|
fid, count, dnList, shouldGrow, err := ms.Topo.PickForWrite(requestedCount, option, vl)
|
||||||
if shouldGrow && !vl.HasGrowRequest() {
|
if shouldGrow && !vl.HasGrowRequest() {
|
||||||
// if picked volume is almost full, trigger a volume-grow request
|
// if picked volume is almost full, trigger a volume-grow request
|
||||||
@ -140,13 +148,24 @@ func (ms *MasterServer) dirAssignHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err != nil {
|
||||||
|
// glog.Warningf("PickForWrite %+v: %v", req, err)
|
||||||
|
lastErr = err
|
||||||
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
ms.maybeAddJwtAuthorization(w, fid, true)
|
ms.maybeAddJwtAuthorization(w, fid, true)
|
||||||
dn := dnList.Head()
|
dn := dnList.Head()
|
||||||
|
|
||||||
writeJsonQuiet(w, r, http.StatusOK, operation.AssignResult{Fid: fid, Url: dn.Url(), PublicUrl: dn.PublicUrl, Count: count})
|
writeJsonQuiet(w, r, http.StatusOK, operation.AssignResult{Fid: fid, Url: dn.Url(), PublicUrl: dn.PublicUrl, Count: count})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if lastErr != nil {
|
||||||
|
writeJsonQuiet(w, r, http.StatusNotAcceptable, operation.AssignResult{Error: lastErr.Error()})
|
||||||
} else {
|
} else {
|
||||||
writeJsonQuiet(w, r, http.StatusNotAcceptable, operation.AssignResult{Error: err.Error()})
|
writeJsonQuiet(w, r, http.StatusRequestTimeout, operation.AssignResult{Error: "request timeout"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user