diff --git a/weed/credential/filer_etc/filer_etc_store.go b/weed/credential/filer_etc/filer_etc_store.go index 05cc6a4e2..9e3c84fe2 100644 --- a/weed/credential/filer_etc/filer_etc_store.go +++ b/weed/credential/filer_etc/filer_etc_store.go @@ -36,19 +36,10 @@ func (store *FilerEtcStore) Initialize(configuration util.Configuration, prefix } // TODO: Initialize grpcDialOption based on configuration } - // Note: filerAddressFunc can be set later via SetFilerClient method + // Note: filerAddressFunc can be set later via SetFilerAddressFunc method return nil } -// SetFilerClient sets the filer client details for the file store -// Deprecated: Use SetFilerAddressFunc for better HA support -func (store *FilerEtcStore) SetFilerClient(filerAddress string, grpcDialOption grpc.DialOption) { - store.filerAddressFunc = func() pb.ServerAddress { - return pb.ServerAddress(filerAddress) - } - store.grpcDialOption = grpcDialOption -} - // SetFilerAddressFunc sets a function that returns the current active filer address // This enables high availability by using the currently active filer func (store *FilerEtcStore) SetFilerAddressFunc(getFiler func() pb.ServerAddress, grpcDialOption grpc.DialOption) { diff --git a/weed/s3api/auth_credentials.go b/weed/s3api/auth_credentials.go index 21357ba4a..be067f715 100644 --- a/weed/s3api/auth_credentials.go +++ b/weed/s3api/auth_credentials.go @@ -140,7 +140,6 @@ func NewIdentityAccessManagementWithStore(option *S3ApiServerOption, explicitSto // For stores that need filer client details, set them // Use SetFilerAddressFunc to provide current active filer for HA if store := credentialManager.GetStore(); store != nil { - // Check for new HA-aware interface first if filerFuncSetter, ok := store.(interface { SetFilerAddressFunc(func() pb.ServerAddress, grpc.DialOption) }); ok { @@ -149,7 +148,7 @@ func NewIdentityAccessManagementWithStore(option *S3ApiServerOption, explicitSto // For now, use first filer - this will be updated when FilerClient is available if len(option.Filers) > 0 { // Create a closure that will use the first filer initially - // In a full implementation, this would get the FilerClient's current filer + // This will be updated later to use FilerClient's current filer getFiler := func() pb.ServerAddress { if len(option.Filers) > 0 { return option.Filers[0] @@ -157,18 +156,7 @@ func NewIdentityAccessManagementWithStore(option *S3ApiServerOption, explicitSto return "" } filerFuncSetter.SetFilerAddressFunc(getFiler, option.GrpcDialOption) - glog.V(1).Infof("Credential store configured with filer function (HA-aware)") - } - } else if filerClientSetter, ok := store.(interface { - SetFilerClient(string, grpc.DialOption) - }); ok { - // Fallback to old interface for backward compatibility - if len(option.Filers) > 0 { - filerAddr := option.Filers[0].ToGrpcAddress() - filerClientSetter.SetFilerClient(filerAddr, option.GrpcDialOption) - glog.V(1).Infof("Credential store configured with first filer: %s (legacy interface)", filerAddr) - } else { - glog.Warningf("No filer addresses configured for credential store") + glog.V(1).Infof("Credential store configured with filer function (will be updated to use FilerClient)") } } } diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index f7447251f..d8b0648ff 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -409,11 +409,6 @@ func (s3a *S3ApiServer) toFilerPath(bucket, object string) string { return fmt.Sprintf("%s/%s%s", s3a.option.BucketsPath, bucket, object) } -// Deprecated: Use toFilerPath instead - no need for full URL -func (s3a *S3ApiServer) toFilerUrl(bucket, object string) string { - return s3a.toFilerPath(bucket, object) -} - // hasConditionalHeaders checks if the request has any conditional headers // This is a lightweight check to avoid unnecessary function calls func (s3a *S3ApiServer) hasConditionalHeaders(r *http.Request) bool { diff --git a/weed/s3api/s3api_object_handlers_multipart.go b/weed/s3api/s3api_object_handlers_multipart.go index ab69107e1..becbd9bf9 100644 --- a/weed/s3api/s3api_object_handlers_multipart.go +++ b/weed/s3api/s3api_object_handlers_multipart.go @@ -404,7 +404,7 @@ func (s3a *S3ApiServer) PutObjectPartHandler(w http.ResponseWriter, r *http.Requ } } - uploadUrl := s3a.genPartUploadUrl(bucket, uploadID, partID) + filePath := s3a.genPartUploadPath(bucket, uploadID, partID) if partID == 1 && r.Header.Get("Content-Type") == "" { dataReader = mimeDetect(r, dataReader) @@ -413,7 +413,7 @@ func (s3a *S3ApiServer) PutObjectPartHandler(w http.ResponseWriter, r *http.Requ glog.V(2).Infof("PutObjectPart: bucket=%s, object=%s, uploadId=%s, partNumber=%d, size=%d", bucket, object, uploadID, partID, r.ContentLength) - etag, errCode, sseMetadata := s3a.putToFiler(r, uploadUrl, dataReader, bucket, partID) + etag, errCode, sseMetadata := s3a.putToFiler(r, filePath, dataReader, bucket, partID) if errCode != s3err.ErrNone { glog.Errorf("PutObjectPart: putToFiler failed with error code %v for bucket=%s, object=%s, partNumber=%d", errCode, bucket, object, partID) @@ -444,11 +444,6 @@ func (s3a *S3ApiServer) genPartUploadPath(bucket, uploadID string, partID int) s s3a.genUploadsFolder(bucket), uploadID, partID, uuid.NewString()) } -// Deprecated: Use genPartUploadPath instead - no need for full URL -func (s3a *S3ApiServer) genPartUploadUrl(bucket, uploadID string, partID int) string { - return s3a.genPartUploadPath(bucket, uploadID, partID) -} - // Generate uploadID hash string from object func (s3a *S3ApiServer) generateUploadID(object string) string { diff --git a/weed/s3api/s3api_object_handlers_put.go b/weed/s3api/s3api_object_handlers_put.go index fce329b03..100796b2e 100644 --- a/weed/s3api/s3api_object_handlers_put.go +++ b/weed/s3api/s3api_object_handlers_put.go @@ -222,12 +222,12 @@ func (s3a *S3ApiServer) PutObjectHandler(w http.ResponseWriter, r *http.Request) s3a.setSSEResponseHeaders(w, r, sseMetadata) default: // Handle regular PUT (never configured versioning) - uploadUrl := s3a.toFilerUrl(bucket, object) + filePath := s3a.toFilerPath(bucket, object) if objectContentType == "" { dataReader = mimeDetect(r, dataReader) } - etag, errCode, sseMetadata := s3a.putToFiler(r, uploadUrl, dataReader, bucket, 1) + etag, errCode, sseMetadata := s3a.putToFiler(r, filePath, dataReader, bucket, 1) if errCode != s3err.ErrNone { s3err.WriteErrorResponse(w, r, errCode) @@ -730,7 +730,7 @@ func (s3a *S3ApiServer) setObjectOwnerFromRequest(r *http.Request, entry *filer_ // For suspended versioning, objects are stored as regular files (version ID "null") in the bucket directory, // while existing versions from when versioning was enabled remain preserved in the .versions subdirectory. func (s3a *S3ApiServer) putSuspendedVersioningObject(r *http.Request, bucket, object string, dataReader io.Reader, objectContentType string) (etag string, errCode s3err.ErrorCode, sseMetadata SSEResponseMetadata) { - // Normalize object path to ensure consistency with toFilerUrl behavior + // Normalize object path to ensure consistency with toFilerPath behavior normalizedObject := removeDuplicateSlashes(object) glog.V(3).Infof("putSuspendedVersioningObject: START bucket=%s, object=%s, normalized=%s", @@ -770,7 +770,7 @@ func (s3a *S3ApiServer) putSuspendedVersioningObject(r *http.Request, bucket, ob glog.V(3).Infof("putSuspendedVersioningObject: no .versions directory for %s/%s", bucket, object) } - uploadUrl := s3a.toFilerUrl(bucket, normalizedObject) + filePath := s3a.toFilerPath(bucket, normalizedObject) body := dataReader if objectContentType == "" { @@ -833,7 +833,7 @@ func (s3a *S3ApiServer) putSuspendedVersioningObject(r *http.Request, bucket, ob } // Upload the file using putToFiler - this will create the file with version metadata - etag, errCode, sseMetadata = s3a.putToFiler(r, uploadUrl, body, bucket, 1) + etag, errCode, sseMetadata = s3a.putToFiler(r, filePath, body, bucket, 1) if errCode != s3err.ErrNone { glog.Errorf("putSuspendedVersioningObject: failed to upload object: %v", errCode) return "", errCode, SSEResponseMetadata{} @@ -924,7 +924,7 @@ func (s3a *S3ApiServer) putVersionedObject(r *http.Request, bucket, object strin // Generate version ID versionId = generateVersionId() - // Normalize object path to ensure consistency with toFilerUrl behavior + // Normalize object path to ensure consistency with toFilerPath behavior normalizedObject := removeDuplicateSlashes(object) glog.V(2).Infof("putVersionedObject: creating version %s for %s/%s (normalized: %s)", versionId, bucket, object, normalizedObject) @@ -935,7 +935,7 @@ func (s3a *S3ApiServer) putVersionedObject(r *http.Request, bucket, object strin // Upload directly to the versions directory // We need to construct the object path relative to the bucket versionObjectPath := normalizedObject + s3_constants.VersionsFolder + "/" + versionFileName - versionUploadUrl := s3a.toFilerUrl(bucket, versionObjectPath) + versionFilePath := s3a.toFilerPath(bucket, versionObjectPath) // Ensure the .versions directory exists before uploading bucketDir := s3a.option.BucketsPath + "/" + bucket @@ -953,9 +953,9 @@ func (s3a *S3ApiServer) putVersionedObject(r *http.Request, bucket, object strin body = mimeDetect(r, body) } - glog.V(2).Infof("putVersionedObject: uploading %s/%s version %s to %s", bucket, object, versionId, versionUploadUrl) + glog.V(2).Infof("putVersionedObject: uploading %s/%s version %s to %s", bucket, object, versionId, versionFilePath) - etag, errCode, sseMetadata = s3a.putToFiler(r, versionUploadUrl, body, bucket, 1) + etag, errCode, sseMetadata = s3a.putToFiler(r, versionFilePath, body, bucket, 1) if errCode != s3err.ErrNone { glog.Errorf("putVersionedObject: failed to upload version: %v", errCode) return "", "", errCode, SSEResponseMetadata{} diff --git a/weed/s3api/s3api_object_handlers_test.go b/weed/s3api/s3api_object_handlers_test.go index cf650a36e..a6592ad4b 100644 --- a/weed/s3api/s3api_object_handlers_test.go +++ b/weed/s3api/s3api_object_handlers_test.go @@ -114,7 +114,7 @@ func TestRemoveDuplicateSlashes(t *testing.T) { } } -func TestS3ApiServer_toFilerUrl(t *testing.T) { +func TestS3ApiServer_toFilerPath(t *testing.T) { tests := []struct { name string args string diff --git a/weed/s3api/s3api_object_versioning.go b/weed/s3api/s3api_object_versioning.go index 1c1dbee03..bbc43f205 100644 --- a/weed/s3api/s3api_object_versioning.go +++ b/weed/s3api/s3api_object_versioning.go @@ -607,7 +607,7 @@ func (s3a *S3ApiServer) calculateETagFromChunks(chunks []*filer_pb.FileChunk) st // getSpecificObjectVersion retrieves a specific version of an object func (s3a *S3ApiServer) getSpecificObjectVersion(bucket, object, versionId string) (*filer_pb.Entry, error) { - // Normalize object path to ensure consistency with toFilerUrl behavior + // Normalize object path to ensure consistency with toFilerPath behavior normalizedObject := removeDuplicateSlashes(object) if versionId == "" { @@ -639,7 +639,7 @@ func (s3a *S3ApiServer) getSpecificObjectVersion(bucket, object, versionId strin // deleteSpecificObjectVersion deletes a specific version of an object func (s3a *S3ApiServer) deleteSpecificObjectVersion(bucket, object, versionId string) error { - // Normalize object path to ensure consistency with toFilerUrl behavior + // Normalize object path to ensure consistency with toFilerPath behavior normalizedObject := removeDuplicateSlashes(object) if versionId == "" { @@ -843,7 +843,7 @@ func (s3a *S3ApiServer) ListObjectVersionsHandler(w http.ResponseWriter, r *http // getLatestObjectVersion finds the latest version of an object by reading .versions directory metadata func (s3a *S3ApiServer) getLatestObjectVersion(bucket, object string) (*filer_pb.Entry, error) { - // Normalize object path to ensure consistency with toFilerUrl behavior + // Normalize object path to ensure consistency with toFilerPath behavior normalizedObject := removeDuplicateSlashes(object) bucketDir := s3a.option.BucketsPath + "/" + bucket