mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c607071b57 | ||
|
|
94dd96a322 | ||
|
|
00e64441c6 | ||
|
|
d21bbd467c | ||
|
|
f11388a159 | ||
|
|
7eeb49ea51 | ||
|
|
e04a9ff8a0 | ||
|
|
959d4fd3ff |
No files matched your search
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/plugin_pb"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
@@ -614,7 +615,7 @@ func deriveSchedulerAdminRuntime(
|
||||
descriptor *plugin_pb.JobTypeDescriptor,
|
||||
) *plugin_pb.AdminRuntimeConfig {
|
||||
if cfg != nil && cfg.AdminRuntime != nil {
|
||||
adminConfig := *cfg.AdminRuntime
|
||||
adminConfig := proto.Clone(cfg.AdminRuntime).(*plugin_pb.AdminRuntimeConfig)
|
||||
// Overlay descriptor defaults for any zero numeric fields. Persisted
|
||||
// configs from older versions have no execution_timeout_seconds, and
|
||||
// without this overlay the scheduler would fall back to the 90s
|
||||
@@ -646,7 +647,7 @@ func deriveSchedulerAdminRuntime(
|
||||
adminConfig.ExecutionTimeoutSeconds = defaults.ExecutionTimeoutSeconds
|
||||
}
|
||||
}
|
||||
return &adminConfig
|
||||
return adminConfig
|
||||
}
|
||||
|
||||
if descriptor == nil || descriptor.AdminRuntimeDefaults == nil {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/plugin_pb"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
const defaultWorkerStaleTimeout = 2 * time.Minute
|
||||
@@ -495,36 +496,35 @@ func cloneJobTypeCapability(in *plugin_pb.JobTypeCapability) *plugin_pb.JobTypeC
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := *in
|
||||
return &out
|
||||
return proto.Clone(in).(*plugin_pb.JobTypeCapability)
|
||||
}
|
||||
|
||||
func cloneWorkerHeartbeat(in *plugin_pb.WorkerHeartbeat) *plugin_pb.WorkerHeartbeat {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := *in
|
||||
out := proto.Clone(in).(*plugin_pb.WorkerHeartbeat)
|
||||
if in.RunningWork != nil {
|
||||
out.RunningWork = make([]*plugin_pb.RunningWork, 0, len(in.RunningWork))
|
||||
for _, rw := range in.RunningWork {
|
||||
if rw == nil {
|
||||
continue
|
||||
running := out.RunningWork[:0]
|
||||
// Clone can turn nil messages into empty messages, so filter using
|
||||
// their original positions while reusing the cloned entries.
|
||||
for i, work := range in.RunningWork {
|
||||
if work != nil {
|
||||
running = append(running, out.RunningWork[i])
|
||||
}
|
||||
clone := *rw
|
||||
out.RunningWork = append(out.RunningWork, &clone)
|
||||
}
|
||||
}
|
||||
if in.QueuedJobsByType != nil {
|
||||
out.QueuedJobsByType = make(map[string]int32, len(in.QueuedJobsByType))
|
||||
for k, v := range in.QueuedJobsByType {
|
||||
out.QueuedJobsByType[k] = v
|
||||
clear(out.RunningWork[len(running):])
|
||||
if running == nil {
|
||||
running = []*plugin_pb.RunningWork{}
|
||||
}
|
||||
out.RunningWork = running
|
||||
}
|
||||
if in.Metadata != nil {
|
||||
out.Metadata = make(map[string]string, len(in.Metadata))
|
||||
for k, v := range in.Metadata {
|
||||
out.Metadata[k] = v
|
||||
}
|
||||
// Preserve writable empty maps without rebuilding populated clones.
|
||||
if in.QueuedJobsByType != nil && out.QueuedJobsByType == nil {
|
||||
out.QueuedJobsByType = make(map[string]int32)
|
||||
}
|
||||
return &out
|
||||
if in.Metadata != nil && out.Metadata == nil {
|
||||
out.Metadata = make(map[string]string)
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/plugin_pb"
|
||||
)
|
||||
|
||||
func TestCloneWorkerHeartbeatFiltersNilAndIsolatesState(t *testing.T) {
|
||||
t.Parallel()
|
||||
source := &plugin_pb.WorkerHeartbeat{
|
||||
RunningWork: []*plugin_pb.RunningWork{nil, {WorkId: "first"}, nil, {WorkId: "second"}, nil},
|
||||
QueuedJobsByType: map[string]int32{"vacuum": 2},
|
||||
Metadata: map[string]string{"rack": "rack-a"},
|
||||
}
|
||||
got := cloneWorkerHeartbeat(source)
|
||||
if len(got.RunningWork) != 2 || got.RunningWork[0].GetWorkId() != "first" || got.RunningWork[1].GetWorkId() != "second" {
|
||||
t.Fatalf("unexpected filtered work: %v", got.RunningWork)
|
||||
}
|
||||
got.RunningWork[0].WorkId = "changed"
|
||||
got.QueuedJobsByType["vacuum"] = 99
|
||||
got.Metadata["rack"] = "changed"
|
||||
if len(source.RunningWork) != 5 || source.RunningWork[0] != nil || source.RunningWork[1].WorkId != "first" {
|
||||
t.Fatalf("cloning mutated source work: %v", source.RunningWork)
|
||||
}
|
||||
if source.QueuedJobsByType["vacuum"] != 2 || source.Metadata["rack"] != "rack-a" {
|
||||
t.Fatal("cloned maps alias the source")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloneWorkerHeartbeatPreservesEmptyCollections(t *testing.T) {
|
||||
t.Parallel()
|
||||
if cloneWorkerHeartbeat(nil) != nil {
|
||||
t.Fatal("nil heartbeat must stay nil")
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
source *plugin_pb.WorkerHeartbeat
|
||||
wantNilWork bool
|
||||
}{
|
||||
{"nil", &plugin_pb.WorkerHeartbeat{}, true},
|
||||
{"empty", &plugin_pb.WorkerHeartbeat{
|
||||
RunningWork: []*plugin_pb.RunningWork{},
|
||||
QueuedJobsByType: map[string]int32{},
|
||||
Metadata: map[string]string{},
|
||||
}, false},
|
||||
{"all nil work", &plugin_pb.WorkerHeartbeat{RunningWork: []*plugin_pb.RunningWork{nil, nil}}, false},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got := cloneWorkerHeartbeat(tc.source)
|
||||
if len(got.RunningWork) != 0 || (got.RunningWork == nil) != tc.wantNilWork {
|
||||
t.Fatalf("unexpected empty work slice: %#v", got.RunningWork)
|
||||
}
|
||||
if (got.QueuedJobsByType == nil) != (tc.source.QueuedJobsByType == nil) || (got.Metadata == nil) != (tc.source.Metadata == nil) {
|
||||
t.Fatal("clone changed whether empty maps are writable")
|
||||
}
|
||||
if got.Metadata != nil {
|
||||
got.Metadata["added"] = "value"
|
||||
if len(tc.source.Metadata) != 0 {
|
||||
t.Fatal("empty metadata map aliases source")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
const LockRingStabilizationInterval = 1 * time.Second
|
||||
@@ -102,9 +103,7 @@ func (lrm *LockRingManager) GetLastUpdate(filerGroup FilerGroupName) *master_pb.
|
||||
if !ok || update == nil {
|
||||
return nil
|
||||
}
|
||||
cp := *update
|
||||
cp.Servers = append([]string(nil), update.Servers...)
|
||||
return &cp
|
||||
return proto.Clone(update).(*master_pb.LockRingUpdate)
|
||||
}
|
||||
|
||||
// scheduleBroadcast resets the stabilization timer. If another change arrives
|
||||
|
||||
@@ -214,11 +214,17 @@ func (option *RemoteGatewayOptions) makeBucketedEventProcessor(filerSource *sour
|
||||
}
|
||||
if filer_pb.IsCreate(resp) {
|
||||
if message.NewParentPath == option.bucketsDir {
|
||||
if isSystemPath(message.NewParentPath, message.NewEntry.Name) {
|
||||
return nil
|
||||
}
|
||||
return handleCreateBucket(message.NewEntry)
|
||||
}
|
||||
if isMultipartUploadFile(message.NewParentPath, message.NewEntry.Name) {
|
||||
return nil
|
||||
}
|
||||
if isSystemPath(message.NewParentPath, message.NewEntry.Name) {
|
||||
return nil
|
||||
}
|
||||
// Propagate delete markers as deletions on the remote.
|
||||
// Delete markers are zero-content version entries, so they
|
||||
// would be filtered out by the HasData check below.
|
||||
@@ -292,6 +298,9 @@ func (option *RemoteGatewayOptions) makeBucketedEventProcessor(filerSource *sour
|
||||
return nil
|
||||
}
|
||||
if resp.Directory == option.bucketsDir {
|
||||
if isSystemPath(resp.Directory, message.OldEntry.Name) {
|
||||
return nil
|
||||
}
|
||||
return handleDeleteBucket(message.OldEntry)
|
||||
}
|
||||
// Skip deletion of internal version files; individual version
|
||||
@@ -300,6 +309,9 @@ func (option *RemoteGatewayOptions) makeBucketedEventProcessor(filerSource *sour
|
||||
glog.V(2).Infof("skipping delete of internal version path: %s/%s", resp.Directory, message.OldEntry.Name)
|
||||
return nil
|
||||
}
|
||||
if isSystemPath(resp.Directory, message.OldEntry.Name) {
|
||||
return nil
|
||||
}
|
||||
bucket, remoteStorageMountLocation, remoteStorage, ok := option.detectBucketInfo(resp.Directory)
|
||||
if !ok {
|
||||
return nil
|
||||
@@ -323,6 +335,9 @@ func (option *RemoteGatewayOptions) makeBucketedEventProcessor(filerSource *sour
|
||||
if message.OldEntry.Name == message.NewEntry.Name {
|
||||
return nil
|
||||
}
|
||||
if isSystemPath(resp.Directory, message.OldEntry.Name) || isSystemPath(message.NewParentPath, message.NewEntry.Name) {
|
||||
return nil
|
||||
}
|
||||
if err := handleCreateBucket(message.NewEntry); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -339,6 +354,9 @@ func (option *RemoteGatewayOptions) makeBucketedEventProcessor(filerSource *sour
|
||||
glog.V(2).Infof("skipping update of internal version path: %s/%s", message.NewParentPath, message.NewEntry.Name)
|
||||
return nil
|
||||
}
|
||||
if isSystemPath(message.NewParentPath, message.NewEntry.Name) {
|
||||
return nil
|
||||
}
|
||||
oldBucket, oldRemoteStorageMountLocation, oldRemoteStorage, oldOk := option.detectBucketInfo(resp.Directory)
|
||||
newBucket, newRemoteStorageMountLocation, newRemoteStorage, newOk := option.detectBucketInfo(message.NewParentPath)
|
||||
if oldOk && newOk {
|
||||
|
||||
@@ -144,6 +144,10 @@ func (option *RemoteSyncOptions) makeEventProcessor(remoteStorage *remote_pb.Rem
|
||||
if isMultipartUploadFile(message.NewParentPath, message.NewEntry.Name) {
|
||||
return nil
|
||||
}
|
||||
if isSystemPath(message.NewParentPath, message.NewEntry.Name) {
|
||||
glog.V(2).Infof("skipping create of system path: %s/%s", message.NewParentPath, message.NewEntry.Name)
|
||||
return nil
|
||||
}
|
||||
// Propagate delete markers as deletions on the remote.
|
||||
// Delete markers are zero-content version entries, so they
|
||||
// would be filtered out by the HasData check below.
|
||||
@@ -229,6 +233,10 @@ func processDeleteEvent(
|
||||
glog.V(2).Infof("skipping delete of internal version path: %s/%s", resp.Directory, message.OldEntry.Name)
|
||||
return nil
|
||||
}
|
||||
if isSystemPath(resp.Directory, message.OldEntry.Name) {
|
||||
glog.V(2).Infof("skipping delete of system path: %s/%s", resp.Directory, message.OldEntry.Name)
|
||||
return nil
|
||||
}
|
||||
if filer.IsMetadataOnlyDelete(message.OldEntry) {
|
||||
glog.V(2).Infof("skipping remote delete of metadata-only delete: %s/%s", resp.Directory, message.OldEntry.Name)
|
||||
return nil
|
||||
@@ -339,6 +347,10 @@ func processUpdateEvent(
|
||||
glog.V(2).Infof("skipping update of internal version path: %s/%s", message.NewParentPath, message.NewEntry.Name)
|
||||
return nil
|
||||
}
|
||||
if isSystemPath(message.NewParentPath, message.NewEntry.Name) {
|
||||
glog.V(2).Infof("skipping update of system path: %s/%s", message.NewParentPath, message.NewEntry.Name)
|
||||
return nil
|
||||
}
|
||||
oldDest := toRemoteStorageLocation(util.FullPath(mountedDir), util.NewFullPath(resp.Directory, message.OldEntry.Name), remoteStorageMountLocation)
|
||||
dest := toRemoteStorageLocation(util.FullPath(mountedDir), util.NewFullPath(message.NewParentPath, message.NewEntry.Name), remoteStorageMountLocation)
|
||||
eventSource := renameSource{path: util.NewFullPath(resp.Directory, message.OldEntry.Name), loc: oldDest, stamp: message.OldEntry.GetRemoteEntry()}
|
||||
@@ -428,7 +440,7 @@ func processUpdateEvent(
|
||||
}
|
||||
glog.V(0).Infof("delete %s", remote_storage.FormatLocation(oldDest))
|
||||
if err := client.DeleteFile(oldDest); err != nil {
|
||||
if isMultipartUploadFile(resp.Directory, message.OldEntry.Name) {
|
||||
if isMultipartUploadFile(resp.Directory, message.OldEntry.Name) || isSystemPath(resp.Directory, message.OldEntry.Name) {
|
||||
return nil
|
||||
}
|
||||
if !errors.Is(err, remote_storage.ErrRemoteObjectNotFound) {
|
||||
@@ -881,6 +893,23 @@ func isMultipartUploadDir(dir string) bool {
|
||||
strings.Contains(dir, "/"+s3_constants.MultipartUploadsFolder+"/")
|
||||
}
|
||||
|
||||
// isSystemPath returns true if the dir and name refer to the internal .system folder
|
||||
// under /buckets (such as the bucket-owner index at /buckets/.system/owners/...)
|
||||
// or any entry inside it. These paths are internal to SeaweedFS and must not
|
||||
// be synced to remote storage.
|
||||
func isSystemPath(dir string, name string) bool {
|
||||
fullPath := string(util.NewFullPath(dir, name))
|
||||
trimmed := strings.Trim(fullPath, "/")
|
||||
parts := strings.Split(trimmed, "/")
|
||||
if len(parts) >= 1 && parts[0] == s3_constants.SystemFolder {
|
||||
return true
|
||||
}
|
||||
if len(parts) >= 2 && parts[1] == s3_constants.SystemFolder {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// isDeleteMarker returns true if the entry is an S3 delete marker
|
||||
// (a zero-content version entry with ExtDeleteMarkerKey set to "true").
|
||||
func isDeleteMarker(entry *filer_pb.Entry) bool {
|
||||
|
||||
@@ -2016,3 +2016,74 @@ func TestMetadataUpdateKeepsTheStoredStampOnNilResult(t *testing.T) {
|
||||
t.Fatalf("stamped RemoteEntry = %+v, want the entry's own stamp kept (mtime 100)", filerClient.updated.Entry.RemoteEntry)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsSystemPath(t *testing.T) {
|
||||
tests := []struct {
|
||||
dir string
|
||||
name string
|
||||
expected bool
|
||||
}{
|
||||
{dir: "/buckets", name: ".system", expected: true},
|
||||
{dir: "/buckets/.system", name: "owners", expected: true},
|
||||
{dir: "/buckets/.system/owners", name: "alice", expected: true},
|
||||
{dir: "/buckets/.system/owners/alice", name: "mybucket", expected: true},
|
||||
{dir: "/", name: ".system", expected: true},
|
||||
{dir: "/.system", name: "config", expected: true},
|
||||
{dir: "/custom-mount", name: ".system", expected: true},
|
||||
{dir: "/custom-mount/.system/owners", name: "alice", expected: true},
|
||||
// Bucket contents should not match
|
||||
{dir: "/buckets/mybucket", name: "file.txt", expected: false},
|
||||
{dir: "/buckets/mybucket", name: ".system", expected: false},
|
||||
{dir: "/buckets/mybucket/.system", name: "data", expected: false},
|
||||
{dir: "/buckets", name: ".system-other", expected: false},
|
||||
{dir: "/buckets/.system-other", name: "sub", expected: false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(fmt.Sprintf("%s/%s", tt.dir, tt.name), func(t *testing.T) {
|
||||
got := isSystemPath(tt.dir, tt.name)
|
||||
if got != tt.expected {
|
||||
t.Errorf("isSystemPath(%q, %q) = %v, want %v", tt.dir, tt.name, got, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoteSyncSkipsSystemFolder(t *testing.T) {
|
||||
const mountedDir = "/buckets"
|
||||
mountLoc := &remote_pb.RemoteStorageLocation{Name: "azure", Bucket: "project-storage", Path: "/"}
|
||||
|
||||
// Test update event on /buckets/.system/owners/... is skipped
|
||||
updateResp := &filer_pb.SubscribeMetadataResponse{
|
||||
Directory: "/buckets/.system/owners/structify-api",
|
||||
EventNotification: &filer_pb.EventNotification{
|
||||
OldEntry: &filer_pb.Entry{Name: "structify-copy-canary"},
|
||||
NewParentPath: "/buckets/.system/owners/structify-api",
|
||||
NewEntry: &filer_pb.Entry{Name: "structify-copy-canary"},
|
||||
},
|
||||
}
|
||||
remote := &recordingRemote{}
|
||||
filerClient := &stubFilerClient{}
|
||||
if err := processUpdateEvent(filerClient, filerClient, "", remote, mountedDir, mountLoc, updateResp); err != nil {
|
||||
t.Fatalf("processUpdateEvent failed: %v", err)
|
||||
}
|
||||
if len(remote.writes) != 0 || len(remote.metadataUpdates) != 0 {
|
||||
t.Fatalf("expected 0 remote writes or metadata updates for system path, got %d writes and %d metadata updates",
|
||||
len(remote.writes), len(remote.metadataUpdates))
|
||||
}
|
||||
|
||||
// Test delete event on /buckets/.system/owners/... is skipped
|
||||
deleteResp := &filer_pb.SubscribeMetadataResponse{
|
||||
Directory: "/buckets/.system/owners/structify-api",
|
||||
EventNotification: &filer_pb.EventNotification{
|
||||
OldEntry: &filer_pb.Entry{Name: "structify-copy-canary"},
|
||||
},
|
||||
}
|
||||
if err := processDeleteEvent(filerClient, remote, mountedDir, mountLoc, deleteResp); err != nil {
|
||||
t.Fatalf("processDeleteEvent failed: %v", err)
|
||||
}
|
||||
if len(remote.deletes) != 0 {
|
||||
t.Fatalf("expected 0 remote deletes for system path, got %d deletes", len(remote.deletes))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/wdclient"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// FilerAddressSetter is an interface for credential stores that need a dynamic filer address
|
||||
@@ -168,15 +169,16 @@ func (cm *CredentialManager) SaveConfiguration(ctx context.Context, config *iam_
|
||||
staticNames := cm.staticNames
|
||||
cm.staticMu.RUnlock()
|
||||
if len(staticNames) > 0 {
|
||||
var dynamicOnly []*iam_pb.Identity
|
||||
for _, ident := range config.Identities {
|
||||
configCopy := proto.Clone(config).(*iam_pb.S3ApiConfiguration)
|
||||
dynamicOnly := configCopy.Identities[:0]
|
||||
for _, ident := range configCopy.Identities {
|
||||
if !staticNames[ident.Name] {
|
||||
dynamicOnly = append(dynamicOnly, ident)
|
||||
}
|
||||
}
|
||||
configCopy := *config
|
||||
clear(configCopy.Identities[len(dynamicOnly):])
|
||||
configCopy.Identities = dynamicOnly
|
||||
return cm.Store.SaveConfiguration(ctx, &configCopy)
|
||||
return cm.Store.SaveConfiguration(ctx, configCopy)
|
||||
}
|
||||
return cm.Store.SaveConfiguration(ctx, config)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package credential
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/iam_pb"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type snapshotConfigurationStore struct {
|
||||
CredentialStore
|
||||
saved *iam_pb.S3ApiConfiguration
|
||||
}
|
||||
|
||||
func (s *snapshotConfigurationStore) SaveConfiguration(_ context.Context, config *iam_pb.S3ApiConfiguration) error {
|
||||
s.saved = config
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestSaveConfigurationFiltersStaticIdentitySnapshot(t *testing.T) {
|
||||
t.Parallel()
|
||||
store := &snapshotConfigurationStore{}
|
||||
manager := &CredentialManager{Store: store}
|
||||
manager.SetStaticIdentities([]*iam_pb.Identity{{Name: "static"}})
|
||||
source := &iam_pb.S3ApiConfiguration{Identities: []*iam_pb.Identity{
|
||||
{Name: "alice", Actions: []string{"Read"}},
|
||||
{Name: "static"},
|
||||
{Name: "bob", Actions: []string{"Write"}},
|
||||
}}
|
||||
before := proto.Clone(source)
|
||||
if err := manager.SaveConfiguration(context.Background(), source); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if store.saved == nil || len(store.saved.Identities) != 2 || store.saved.Identities[0].Name != "alice" || store.saved.Identities[1].Name != "bob" {
|
||||
t.Fatalf("unexpected saved configuration: %v", store.saved)
|
||||
}
|
||||
if !proto.Equal(source, before) {
|
||||
t.Fatal("filtering mutated the caller's configuration")
|
||||
}
|
||||
store.saved.Identities[0].Actions[0] = "Admin"
|
||||
store.saved.Identities[1].Name = "changed"
|
||||
if !proto.Equal(source, before) {
|
||||
t.Fatal("saved identities alias the caller's configuration")
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// fakeFilerClient captures MountRegister/MountList calls and lets the test
|
||||
@@ -17,22 +18,21 @@ type fakeFilerClient struct {
|
||||
filer_pb.SeaweedFilerClient // embed for methods we don't need
|
||||
|
||||
mu sync.Mutex
|
||||
registerCalls []filer_pb.MountRegisterRequest
|
||||
registerCalls []*filer_pb.MountRegisterRequest
|
||||
listResponse filer_pb.MountListResponse
|
||||
}
|
||||
|
||||
func (f *fakeFilerClient) MountRegister(ctx context.Context, req *filer_pb.MountRegisterRequest, opts ...grpc.CallOption) (*filer_pb.MountRegisterResponse, error) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
f.registerCalls = append(f.registerCalls, *req)
|
||||
f.registerCalls = append(f.registerCalls, proto.Clone(req).(*filer_pb.MountRegisterRequest))
|
||||
return &filer_pb.MountRegisterResponse{}, nil
|
||||
}
|
||||
|
||||
func (f *fakeFilerClient) MountList(ctx context.Context, req *filer_pb.MountListRequest, opts ...grpc.CallOption) (*filer_pb.MountListResponse, error) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
resp := f.listResponse // value copy
|
||||
return &resp, nil
|
||||
return proto.Clone(&f.listResponse).(*filer_pb.MountListResponse), nil
|
||||
}
|
||||
|
||||
// fakeFilerFleet maps each addr to its own fakeFilerClient so a test can
|
||||
|
||||
@@ -522,11 +522,16 @@ message DeleteEntryRequest {
|
||||
repeated int32 signatures = 8;
|
||||
int64 if_not_modified_after = 9;
|
||||
bool keep_remote_object = 10;
|
||||
// Optional precondition evaluated against the current entry atomically with
|
||||
// the delete, under the filer's per-path lock. A failed condition reports
|
||||
// FilerError PRECONDITION_FAILED and deletes nothing.
|
||||
WriteCondition condition = 11;
|
||||
}
|
||||
|
||||
message DeleteEntryResponse {
|
||||
string error = 1;
|
||||
SubscribeMetadataResponse metadata_event = 2;
|
||||
FilerError error_code = 3;
|
||||
}
|
||||
|
||||
message AtomicRenameEntryRequest {
|
||||
|
||||
+141
-117
@@ -2771,8 +2771,12 @@ type DeleteEntryRequest struct {
|
||||
Signatures []int32 `protobuf:"varint,8,rep,packed,name=signatures,proto3" json:"signatures,omitempty"`
|
||||
IfNotModifiedAfter int64 `protobuf:"varint,9,opt,name=if_not_modified_after,json=ifNotModifiedAfter,proto3" json:"if_not_modified_after,omitempty"`
|
||||
KeepRemoteObject bool `protobuf:"varint,10,opt,name=keep_remote_object,json=keepRemoteObject,proto3" json:"keep_remote_object,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
// Optional precondition evaluated against the current entry atomically with
|
||||
// the delete, under the filer's per-path lock. A failed condition reports
|
||||
// FilerError PRECONDITION_FAILED and deletes nothing.
|
||||
Condition *WriteCondition `protobuf:"bytes,11,opt,name=condition,proto3" json:"condition,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *DeleteEntryRequest) Reset() {
|
||||
@@ -2868,10 +2872,18 @@ func (x *DeleteEntryRequest) GetKeepRemoteObject() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *DeleteEntryRequest) GetCondition() *WriteCondition {
|
||||
if x != nil {
|
||||
return x.Condition
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeleteEntryResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"`
|
||||
MetadataEvent *SubscribeMetadataResponse `protobuf:"bytes,2,opt,name=metadata_event,json=metadataEvent,proto3" json:"metadata_event,omitempty"`
|
||||
ErrorCode FilerError `protobuf:"varint,3,opt,name=error_code,json=errorCode,proto3,enum=filer_pb.FilerError" json:"error_code,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -2920,6 +2932,13 @@ func (x *DeleteEntryResponse) GetMetadataEvent() *SubscribeMetadataResponse {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *DeleteEntryResponse) GetErrorCode() FilerError {
|
||||
if x != nil {
|
||||
return x.ErrorCode
|
||||
}
|
||||
return FilerError_OK
|
||||
}
|
||||
|
||||
type AtomicRenameEntryRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
OldDirectory string `protobuf:"bytes,1,opt,name=old_directory,json=oldDirectory,proto3" json:"old_directory,omitempty"`
|
||||
@@ -7539,7 +7558,7 @@ const file_filer_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"entry_name\x18\x02 \x01(\tR\tentryName\x12+\n" +
|
||||
"\x06chunks\x18\x03 \x03(\v2\x13.filer_pb.FileChunkR\x06chunks\"\x17\n" +
|
||||
"\x15AppendToEntryResponse\"\xf9\x02\n" +
|
||||
"\x15AppendToEntryResponse\"\xb1\x03\n" +
|
||||
"\x12DeleteEntryRequest\x12\x1c\n" +
|
||||
"\tdirectory\x18\x01 \x01(\tR\tdirectory\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04name\x12$\n" +
|
||||
@@ -7552,10 +7571,13 @@ const file_filer_proto_rawDesc = "" +
|
||||
"signatures\x121\n" +
|
||||
"\x15if_not_modified_after\x18\t \x01(\x03R\x12ifNotModifiedAfter\x12,\n" +
|
||||
"\x12keep_remote_object\x18\n" +
|
||||
" \x01(\bR\x10keepRemoteObject\"w\n" +
|
||||
" \x01(\bR\x10keepRemoteObject\x126\n" +
|
||||
"\tcondition\x18\v \x01(\v2\x18.filer_pb.WriteConditionR\tcondition\"\xac\x01\n" +
|
||||
"\x13DeleteEntryResponse\x12\x14\n" +
|
||||
"\x05error\x18\x01 \x01(\tR\x05error\x12J\n" +
|
||||
"\x0emetadata_event\x18\x02 \x01(\v2#.filer_pb.SubscribeMetadataResponseR\rmetadataEvent\"\xed\x01\n" +
|
||||
"\x0emetadata_event\x18\x02 \x01(\v2#.filer_pb.SubscribeMetadataResponseR\rmetadataEvent\x123\n" +
|
||||
"\n" +
|
||||
"error_code\x18\x03 \x01(\x0e2\x14.filer_pb.FilerErrorR\terrorCode\"\xed\x01\n" +
|
||||
"\x18AtomicRenameEntryRequest\x12#\n" +
|
||||
"\rold_directory\x18\x01 \x01(\tR\foldDirectory\x12\x19\n" +
|
||||
"\bold_name\x18\x02 \x01(\tR\aoldName\x12#\n" +
|
||||
@@ -8142,118 +8164,120 @@ var file_filer_proto_depIdxs = []int32{
|
||||
18, // 34: filer_pb.UpdateEntryRequest.condition:type_name -> filer_pb.WriteCondition
|
||||
59, // 35: filer_pb.UpdateEntryResponse.metadata_event:type_name -> filer_pb.SubscribeMetadataResponse
|
||||
13, // 36: filer_pb.AppendToEntryRequest.chunks:type_name -> filer_pb.FileChunk
|
||||
59, // 37: filer_pb.DeleteEntryResponse.metadata_event:type_name -> filer_pb.SubscribeMetadataResponse
|
||||
12, // 38: filer_pb.StreamRenameEntryResponse.event_notification:type_name -> filer_pb.EventNotification
|
||||
45, // 39: filer_pb.AssignVolumeResponse.location:type_name -> filer_pb.Location
|
||||
45, // 40: filer_pb.AssignVolumeResponse.replicas:type_name -> filer_pb.Location
|
||||
1, // 41: filer_pb.AssignVolumeResponse.error_code:type_name -> filer_pb.FilerError
|
||||
45, // 42: filer_pb.Locations.locations:type_name -> filer_pb.Location
|
||||
104, // 43: filer_pb.LookupVolumeResponse.locations_map:type_name -> filer_pb.LookupVolumeResponse.LocationsMapEntry
|
||||
47, // 44: filer_pb.CollectionListResponse.collections:type_name -> filer_pb.Collection
|
||||
12, // 45: filer_pb.SubscribeMetadataResponse.event_notification:type_name -> filer_pb.EventNotification
|
||||
59, // 46: filer_pb.SubscribeMetadataResponse.events:type_name -> filer_pb.SubscribeMetadataResponse
|
||||
63, // 47: filer_pb.SubscribeMetadataResponse.log_file_refs:type_name -> filer_pb.LogFileChunkRef
|
||||
62, // 48: filer_pb.ListMetadataSubscribersResponse.subscribers:type_name -> filer_pb.MetadataSubscriber
|
||||
13, // 49: filer_pb.LogFileChunkRef.chunks:type_name -> filer_pb.FileChunk
|
||||
10, // 50: filer_pb.TraverseBfsMetadataResponse.entry:type_name -> filer_pb.Entry
|
||||
105, // 51: filer_pb.LocateBrokerResponse.resources:type_name -> filer_pb.LocateBrokerResponse.Resource
|
||||
106, // 52: filer_pb.FilerConf.locations:type_name -> filer_pb.FilerConf.PathConf
|
||||
10, // 53: filer_pb.CacheRemoteObjectToLocalClusterResponse.entry:type_name -> filer_pb.Entry
|
||||
59, // 54: filer_pb.CacheRemoteObjectToLocalClusterResponse.metadata_event:type_name -> filer_pb.SubscribeMetadataResponse
|
||||
84, // 55: filer_pb.TransferLocksRequest.locks:type_name -> filer_pb.Lock
|
||||
17, // 56: filer_pb.StreamMutateEntryRequest.create_request:type_name -> filer_pb.CreateEntryRequest
|
||||
29, // 57: filer_pb.StreamMutateEntryRequest.update_request:type_name -> filer_pb.UpdateEntryRequest
|
||||
35, // 58: filer_pb.StreamMutateEntryRequest.delete_request:type_name -> filer_pb.DeleteEntryRequest
|
||||
39, // 59: filer_pb.StreamMutateEntryRequest.rename_request:type_name -> filer_pb.StreamRenameEntryRequest
|
||||
28, // 60: filer_pb.StreamMutateEntryResponse.create_response:type_name -> filer_pb.CreateEntryResponse
|
||||
30, // 61: filer_pb.StreamMutateEntryResponse.update_response:type_name -> filer_pb.UpdateEntryResponse
|
||||
36, // 62: filer_pb.StreamMutateEntryResponse.delete_response:type_name -> filer_pb.DeleteEntryResponse
|
||||
40, // 63: filer_pb.StreamMutateEntryResponse.rename_response:type_name -> filer_pb.StreamRenameEntryResponse
|
||||
95, // 64: filer_pb.MountListResponse.mounts:type_name -> filer_pb.MountInfo
|
||||
5, // 65: filer_pb.LookupDirectoryEntriesRequest.requests:type_name -> filer_pb.LookupDirectoryEntryRequest
|
||||
10, // 66: filer_pb.LookupDirectoryEntryResult.entry:type_name -> filer_pb.Entry
|
||||
97, // 67: filer_pb.LookupDirectoryEntriesResponse.results:type_name -> filer_pb.LookupDirectoryEntryResult
|
||||
107, // 68: filer_pb.LookupDirectoryEntriesResponse.locations_map:type_name -> filer_pb.LookupDirectoryEntriesResponse.LocationsMapEntry
|
||||
108, // 69: filer_pb.LookupDirectoryEntriesResponse.read_auth:type_name -> filer_pb.LookupDirectoryEntriesResponse.ReadAuthEntry
|
||||
3, // 70: filer_pb.WriteCondition.Clause.kind:type_name -> filer_pb.WriteCondition.Kind
|
||||
10, // 71: filer_pb.WriteCondition.Clause.expected_entry:type_name -> filer_pb.Entry
|
||||
44, // 72: filer_pb.LookupVolumeResponse.LocationsMapEntry.value:type_name -> filer_pb.Locations
|
||||
44, // 73: filer_pb.LookupDirectoryEntriesResponse.LocationsMapEntry.value:type_name -> filer_pb.Locations
|
||||
5, // 74: filer_pb.SeaweedFiler.LookupDirectoryEntry:input_type -> filer_pb.LookupDirectoryEntryRequest
|
||||
96, // 75: filer_pb.SeaweedFiler.LookupDirectoryEntries:input_type -> filer_pb.LookupDirectoryEntriesRequest
|
||||
7, // 76: filer_pb.SeaweedFiler.ListEntries:input_type -> filer_pb.ListEntriesRequest
|
||||
17, // 77: filer_pb.SeaweedFiler.CreateEntry:input_type -> filer_pb.CreateEntryRequest
|
||||
29, // 78: filer_pb.SeaweedFiler.UpdateEntry:input_type -> filer_pb.UpdateEntryRequest
|
||||
31, // 79: filer_pb.SeaweedFiler.TouchAccessTime:input_type -> filer_pb.TouchAccessTimeRequest
|
||||
33, // 80: filer_pb.SeaweedFiler.AppendToEntry:input_type -> filer_pb.AppendToEntryRequest
|
||||
35, // 81: filer_pb.SeaweedFiler.DeleteEntry:input_type -> filer_pb.DeleteEntryRequest
|
||||
21, // 82: filer_pb.SeaweedFiler.ObjectTransaction:input_type -> filer_pb.ObjectTransactionRequest
|
||||
26, // 83: filer_pb.SeaweedFiler.ObjectTransactionBatch:input_type -> filer_pb.ObjectTransactionBatchRequest
|
||||
24, // 84: filer_pb.SeaweedFiler.PosixLock:input_type -> filer_pb.PosixLockRequest
|
||||
37, // 85: filer_pb.SeaweedFiler.AtomicRenameEntry:input_type -> filer_pb.AtomicRenameEntryRequest
|
||||
39, // 86: filer_pb.SeaweedFiler.StreamRenameEntry:input_type -> filer_pb.StreamRenameEntryRequest
|
||||
89, // 87: filer_pb.SeaweedFiler.StreamMutateEntry:input_type -> filer_pb.StreamMutateEntryRequest
|
||||
41, // 88: filer_pb.SeaweedFiler.AssignVolume:input_type -> filer_pb.AssignVolumeRequest
|
||||
43, // 89: filer_pb.SeaweedFiler.LookupVolume:input_type -> filer_pb.LookupVolumeRequest
|
||||
48, // 90: filer_pb.SeaweedFiler.CollectionList:input_type -> filer_pb.CollectionListRequest
|
||||
50, // 91: filer_pb.SeaweedFiler.DeleteCollection:input_type -> filer_pb.DeleteCollectionRequest
|
||||
52, // 92: filer_pb.SeaweedFiler.Statistics:input_type -> filer_pb.StatisticsRequest
|
||||
54, // 93: filer_pb.SeaweedFiler.Ping:input_type -> filer_pb.PingRequest
|
||||
56, // 94: filer_pb.SeaweedFiler.GetFilerConfiguration:input_type -> filer_pb.GetFilerConfigurationRequest
|
||||
64, // 95: filer_pb.SeaweedFiler.TraverseBfsMetadata:input_type -> filer_pb.TraverseBfsMetadataRequest
|
||||
58, // 96: filer_pb.SeaweedFiler.SubscribeMetadata:input_type -> filer_pb.SubscribeMetadataRequest
|
||||
58, // 97: filer_pb.SeaweedFiler.SubscribeLocalMetadata:input_type -> filer_pb.SubscribeMetadataRequest
|
||||
60, // 98: filer_pb.SeaweedFiler.ListMetadataSubscribers:input_type -> filer_pb.ListMetadataSubscribersRequest
|
||||
71, // 99: filer_pb.SeaweedFiler.KvGet:input_type -> filer_pb.KvGetRequest
|
||||
73, // 100: filer_pb.SeaweedFiler.KvPut:input_type -> filer_pb.KvPutRequest
|
||||
76, // 101: filer_pb.SeaweedFiler.CacheRemoteObjectToLocalCluster:input_type -> filer_pb.CacheRemoteObjectToLocalClusterRequest
|
||||
78, // 102: filer_pb.SeaweedFiler.DistributedLock:input_type -> filer_pb.LockRequest
|
||||
80, // 103: filer_pb.SeaweedFiler.DistributedUnlock:input_type -> filer_pb.UnlockRequest
|
||||
82, // 104: filer_pb.SeaweedFiler.FindLockOwner:input_type -> filer_pb.FindLockOwnerRequest
|
||||
85, // 105: filer_pb.SeaweedFiler.TransferLocks:input_type -> filer_pb.TransferLocksRequest
|
||||
87, // 106: filer_pb.SeaweedFiler.ReplicateLock:input_type -> filer_pb.ReplicateLockRequest
|
||||
91, // 107: filer_pb.SeaweedFiler.MountRegister:input_type -> filer_pb.MountRegisterRequest
|
||||
93, // 108: filer_pb.SeaweedFiler.MountList:input_type -> filer_pb.MountListRequest
|
||||
6, // 109: filer_pb.SeaweedFiler.LookupDirectoryEntry:output_type -> filer_pb.LookupDirectoryEntryResponse
|
||||
98, // 110: filer_pb.SeaweedFiler.LookupDirectoryEntries:output_type -> filer_pb.LookupDirectoryEntriesResponse
|
||||
8, // 111: filer_pb.SeaweedFiler.ListEntries:output_type -> filer_pb.ListEntriesResponse
|
||||
28, // 112: filer_pb.SeaweedFiler.CreateEntry:output_type -> filer_pb.CreateEntryResponse
|
||||
30, // 113: filer_pb.SeaweedFiler.UpdateEntry:output_type -> filer_pb.UpdateEntryResponse
|
||||
32, // 114: filer_pb.SeaweedFiler.TouchAccessTime:output_type -> filer_pb.TouchAccessTimeResponse
|
||||
34, // 115: filer_pb.SeaweedFiler.AppendToEntry:output_type -> filer_pb.AppendToEntryResponse
|
||||
36, // 116: filer_pb.SeaweedFiler.DeleteEntry:output_type -> filer_pb.DeleteEntryResponse
|
||||
22, // 117: filer_pb.SeaweedFiler.ObjectTransaction:output_type -> filer_pb.ObjectTransactionResponse
|
||||
27, // 118: filer_pb.SeaweedFiler.ObjectTransactionBatch:output_type -> filer_pb.ObjectTransactionBatchResponse
|
||||
25, // 119: filer_pb.SeaweedFiler.PosixLock:output_type -> filer_pb.PosixLockResponse
|
||||
38, // 120: filer_pb.SeaweedFiler.AtomicRenameEntry:output_type -> filer_pb.AtomicRenameEntryResponse
|
||||
40, // 121: filer_pb.SeaweedFiler.StreamRenameEntry:output_type -> filer_pb.StreamRenameEntryResponse
|
||||
90, // 122: filer_pb.SeaweedFiler.StreamMutateEntry:output_type -> filer_pb.StreamMutateEntryResponse
|
||||
42, // 123: filer_pb.SeaweedFiler.AssignVolume:output_type -> filer_pb.AssignVolumeResponse
|
||||
46, // 124: filer_pb.SeaweedFiler.LookupVolume:output_type -> filer_pb.LookupVolumeResponse
|
||||
49, // 125: filer_pb.SeaweedFiler.CollectionList:output_type -> filer_pb.CollectionListResponse
|
||||
51, // 126: filer_pb.SeaweedFiler.DeleteCollection:output_type -> filer_pb.DeleteCollectionResponse
|
||||
53, // 127: filer_pb.SeaweedFiler.Statistics:output_type -> filer_pb.StatisticsResponse
|
||||
55, // 128: filer_pb.SeaweedFiler.Ping:output_type -> filer_pb.PingResponse
|
||||
57, // 129: filer_pb.SeaweedFiler.GetFilerConfiguration:output_type -> filer_pb.GetFilerConfigurationResponse
|
||||
65, // 130: filer_pb.SeaweedFiler.TraverseBfsMetadata:output_type -> filer_pb.TraverseBfsMetadataResponse
|
||||
59, // 131: filer_pb.SeaweedFiler.SubscribeMetadata:output_type -> filer_pb.SubscribeMetadataResponse
|
||||
59, // 132: filer_pb.SeaweedFiler.SubscribeLocalMetadata:output_type -> filer_pb.SubscribeMetadataResponse
|
||||
61, // 133: filer_pb.SeaweedFiler.ListMetadataSubscribers:output_type -> filer_pb.ListMetadataSubscribersResponse
|
||||
72, // 134: filer_pb.SeaweedFiler.KvGet:output_type -> filer_pb.KvGetResponse
|
||||
74, // 135: filer_pb.SeaweedFiler.KvPut:output_type -> filer_pb.KvPutResponse
|
||||
77, // 136: filer_pb.SeaweedFiler.CacheRemoteObjectToLocalCluster:output_type -> filer_pb.CacheRemoteObjectToLocalClusterResponse
|
||||
79, // 137: filer_pb.SeaweedFiler.DistributedLock:output_type -> filer_pb.LockResponse
|
||||
81, // 138: filer_pb.SeaweedFiler.DistributedUnlock:output_type -> filer_pb.UnlockResponse
|
||||
83, // 139: filer_pb.SeaweedFiler.FindLockOwner:output_type -> filer_pb.FindLockOwnerResponse
|
||||
86, // 140: filer_pb.SeaweedFiler.TransferLocks:output_type -> filer_pb.TransferLocksResponse
|
||||
88, // 141: filer_pb.SeaweedFiler.ReplicateLock:output_type -> filer_pb.ReplicateLockResponse
|
||||
92, // 142: filer_pb.SeaweedFiler.MountRegister:output_type -> filer_pb.MountRegisterResponse
|
||||
94, // 143: filer_pb.SeaweedFiler.MountList:output_type -> filer_pb.MountListResponse
|
||||
109, // [109:144] is the sub-list for method output_type
|
||||
74, // [74:109] is the sub-list for method input_type
|
||||
74, // [74:74] is the sub-list for extension type_name
|
||||
74, // [74:74] is the sub-list for extension extendee
|
||||
0, // [0:74] is the sub-list for field type_name
|
||||
18, // 37: filer_pb.DeleteEntryRequest.condition:type_name -> filer_pb.WriteCondition
|
||||
59, // 38: filer_pb.DeleteEntryResponse.metadata_event:type_name -> filer_pb.SubscribeMetadataResponse
|
||||
1, // 39: filer_pb.DeleteEntryResponse.error_code:type_name -> filer_pb.FilerError
|
||||
12, // 40: filer_pb.StreamRenameEntryResponse.event_notification:type_name -> filer_pb.EventNotification
|
||||
45, // 41: filer_pb.AssignVolumeResponse.location:type_name -> filer_pb.Location
|
||||
45, // 42: filer_pb.AssignVolumeResponse.replicas:type_name -> filer_pb.Location
|
||||
1, // 43: filer_pb.AssignVolumeResponse.error_code:type_name -> filer_pb.FilerError
|
||||
45, // 44: filer_pb.Locations.locations:type_name -> filer_pb.Location
|
||||
104, // 45: filer_pb.LookupVolumeResponse.locations_map:type_name -> filer_pb.LookupVolumeResponse.LocationsMapEntry
|
||||
47, // 46: filer_pb.CollectionListResponse.collections:type_name -> filer_pb.Collection
|
||||
12, // 47: filer_pb.SubscribeMetadataResponse.event_notification:type_name -> filer_pb.EventNotification
|
||||
59, // 48: filer_pb.SubscribeMetadataResponse.events:type_name -> filer_pb.SubscribeMetadataResponse
|
||||
63, // 49: filer_pb.SubscribeMetadataResponse.log_file_refs:type_name -> filer_pb.LogFileChunkRef
|
||||
62, // 50: filer_pb.ListMetadataSubscribersResponse.subscribers:type_name -> filer_pb.MetadataSubscriber
|
||||
13, // 51: filer_pb.LogFileChunkRef.chunks:type_name -> filer_pb.FileChunk
|
||||
10, // 52: filer_pb.TraverseBfsMetadataResponse.entry:type_name -> filer_pb.Entry
|
||||
105, // 53: filer_pb.LocateBrokerResponse.resources:type_name -> filer_pb.LocateBrokerResponse.Resource
|
||||
106, // 54: filer_pb.FilerConf.locations:type_name -> filer_pb.FilerConf.PathConf
|
||||
10, // 55: filer_pb.CacheRemoteObjectToLocalClusterResponse.entry:type_name -> filer_pb.Entry
|
||||
59, // 56: filer_pb.CacheRemoteObjectToLocalClusterResponse.metadata_event:type_name -> filer_pb.SubscribeMetadataResponse
|
||||
84, // 57: filer_pb.TransferLocksRequest.locks:type_name -> filer_pb.Lock
|
||||
17, // 58: filer_pb.StreamMutateEntryRequest.create_request:type_name -> filer_pb.CreateEntryRequest
|
||||
29, // 59: filer_pb.StreamMutateEntryRequest.update_request:type_name -> filer_pb.UpdateEntryRequest
|
||||
35, // 60: filer_pb.StreamMutateEntryRequest.delete_request:type_name -> filer_pb.DeleteEntryRequest
|
||||
39, // 61: filer_pb.StreamMutateEntryRequest.rename_request:type_name -> filer_pb.StreamRenameEntryRequest
|
||||
28, // 62: filer_pb.StreamMutateEntryResponse.create_response:type_name -> filer_pb.CreateEntryResponse
|
||||
30, // 63: filer_pb.StreamMutateEntryResponse.update_response:type_name -> filer_pb.UpdateEntryResponse
|
||||
36, // 64: filer_pb.StreamMutateEntryResponse.delete_response:type_name -> filer_pb.DeleteEntryResponse
|
||||
40, // 65: filer_pb.StreamMutateEntryResponse.rename_response:type_name -> filer_pb.StreamRenameEntryResponse
|
||||
95, // 66: filer_pb.MountListResponse.mounts:type_name -> filer_pb.MountInfo
|
||||
5, // 67: filer_pb.LookupDirectoryEntriesRequest.requests:type_name -> filer_pb.LookupDirectoryEntryRequest
|
||||
10, // 68: filer_pb.LookupDirectoryEntryResult.entry:type_name -> filer_pb.Entry
|
||||
97, // 69: filer_pb.LookupDirectoryEntriesResponse.results:type_name -> filer_pb.LookupDirectoryEntryResult
|
||||
107, // 70: filer_pb.LookupDirectoryEntriesResponse.locations_map:type_name -> filer_pb.LookupDirectoryEntriesResponse.LocationsMapEntry
|
||||
108, // 71: filer_pb.LookupDirectoryEntriesResponse.read_auth:type_name -> filer_pb.LookupDirectoryEntriesResponse.ReadAuthEntry
|
||||
3, // 72: filer_pb.WriteCondition.Clause.kind:type_name -> filer_pb.WriteCondition.Kind
|
||||
10, // 73: filer_pb.WriteCondition.Clause.expected_entry:type_name -> filer_pb.Entry
|
||||
44, // 74: filer_pb.LookupVolumeResponse.LocationsMapEntry.value:type_name -> filer_pb.Locations
|
||||
44, // 75: filer_pb.LookupDirectoryEntriesResponse.LocationsMapEntry.value:type_name -> filer_pb.Locations
|
||||
5, // 76: filer_pb.SeaweedFiler.LookupDirectoryEntry:input_type -> filer_pb.LookupDirectoryEntryRequest
|
||||
96, // 77: filer_pb.SeaweedFiler.LookupDirectoryEntries:input_type -> filer_pb.LookupDirectoryEntriesRequest
|
||||
7, // 78: filer_pb.SeaweedFiler.ListEntries:input_type -> filer_pb.ListEntriesRequest
|
||||
17, // 79: filer_pb.SeaweedFiler.CreateEntry:input_type -> filer_pb.CreateEntryRequest
|
||||
29, // 80: filer_pb.SeaweedFiler.UpdateEntry:input_type -> filer_pb.UpdateEntryRequest
|
||||
31, // 81: filer_pb.SeaweedFiler.TouchAccessTime:input_type -> filer_pb.TouchAccessTimeRequest
|
||||
33, // 82: filer_pb.SeaweedFiler.AppendToEntry:input_type -> filer_pb.AppendToEntryRequest
|
||||
35, // 83: filer_pb.SeaweedFiler.DeleteEntry:input_type -> filer_pb.DeleteEntryRequest
|
||||
21, // 84: filer_pb.SeaweedFiler.ObjectTransaction:input_type -> filer_pb.ObjectTransactionRequest
|
||||
26, // 85: filer_pb.SeaweedFiler.ObjectTransactionBatch:input_type -> filer_pb.ObjectTransactionBatchRequest
|
||||
24, // 86: filer_pb.SeaweedFiler.PosixLock:input_type -> filer_pb.PosixLockRequest
|
||||
37, // 87: filer_pb.SeaweedFiler.AtomicRenameEntry:input_type -> filer_pb.AtomicRenameEntryRequest
|
||||
39, // 88: filer_pb.SeaweedFiler.StreamRenameEntry:input_type -> filer_pb.StreamRenameEntryRequest
|
||||
89, // 89: filer_pb.SeaweedFiler.StreamMutateEntry:input_type -> filer_pb.StreamMutateEntryRequest
|
||||
41, // 90: filer_pb.SeaweedFiler.AssignVolume:input_type -> filer_pb.AssignVolumeRequest
|
||||
43, // 91: filer_pb.SeaweedFiler.LookupVolume:input_type -> filer_pb.LookupVolumeRequest
|
||||
48, // 92: filer_pb.SeaweedFiler.CollectionList:input_type -> filer_pb.CollectionListRequest
|
||||
50, // 93: filer_pb.SeaweedFiler.DeleteCollection:input_type -> filer_pb.DeleteCollectionRequest
|
||||
52, // 94: filer_pb.SeaweedFiler.Statistics:input_type -> filer_pb.StatisticsRequest
|
||||
54, // 95: filer_pb.SeaweedFiler.Ping:input_type -> filer_pb.PingRequest
|
||||
56, // 96: filer_pb.SeaweedFiler.GetFilerConfiguration:input_type -> filer_pb.GetFilerConfigurationRequest
|
||||
64, // 97: filer_pb.SeaweedFiler.TraverseBfsMetadata:input_type -> filer_pb.TraverseBfsMetadataRequest
|
||||
58, // 98: filer_pb.SeaweedFiler.SubscribeMetadata:input_type -> filer_pb.SubscribeMetadataRequest
|
||||
58, // 99: filer_pb.SeaweedFiler.SubscribeLocalMetadata:input_type -> filer_pb.SubscribeMetadataRequest
|
||||
60, // 100: filer_pb.SeaweedFiler.ListMetadataSubscribers:input_type -> filer_pb.ListMetadataSubscribersRequest
|
||||
71, // 101: filer_pb.SeaweedFiler.KvGet:input_type -> filer_pb.KvGetRequest
|
||||
73, // 102: filer_pb.SeaweedFiler.KvPut:input_type -> filer_pb.KvPutRequest
|
||||
76, // 103: filer_pb.SeaweedFiler.CacheRemoteObjectToLocalCluster:input_type -> filer_pb.CacheRemoteObjectToLocalClusterRequest
|
||||
78, // 104: filer_pb.SeaweedFiler.DistributedLock:input_type -> filer_pb.LockRequest
|
||||
80, // 105: filer_pb.SeaweedFiler.DistributedUnlock:input_type -> filer_pb.UnlockRequest
|
||||
82, // 106: filer_pb.SeaweedFiler.FindLockOwner:input_type -> filer_pb.FindLockOwnerRequest
|
||||
85, // 107: filer_pb.SeaweedFiler.TransferLocks:input_type -> filer_pb.TransferLocksRequest
|
||||
87, // 108: filer_pb.SeaweedFiler.ReplicateLock:input_type -> filer_pb.ReplicateLockRequest
|
||||
91, // 109: filer_pb.SeaweedFiler.MountRegister:input_type -> filer_pb.MountRegisterRequest
|
||||
93, // 110: filer_pb.SeaweedFiler.MountList:input_type -> filer_pb.MountListRequest
|
||||
6, // 111: filer_pb.SeaweedFiler.LookupDirectoryEntry:output_type -> filer_pb.LookupDirectoryEntryResponse
|
||||
98, // 112: filer_pb.SeaweedFiler.LookupDirectoryEntries:output_type -> filer_pb.LookupDirectoryEntriesResponse
|
||||
8, // 113: filer_pb.SeaweedFiler.ListEntries:output_type -> filer_pb.ListEntriesResponse
|
||||
28, // 114: filer_pb.SeaweedFiler.CreateEntry:output_type -> filer_pb.CreateEntryResponse
|
||||
30, // 115: filer_pb.SeaweedFiler.UpdateEntry:output_type -> filer_pb.UpdateEntryResponse
|
||||
32, // 116: filer_pb.SeaweedFiler.TouchAccessTime:output_type -> filer_pb.TouchAccessTimeResponse
|
||||
34, // 117: filer_pb.SeaweedFiler.AppendToEntry:output_type -> filer_pb.AppendToEntryResponse
|
||||
36, // 118: filer_pb.SeaweedFiler.DeleteEntry:output_type -> filer_pb.DeleteEntryResponse
|
||||
22, // 119: filer_pb.SeaweedFiler.ObjectTransaction:output_type -> filer_pb.ObjectTransactionResponse
|
||||
27, // 120: filer_pb.SeaweedFiler.ObjectTransactionBatch:output_type -> filer_pb.ObjectTransactionBatchResponse
|
||||
25, // 121: filer_pb.SeaweedFiler.PosixLock:output_type -> filer_pb.PosixLockResponse
|
||||
38, // 122: filer_pb.SeaweedFiler.AtomicRenameEntry:output_type -> filer_pb.AtomicRenameEntryResponse
|
||||
40, // 123: filer_pb.SeaweedFiler.StreamRenameEntry:output_type -> filer_pb.StreamRenameEntryResponse
|
||||
90, // 124: filer_pb.SeaweedFiler.StreamMutateEntry:output_type -> filer_pb.StreamMutateEntryResponse
|
||||
42, // 125: filer_pb.SeaweedFiler.AssignVolume:output_type -> filer_pb.AssignVolumeResponse
|
||||
46, // 126: filer_pb.SeaweedFiler.LookupVolume:output_type -> filer_pb.LookupVolumeResponse
|
||||
49, // 127: filer_pb.SeaweedFiler.CollectionList:output_type -> filer_pb.CollectionListResponse
|
||||
51, // 128: filer_pb.SeaweedFiler.DeleteCollection:output_type -> filer_pb.DeleteCollectionResponse
|
||||
53, // 129: filer_pb.SeaweedFiler.Statistics:output_type -> filer_pb.StatisticsResponse
|
||||
55, // 130: filer_pb.SeaweedFiler.Ping:output_type -> filer_pb.PingResponse
|
||||
57, // 131: filer_pb.SeaweedFiler.GetFilerConfiguration:output_type -> filer_pb.GetFilerConfigurationResponse
|
||||
65, // 132: filer_pb.SeaweedFiler.TraverseBfsMetadata:output_type -> filer_pb.TraverseBfsMetadataResponse
|
||||
59, // 133: filer_pb.SeaweedFiler.SubscribeMetadata:output_type -> filer_pb.SubscribeMetadataResponse
|
||||
59, // 134: filer_pb.SeaweedFiler.SubscribeLocalMetadata:output_type -> filer_pb.SubscribeMetadataResponse
|
||||
61, // 135: filer_pb.SeaweedFiler.ListMetadataSubscribers:output_type -> filer_pb.ListMetadataSubscribersResponse
|
||||
72, // 136: filer_pb.SeaweedFiler.KvGet:output_type -> filer_pb.KvGetResponse
|
||||
74, // 137: filer_pb.SeaweedFiler.KvPut:output_type -> filer_pb.KvPutResponse
|
||||
77, // 138: filer_pb.SeaweedFiler.CacheRemoteObjectToLocalCluster:output_type -> filer_pb.CacheRemoteObjectToLocalClusterResponse
|
||||
79, // 139: filer_pb.SeaweedFiler.DistributedLock:output_type -> filer_pb.LockResponse
|
||||
81, // 140: filer_pb.SeaweedFiler.DistributedUnlock:output_type -> filer_pb.UnlockResponse
|
||||
83, // 141: filer_pb.SeaweedFiler.FindLockOwner:output_type -> filer_pb.FindLockOwnerResponse
|
||||
86, // 142: filer_pb.SeaweedFiler.TransferLocks:output_type -> filer_pb.TransferLocksResponse
|
||||
88, // 143: filer_pb.SeaweedFiler.ReplicateLock:output_type -> filer_pb.ReplicateLockResponse
|
||||
92, // 144: filer_pb.SeaweedFiler.MountRegister:output_type -> filer_pb.MountRegisterResponse
|
||||
94, // 145: filer_pb.SeaweedFiler.MountList:output_type -> filer_pb.MountListResponse
|
||||
111, // [111:146] is the sub-list for method output_type
|
||||
76, // [76:111] is the sub-list for method input_type
|
||||
76, // [76:76] is the sub-list for extension type_name
|
||||
76, // [76:76] is the sub-list for extension extendee
|
||||
0, // [0:76] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_filer_proto_init() }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc v3.21.12
|
||||
// - protoc v7.35.0
|
||||
// source: filer.proto
|
||||
|
||||
package filer_pb
|
||||
|
||||
@@ -2486,6 +2486,16 @@ func (m *DeleteEntryRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
||||
i -= len(m.unknownFields)
|
||||
copy(dAtA[i:], m.unknownFields)
|
||||
}
|
||||
if m.Condition != nil {
|
||||
size, err := m.Condition.MarshalToSizedBufferVT(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
|
||||
i--
|
||||
dAtA[i] = 0x5a
|
||||
}
|
||||
if m.KeepRemoteObject {
|
||||
i--
|
||||
if m.KeepRemoteObject {
|
||||
@@ -2609,6 +2619,11 @@ func (m *DeleteEntryResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
||||
i -= len(m.unknownFields)
|
||||
copy(dAtA[i:], m.unknownFields)
|
||||
}
|
||||
if m.ErrorCode != 0 {
|
||||
i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ErrorCode))
|
||||
i--
|
||||
dAtA[i] = 0x18
|
||||
}
|
||||
if m.MetadataEvent != nil {
|
||||
size, err := m.MetadataEvent.MarshalToSizedBufferVT(dAtA[:i])
|
||||
if err != nil {
|
||||
@@ -2659,6 +2674,16 @@ func (m *AtomicRenameEntryRequest) MarshalToSizedBufferVT(dAtA []byte) (int, err
|
||||
i -= len(m.unknownFields)
|
||||
copy(dAtA[i:], m.unknownFields)
|
||||
}
|
||||
if m.FailIfTargetExists {
|
||||
i--
|
||||
if m.FailIfTargetExists {
|
||||
dAtA[i] = 1
|
||||
} else {
|
||||
dAtA[i] = 0
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x30
|
||||
}
|
||||
if len(m.Signatures) > 0 {
|
||||
var pksize2 int
|
||||
for _, num := range m.Signatures {
|
||||
@@ -7548,6 +7573,10 @@ func (m *DeleteEntryRequest) SizeVT() (n int) {
|
||||
if m.KeepRemoteObject {
|
||||
n += 2
|
||||
}
|
||||
if m.Condition != nil {
|
||||
l = m.Condition.SizeVT()
|
||||
n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
|
||||
}
|
||||
n += len(m.unknownFields)
|
||||
return n
|
||||
}
|
||||
@@ -7566,6 +7595,9 @@ func (m *DeleteEntryResponse) SizeVT() (n int) {
|
||||
l = m.MetadataEvent.SizeVT()
|
||||
n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
|
||||
}
|
||||
if m.ErrorCode != 0 {
|
||||
n += 1 + protohelpers.SizeOfVarint(uint64(m.ErrorCode))
|
||||
}
|
||||
n += len(m.unknownFields)
|
||||
return n
|
||||
}
|
||||
@@ -7599,6 +7631,9 @@ func (m *AtomicRenameEntryRequest) SizeVT() (n int) {
|
||||
}
|
||||
n += 1 + protohelpers.SizeOfVarint(uint64(l)) + l
|
||||
}
|
||||
if m.FailIfTargetExists {
|
||||
n += 2
|
||||
}
|
||||
n += len(m.unknownFields)
|
||||
return n
|
||||
}
|
||||
@@ -16157,6 +16192,42 @@ func (m *DeleteEntryRequest) UnmarshalVT(dAtA []byte) error {
|
||||
}
|
||||
}
|
||||
m.KeepRemoteObject = bool(v != 0)
|
||||
case 11:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Condition", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protohelpers.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return protohelpers.ErrInvalidLength
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return protohelpers.ErrInvalidLength
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Condition == nil {
|
||||
m.Condition = &WriteCondition{}
|
||||
}
|
||||
if err := m.Condition.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := protohelpers.Skip(dAtA[iNdEx:])
|
||||
@@ -16276,6 +16347,25 @@ func (m *DeleteEntryResponse) UnmarshalVT(dAtA []byte) error {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ErrorCode", wireType)
|
||||
}
|
||||
m.ErrorCode = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protohelpers.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.ErrorCode |= FilerError(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := protohelpers.Skip(dAtA[iNdEx:])
|
||||
@@ -16531,6 +16621,26 @@ func (m *AtomicRenameEntryRequest) UnmarshalVT(dAtA []byte) error {
|
||||
} else {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Signatures", wireType)
|
||||
}
|
||||
case 6:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field FailIfTargetExists", wireType)
|
||||
}
|
||||
var v int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return protohelpers.ErrIntOverflow
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
v |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
m.FailIfTargetExists = bool(v != 0)
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := protohelpers.Skip(dAtA[iNdEx:])
|
||||
|
||||
@@ -660,8 +660,7 @@ func (w *Worker) buildHeartbeat() *plugin_pb.WorkerHeartbeat {
|
||||
if work == nil {
|
||||
continue
|
||||
}
|
||||
cloned := *work
|
||||
running = append(running, &cloned)
|
||||
running = append(running, proto.Clone(work).(*plugin_pb.RunningWork))
|
||||
}
|
||||
w.runningMu.RUnlock()
|
||||
|
||||
|
||||
@@ -229,8 +229,7 @@ func (fs *FilerSink) replicateOneManifestChunk(ctx context.Context, sourceChunk
|
||||
|
||||
manifestDataChunks := make([]*filer_pb.FileChunk, len(replicatedResolvedChunks))
|
||||
for i, chunk := range replicatedResolvedChunks {
|
||||
copied := *chunk
|
||||
manifestDataChunks[i] = &copied
|
||||
manifestDataChunks[i] = proto.Clone(chunk).(*filer_pb.FileChunk)
|
||||
}
|
||||
filer_pb.BeforeEntrySerialization(manifestDataChunks)
|
||||
manifestData, err := proto.Marshal(&filer_pb.FileChunkManifest{
|
||||
|
||||
@@ -111,7 +111,7 @@ func TestNewSignV4ChunkedReaderStreamingUnsignedPayloadTrailer(t *testing.T) {
|
||||
runWithRequest(iam, req, t, expectedPayload)
|
||||
}
|
||||
|
||||
func runWithRequest(iam IdentityAccessManagement, req *http.Request, t *testing.T, expectedPayload string) {
|
||||
func runWithRequest(iam *IdentityAccessManagement, req *http.Request, t *testing.T, expectedPayload string) {
|
||||
reader, errCode := iam.newChunkedReader(req)
|
||||
assert.NotNil(t, reader)
|
||||
assert.Equal(t, s3err.ErrNone, errCode)
|
||||
@@ -124,11 +124,11 @@ func runWithRequest(iam IdentityAccessManagement, req *http.Request, t *testing.
|
||||
assert.Equal(t, expectedPayload, string(data))
|
||||
}
|
||||
|
||||
func setupIam() IdentityAccessManagement {
|
||||
func setupIam() *IdentityAccessManagement {
|
||||
// Create an IdentityAccessManagement instance
|
||||
// Add default access keys and secrets
|
||||
|
||||
iam := IdentityAccessManagement{
|
||||
iam := &IdentityAccessManagement{
|
||||
identities: []*Identity{},
|
||||
accessKeyIdent: map[string]*Identity{},
|
||||
accounts: map[string]*Account{},
|
||||
|
||||
@@ -29,6 +29,7 @@ const (
|
||||
SeaweedStorageDestinationHeader = "x-seaweedfs-destination"
|
||||
MultipartUploadsFolder = ".uploads"
|
||||
VersionsFolder = ".versions"
|
||||
SystemFolder = ".system"
|
||||
FolderMimeType = "httpd/unix-directory"
|
||||
DirectoryMimeType = "application/x-directory"
|
||||
)
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
// indexes pre-existing buckets. The .complete marker is written once the
|
||||
// backfill has finished; until it exists readers keep scanning /buckets.
|
||||
const (
|
||||
s3SystemFolder = ".system"
|
||||
s3SystemFolder = s3_constants.SystemFolder
|
||||
bucketOwnerIndexFolder = "owners"
|
||||
bucketOwnerIndexReadyMarker = ".complete"
|
||||
)
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestHeadBucketSeparatesLookupFailureFromMissingBucket(t *testing.T) {
|
||||
s3a.HeadBucketHandler(rr, req)
|
||||
|
||||
if rr.Code != tc.wantCode {
|
||||
t.Fatalf("status = %d, want %d", rr.Code, tc.wantCode)
|
||||
t.Fatalf("status = %d, want %d: %s", rr.Code, tc.wantCode, rr.Body.String())
|
||||
}
|
||||
// HEAD returns the status without an XML error body, including for
|
||||
// lookup failures and missing buckets.
|
||||
|
||||
@@ -1049,6 +1049,24 @@ func (fs *FilerServer) DeleteEntry(ctx context.Context, req *filer_pb.DeleteEntr
|
||||
pathLock := fs.entryLockTable.AcquireLock("DeleteEntry", fullpath, util.ExclusiveLock)
|
||||
defer fs.entryLockTable.ReleaseLock(fullpath, pathLock)
|
||||
|
||||
// A condition makes the delete a check-then-write like UpdateEntry's: the
|
||||
// lock serializes it against local writes and replays applied to this
|
||||
// store, so only a write still in flight from a peer can slip past the
|
||||
// check — the same window if_not_modified_after leaves.
|
||||
if conditionIsSet(req.Condition) {
|
||||
current, findErr := fs.filer.FindEntry(ctx, fullpath)
|
||||
switch {
|
||||
case errors.Is(findErr, filer_pb.ErrNotFound):
|
||||
current = nil
|
||||
case findErr != nil:
|
||||
return &filer_pb.DeleteEntryResponse{}, fmt.Errorf("DeleteEntry condition check %s: %w", fullpath, findErr)
|
||||
}
|
||||
if !writeConditionSatisfied(req.Condition, current) {
|
||||
glog.V(3).InfofCtx(ctx, "DeleteEntry %s: precondition failed: %v", fullpath, req.Condition)
|
||||
return &filer_pb.DeleteEntryResponse{Error: "precondition failed", ErrorCode: filer_pb.FilerError_PRECONDITION_FAILED}, nil
|
||||
}
|
||||
}
|
||||
|
||||
if req.KeepRemoteObject {
|
||||
ctx = filer.WithKeepRemoteObject(ctx)
|
||||
}
|
||||
|
||||
@@ -87,14 +87,18 @@ func clauseSatisfied(c *filer_pb.WriteCondition_Clause, current *filer.Entry) bo
|
||||
if !exists || c.ExpectedEntry == nil {
|
||||
return !exists && c.ExpectedEntry == nil
|
||||
}
|
||||
// Compare both sides in serialized form on clones: chunks are matched
|
||||
// by their fid only — the stored entry may carry the restored file_id
|
||||
// while an expected one built from a metadata event does not.
|
||||
expected := proto.Clone(c.ExpectedEntry).(*filer_pb.Entry)
|
||||
filer_pb.BeforeEntrySerialization(expected.Chunks)
|
||||
actual := proto.Clone(current.ToProtoEntry()).(*filer_pb.Entry)
|
||||
filer_pb.BeforeEntrySerialization(actual.Chunks)
|
||||
return proto.Equal(actual, filer.FromPbEntry("", expected).ToProtoEntry())
|
||||
// Compare both sides in canonical serialized form on clones: chunks are
|
||||
// matched by their fid only — the stored entry may carry the restored
|
||||
// file_id while an expected one built from a metadata event does not —
|
||||
// and the codec round-trip settles derived fields on both sides, like an
|
||||
// unset atime reading back as mtime.
|
||||
canonical := func(e *filer_pb.Entry) *filer_pb.Entry {
|
||||
filer_pb.BeforeEntrySerialization(e.Chunks)
|
||||
return filer.FromPbEntry("", e).ToProtoEntry()
|
||||
}
|
||||
expected := canonical(proto.Clone(c.ExpectedEntry).(*filer_pb.Entry))
|
||||
actual := canonical(proto.Clone(current.ToProtoEntry()).(*filer_pb.Entry))
|
||||
return proto.Equal(actual, expected)
|
||||
default:
|
||||
// An unrecognized clause kind (e.g. from a newer client) must not be
|
||||
// treated as satisfied, which would silently bypass the guard. Fail
|
||||
|
||||
@@ -382,3 +382,83 @@ func TestUpdateEntryConditionEnforced(t *testing.T) {
|
||||
t.Fatalf("update not applied, mtime %d", got)
|
||||
}
|
||||
}
|
||||
|
||||
// The delete condition turns verify-then-delete into a check-then-write: the
|
||||
// filer drops the entry only while it still matches the version the caller
|
||||
// verified, and a stale expectation answers PRECONDITION_FAILED without
|
||||
// deleting.
|
||||
func TestDeleteEntryConditionEnforced(t *testing.T) {
|
||||
newServer := func() (*FilerServer, *renameTestStore) {
|
||||
store := newRenameTestStore()
|
||||
store.entries["/test/obj"] = &filer.Entry{
|
||||
FullPath: "/test/obj",
|
||||
Attr: filer.Attr{Inode: 1, Mtime: time.Unix(1700000000, 0), Mode: 0644, FileSize: 100},
|
||||
Chunks: []*filer_pb.FileChunk{chunkFid("3,01637037d6")},
|
||||
}
|
||||
f := newRenameTestFiler(t, store)
|
||||
return &FilerServer{filer: f, option: &FilerOption{}, entryLockTable: util.NewLockTable[util.FullPath]()}, store
|
||||
}
|
||||
|
||||
del := func(expected *filer_pb.Entry) *filer_pb.DeleteEntryRequest {
|
||||
return &filer_pb.DeleteEntryRequest{
|
||||
Directory: "/test",
|
||||
Name: "obj",
|
||||
Condition: one(&filer_pb.WriteCondition_Clause{
|
||||
Kind: filer_pb.WriteCondition_IF_ENTRY_EQUAL,
|
||||
ExpectedEntry: expected,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
t.Run("matching version deletes", func(t *testing.T) {
|
||||
fs, store := newServer()
|
||||
expected := store.entries["/test/obj"].ToProtoEntry()
|
||||
resp, err := fs.DeleteEntry(context.Background(), del(expected))
|
||||
if err != nil || resp.Error != "" {
|
||||
t.Fatalf("delete failed: %v %s", err, resp.Error)
|
||||
}
|
||||
if _, ok := store.entries["/test/obj"]; ok {
|
||||
t.Fatal("entry must be deleted when the verified version still matches")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("stale version keeps the entry", func(t *testing.T) {
|
||||
fs, store := newServer()
|
||||
expected := store.entries["/test/obj"].ToProtoEntry()
|
||||
store.entries["/test/obj"].Chunks = append(store.entries["/test/obj"].Chunks, chunkFid("3,09"))
|
||||
resp, err := fs.DeleteEntry(context.Background(), del(expected))
|
||||
if err != nil {
|
||||
t.Fatalf("DeleteEntry: %v", err)
|
||||
}
|
||||
if resp.ErrorCode != filer_pb.FilerError_PRECONDITION_FAILED {
|
||||
t.Fatalf("stale version must report PRECONDITION_FAILED, got %v %q", resp.ErrorCode, resp.Error)
|
||||
}
|
||||
if _, ok := store.entries["/test/obj"]; !ok {
|
||||
t.Fatal("stale version must leave the entry alone")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("vanished entry reports precondition failed", func(t *testing.T) {
|
||||
fs, store := newServer()
|
||||
expected := store.entries["/test/obj"].ToProtoEntry()
|
||||
delete(store.entries, "/test/obj")
|
||||
resp, err := fs.DeleteEntry(context.Background(), del(expected))
|
||||
if err != nil {
|
||||
t.Fatalf("DeleteEntry: %v", err)
|
||||
}
|
||||
if resp.ErrorCode != filer_pb.FilerError_PRECONDITION_FAILED {
|
||||
t.Fatalf("gone entry must report PRECONDITION_FAILED, got %v %q", resp.ErrorCode, resp.Error)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("unconditional delete still applies", func(t *testing.T) {
|
||||
fs, store := newServer()
|
||||
resp, err := fs.DeleteEntry(context.Background(), &filer_pb.DeleteEntryRequest{Directory: "/test", Name: "obj"})
|
||||
if err != nil || resp.Error != "" {
|
||||
t.Fatalf("delete failed: %v %s", err, resp.Error)
|
||||
}
|
||||
if _, ok := store.entries["/test/obj"]; ok {
|
||||
t.Fatal("unconditional delete must drop the entry")
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -408,10 +408,18 @@ func (c *commandFsVerify) pruneEntry(path util.FullPath, mtimeSec int64, md5 []b
|
||||
Directory: dir,
|
||||
Name: name,
|
||||
IfNotModifiedAfter: mtimeSec,
|
||||
Condition: &filer_pb.WriteCondition{Clauses: []*filer_pb.WriteCondition_Clause{{
|
||||
Kind: filer_pb.WriteCondition_IF_ENTRY_EQUAL,
|
||||
ExpectedEntry: lookupResp.Entry,
|
||||
}}},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if deleteResp.ErrorCode == filer_pb.FilerError_PRECONDITION_FAILED {
|
||||
fmt.Fprintf(c.writer, "skip pruning %s: entry changed since verification\n", path)
|
||||
return nil
|
||||
}
|
||||
if deleteResp.Error != "" {
|
||||
return fmt.Errorf("delete entry %s: %s", path, deleteResp.Error)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type fsVerifyTestVolumeServer struct {
|
||||
@@ -37,6 +38,9 @@ type fsVerifyTestFilerServer struct {
|
||||
filer_pb.UnimplementedSeaweedFilerServer
|
||||
entry *filer_pb.Entry
|
||||
deleted []*filer_pb.DeleteEntryRequest
|
||||
// onDelete runs inside DeleteEntry before the guards, letting a test
|
||||
// interleave a rewrite between the pruning lookup and the delete.
|
||||
onDelete func()
|
||||
}
|
||||
|
||||
func (s *fsVerifyTestFilerServer) LookupDirectoryEntry(_ context.Context, req *filer_pb.LookupDirectoryEntryRequest) (*filer_pb.LookupDirectoryEntryResponse, error) {
|
||||
@@ -48,11 +52,28 @@ func (s *fsVerifyTestFilerServer) LookupDirectoryEntry(_ context.Context, req *f
|
||||
|
||||
func (s *fsVerifyTestFilerServer) DeleteEntry(_ context.Context, req *filer_pb.DeleteEntryRequest) (*filer_pb.DeleteEntryResponse, error) {
|
||||
s.deleted = append(s.deleted, req)
|
||||
if s.onDelete != nil {
|
||||
s.onDelete()
|
||||
}
|
||||
// mirror the real filer: an entry newer than IfNotModifiedAfter is
|
||||
// silently skipped, no error and no Error field
|
||||
if s.entry != nil && req.IfNotModifiedAfter > 0 && s.entry.Attributes.GetMtime() > req.IfNotModifiedAfter {
|
||||
return &filer_pb.DeleteEntryResponse{}, nil
|
||||
}
|
||||
// ... and an entry that no longer matches the version the client
|
||||
// verified fails the delete's write condition
|
||||
for _, cl := range req.GetCondition().GetClauses() {
|
||||
if cl.GetKind() != filer_pb.WriteCondition_IF_ENTRY_EQUAL {
|
||||
continue
|
||||
}
|
||||
expected := proto.Clone(cl.GetExpectedEntry()).(*filer_pb.Entry)
|
||||
filer_pb.BeforeEntrySerialization(expected.GetChunks())
|
||||
stored := proto.Clone(s.entry).(*filer_pb.Entry)
|
||||
filer_pb.BeforeEntrySerialization(stored.GetChunks())
|
||||
if !proto.Equal(stored, expected) {
|
||||
return &filer_pb.DeleteEntryResponse{Error: "precondition failed", ErrorCode: filer_pb.FilerError_PRECONDITION_FAILED}, nil
|
||||
}
|
||||
}
|
||||
s.entry = nil
|
||||
return &filer_pb.DeleteEntryResponse{}, nil
|
||||
}
|
||||
@@ -292,6 +313,38 @@ func TestFsVerifyPruneEntryGuards(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A rewrite landing between the pruning lookup and the delete keeps the same
|
||||
// mtime second, so neither the re-lookup nor IfNotModifiedAfter sees it — the
|
||||
// entry version on the delete is the only guard that catches it.
|
||||
func TestFsVerifyPruneEntryMidFlightRewrite(t *testing.T) {
|
||||
filer := &fsVerifyTestFilerServer{entry: &filer_pb.Entry{
|
||||
Name: "file",
|
||||
Attributes: &filer_pb.FuseAttributes{Mtime: 100, Md5: []byte("md5")},
|
||||
Chunks: []*filer_pb.FileChunk{{Fid: &filer_pb.FileId{VolumeId: 7, FileKey: 42}}},
|
||||
}}
|
||||
commandEnv, _, cleanup := newFsVerifyTestCommandEnv(t, filer, &fsVerifyTestVolumeServer{})
|
||||
defer cleanup()
|
||||
c := newFsVerifyTestCommand(t, commandEnv, &bytes.Buffer{})
|
||||
|
||||
chunks := []*filer_pb.FileChunk{{Fid: &filer_pb.FileId{VolumeId: 7, FileKey: 42}}}
|
||||
filer.onDelete = func() {
|
||||
filer.onDelete = nil
|
||||
filer.entry = &filer_pb.Entry{
|
||||
Name: "file",
|
||||
Attributes: &filer_pb.FuseAttributes{Mtime: 100, Md5: []byte("md5")},
|
||||
Chunks: []*filer_pb.FileChunk{{Fid: &filer_pb.FileId{VolumeId: 7, FileKey: 43}}},
|
||||
}
|
||||
}
|
||||
|
||||
pruned, err := c.pruneEntry(util.NewFullPath("/buckets/b", "file"), 100, []byte("md5"), chunks)
|
||||
if err != nil || pruned {
|
||||
t.Fatalf("mid-flight rewrite must not be pruned, got pruned=%v err=%v", pruned, err)
|
||||
}
|
||||
if filer.entry == nil {
|
||||
t.Fatal("rewritten entry must survive the conditional delete")
|
||||
}
|
||||
}
|
||||
|
||||
// An unresolvable chunk manifest is an entry-level verification failure even
|
||||
// when the raw manifest needle is healthy; raw chunks are still checked so a
|
||||
// missing manifest needle can be pruned.
|
||||
|
||||
@@ -838,8 +838,8 @@ func (c *commandVolumeFsck) purgeEmptyDirectories() {
|
||||
if mtime <= 0 || mtime >= time.Now().Add(-directoryQuietPeriod).Unix() {
|
||||
continue
|
||||
}
|
||||
if err := c.deleteEmptyDirectory(dir, mtime); err != nil {
|
||||
if !errors.Is(err, filer.ErrNonEmptyFolder) {
|
||||
if err := c.deleteEmptyDirectory(dir, entry); err != nil {
|
||||
if !errors.Is(err, filer.ErrNonEmptyFolder) && !errors.Is(err, errDeleteEntryChanged) {
|
||||
fmt.Fprintf(c.writer, "delete empty directory %s: %v\n", dir, err)
|
||||
}
|
||||
continue
|
||||
@@ -848,20 +848,31 @@ func (c *commandVolumeFsck) purgeEmptyDirectories() {
|
||||
}
|
||||
}
|
||||
|
||||
// deleteEmptyDirectory deletes dir unless it changed since it was looked up at mtime,
|
||||
// errDeleteEntryChanged reports a delete skipped because the entry no longer
|
||||
// matches the version the caller verified.
|
||||
var errDeleteEntryChanged = errors.New("entry changed since verification")
|
||||
|
||||
// deleteEmptyDirectory deletes dir unless it changed since it was looked up,
|
||||
// so a directory promoted to an S3 object meanwhile survives. The delete is not
|
||||
// recursive, leaving the filer to reject a directory that is not empty.
|
||||
func (c *commandVolumeFsck) deleteEmptyDirectory(dir util.FullPath, mtime int64) error {
|
||||
func (c *commandVolumeFsck) deleteEmptyDirectory(dir util.FullPath, expected *filer_pb.Entry) error {
|
||||
parent, name := dir.DirAndName()
|
||||
return c.env.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||
resp, err := client.DeleteEntry(context.Background(), &filer_pb.DeleteEntryRequest{
|
||||
Directory: parent,
|
||||
Name: name,
|
||||
IfNotModifiedAfter: mtime,
|
||||
IfNotModifiedAfter: expected.Attributes.GetMtime(),
|
||||
Condition: &filer_pb.WriteCondition{Clauses: []*filer_pb.WriteCondition_Clause{{
|
||||
Kind: filer_pb.WriteCondition_IF_ENTRY_EQUAL,
|
||||
ExpectedEntry: expected,
|
||||
}}},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.ErrorCode == filer_pb.FilerError_PRECONDITION_FAILED {
|
||||
return errDeleteEntryChanged
|
||||
}
|
||||
if resp.Error != "" {
|
||||
return filer.DeleteEntryError(resp.Error)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func TestVolumeFsckCanPurgeDirectory(t *testing.T) {
|
||||
@@ -100,6 +101,21 @@ func (s *stubFilerServer) LookupDirectoryEntry(ctx context.Context, req *filer_p
|
||||
func (s *stubFilerServer) DeleteEntry(ctx context.Context, req *filer_pb.DeleteEntryRequest) (*filer_pb.DeleteEntryResponse, error) {
|
||||
fullPath := string(util.NewFullPath(req.Directory, req.Name))
|
||||
entry, found := s.entries[fullPath]
|
||||
// mirror the real filer: the condition is checked before the delete runs,
|
||||
// so a stale expectation answers PRECONDITION_FAILED — even for a path
|
||||
// that is already gone
|
||||
for _, cl := range req.GetCondition().GetClauses() {
|
||||
if cl.GetKind() != filer_pb.WriteCondition_IF_ENTRY_EQUAL {
|
||||
continue
|
||||
}
|
||||
expected := proto.Clone(cl.GetExpectedEntry()).(*filer_pb.Entry)
|
||||
filer_pb.BeforeEntrySerialization(expected.GetChunks())
|
||||
stored := proto.Clone(entry).(*filer_pb.Entry)
|
||||
filer_pb.BeforeEntrySerialization(stored.GetChunks())
|
||||
if !proto.Equal(stored, expected) {
|
||||
return &filer_pb.DeleteEntryResponse{Error: "precondition failed", ErrorCode: filer_pb.FilerError_PRECONDITION_FAILED}, nil
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return &filer_pb.DeleteEntryResponse{Error: filer_pb.ErrNotFound.Error()}, nil
|
||||
}
|
||||
|
||||
+5
-3
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type DiskIOProbeConfig struct {
|
||||
@@ -91,7 +92,7 @@ type diskState struct {
|
||||
statFailureCount int
|
||||
statSuccessCount int
|
||||
lastStatErr error
|
||||
lastGoodStatus volume_server_pb.DiskStatus
|
||||
lastGoodStatus *volume_server_pb.DiskStatus
|
||||
hasLastGood bool
|
||||
|
||||
samples []ioSample
|
||||
@@ -497,7 +498,7 @@ func (s *diskState) updateErrorLocked(disk *volume_server_pb.DiskStatus, config
|
||||
}
|
||||
|
||||
func (s *diskState) rememberGoodStatusLocked(disk *volume_server_pb.DiskStatus) {
|
||||
s.lastGoodStatus = *disk
|
||||
s.lastGoodStatus = proto.Clone(disk).(*volume_server_pb.DiskStatus)
|
||||
s.hasLastGood = true
|
||||
}
|
||||
|
||||
@@ -508,7 +509,8 @@ func (s *diskState) applyLastGoodStatusLocked(disk *volume_server_pb.DiskStatus)
|
||||
|
||||
dir := disk.Dir
|
||||
errorMessage := disk.Error
|
||||
*disk = s.lastGoodStatus
|
||||
proto.Reset(disk)
|
||||
proto.Merge(disk, s.lastGoodStatus)
|
||||
disk.Dir = dir
|
||||
disk.Error = errorMessage
|
||||
}
|
||||
Reference in new issue
Block a user