From 9012069bd7a98d1e12c1a6117b47861da8349e16 Mon Sep 17 00:00:00 2001 From: promalert Date: Thu, 8 Jan 2026 05:06:08 +0800 Subject: [PATCH] chore: execute goimports to format the code (#7983) * chore: execute goimports to format the code Signed-off-by: promalert * goimports -w . --------- Signed-off-by: promalert Co-authored-by: Chris Lu --- .../agent_pub_record/agent_pub_record.go | 7 +++-- .../agent_sub_record/agent_sub_record.go | 5 ++-- seaweedfs-rdma-sidecar/pkg/rdma/client.go | 4 +-- .../pkg/seaweedfs/client.go | 1 + telemetry/proto/telemetry.pb.go | 5 ++-- test/fuse_integration/framework.go | 1 + test/fuse_integration/minimal_test.go | 2 +- test/kafka/integration/rebalancing_test.go | 10 +++---- .../integration/schema_end_to_end_test.go | 5 ++-- .../consumer/consumer_stalling_test.go | 28 +++++++++--------- .../internal/schema/pb/loadtest.pb.go | 5 ++-- test/kafka/loadtest/resume_million_test.go | 1 - test/kafka/unit/gateway_test.go | 16 +++++----- test/s3/etag/s3_etag_test.go | 11 ++++--- test/s3/iam/s3_iam_integration_test.go | 6 ++-- test/s3/s3client/s3client.go | 3 +- test/s3/sse/github_7562_copy_test.go | 1 - .../s3_versioning_multipart_test.go | 1 - .../s3_versioning_pagination_stress_test.go | 1 - test/sftp/basic_test.go | 5 ++-- test/sftp/framework.go | 1 - .../load_test_meta_tail.go | 7 +++-- .../repeated_vacuum/repeated_vacuum.go | 5 ++-- .../s3/presigned_put/presigned_put.go | 7 +++-- .../bench_filer_upload/bench_filer_upload.go | 3 +- .../stress_filer_upload.go | 3 +- unmaintained/volume_tailer/volume_tailer.go | 2 +- weed/cluster/cluster_test.go | 3 +- weed/cluster/group_members.go | 3 +- .../lock_manager/distributed_lock_manager.go | 3 +- weed/cluster/lock_manager/lock_manager.go | 5 ++-- weed/command/autocomplete.go | 7 +++-- weed/command/benchmark.go | 7 ++--- weed/command/filer_meta_tail.go | 4 +-- weed/command/filer_meta_tail_elastic.go | 3 +- weed/command/filer_remote_gateway.go | 5 ++-- weed/command/filer_remote_gateway_buckets.go | 11 +++---- weed/command/filer_remote_sync.go | 3 +- weed/command/filer_sync_jobs.go | 5 ++-- weed/command/mini.go | 9 +++--- weed/command/mount_linux.go | 3 +- weed/command/sftp.go | 2 +- weed/command/shell.go | 1 + weed/command/update.go | 2 +- weed/command/version.go | 3 +- .../filer_etc/filer_etc_identity.go | 24 +++++++-------- weed/credential/filer_etc/filer_etc_policy.go | 14 ++++----- weed/credential/filer_etc/filer_etc_store.go | 2 +- .../abstract_sql/abstract_sql_store_kv.go | 3 +- weed/filer/arangodb/arangodb_store_bucket.go | 3 +- weed/filer/cassandra/cassandra_store_kv.go | 1 + weed/filer/cassandra2/cassandra_store_kv.go | 1 + weed/filer/configuration.go | 5 ++-- .../empty_folder_cleanup/cleanup_queue.go | 3 -- .../cleanup_queue_test.go | 3 -- .../empty_folder_cleaner.go | 1 - .../empty_folder_cleaner_test.go | 1 - weed/filer/entry.go | 2 +- weed/filer/etcd/etcd_store_kv.go | 1 + weed/filer/etcd/etcd_store_test.go | 3 +- weed/filer/filechunk_section_test.go | 3 +- weed/filer/filechunks.go | 2 +- weed/filer/filechunks2_test.go | 2 +- weed/filer/filechunks_read.go | 3 +- weed/filer/filechunks_read_test.go | 3 +- weed/filer/filerstore_wrapper.go | 6 ++-- weed/filer/hbase/hbase_store_kv.go | 3 +- weed/filer/interval_list_test.go | 3 +- weed/filer/leveldb/leveldb_store_kv.go | 1 + weed/filer/leveldb/leveldb_store_test.go | 2 +- weed/filer/leveldb2/leveldb2_store_test.go | 2 +- weed/filer/leveldb3/leveldb3_store_bucket.go | 3 +- weed/filer/leveldb3/leveldb3_store_test.go | 2 +- weed/filer/mysql/mysql_store.go | 5 ++-- weed/filer/read_remote.go | 1 + weed/filer/reader_cache_test.go | 4 +-- weed/filer/redis2/redis_sentinel_store.go | 3 +- .../redis3/kv_directory_children_test.go | 5 ++-- weed/filer/redis3/skiplist_element_store.go | 1 + weed/filer/redis_lua/redis_sentinel_store.go | 3 +- weed/filer/redis_lua/stored_procedure/init.go | 1 + weed/filer/remote_mapping.go | 1 + weed/filer/remote_storage.go | 5 ++-- weed/filer/remote_storage_test.go | 3 +- weed/filer/ydb/ydb_store_kv.go | 1 + weed/filer/ydb/ydb_store_test.go | 3 +- weed/filer/ydb/ydb_types.go | 1 + weed/glog/glog_file.go | 3 +- weed/iam/sts/constants.go | 20 ++++++------- weed/iam/sts/sts_service_test.go | 2 +- weed/iam/utils/arn_utils_test.go | 8 ++--- weed/images/orientation_test.go | 3 +- weed/images/resizing_test.go | 3 +- weed/mount/inode_to_path_test.go | 3 +- weed/mount/locked_entry.go | 3 +- weed/mount/meta_cache/meta_cache.go | 4 +-- weed/mount/meta_cache/meta_cache_subscribe.go | 3 +- .../page_writer/chunk_interval_list_test.go | 3 +- weed/mount/weedfs_forget.go | 1 + weed/mount/weedfs_grpc_server.go | 1 + weed/mount/weedfs_quota_test.go | 1 - weed/mount/weedfs_stats.go | 5 ++-- weed/mq/agent/agent_grpc_pub_session.go | 5 ++-- weed/mq/agent/agent_grpc_publish.go | 1 + weed/mq/agent/agent_server.go | 3 +- weed/mq/broker/broker_grpc_admin.go | 1 + weed/mq/broker/broker_grpc_balance.go | 1 + .../broker_grpc_topic_partition_control.go | 1 + .../mq/client/agent_client/publish_session.go | 1 + weed/mq/client/pub_client/publish.go | 3 +- weed/mq/client/pub_client/publisher.go | 5 ++-- weed/mq/pub_balancer/allocate_test.go | 3 +- weed/mq/pub_balancer/balance_action.go | 1 + weed/mq/pub_balancer/balance_brokers_test.go | 5 ++-- weed/mq/pub_balancer/broker_stats.go | 1 + weed/mq/pub_balancer/lookup.go | 1 + weed/mq/pub_balancer/repair_test.go | 3 +- weed/mq/schema/schema_test.go | 3 +- weed/mq/schema/struct_to_schema_test.go | 3 +- weed/mq/schema/to_parquet_levels.go | 1 + weed/mq/schema/to_parquet_levels_test.go | 3 +- weed/mq/segment/message_serde_test.go | 3 +- weed/mq/sub_coordinator/consumer_group.go | 3 +- .../inflight_message_tracker_test.go | 3 +- weed/mq/sub_coordinator/market.go | 5 ++-- .../partition_consumer_mapping.go | 3 +- .../partition_consumer_mapping_test.go | 3 +- .../gocdk_pub_sub/gocdk_pub_sub.go | 13 +++++---- weed/operation/assign_file_id.go | 3 +- weed/operation/assign_file_id_test.go | 5 ++-- weed/operation/buffer_pool.go | 3 +- weed/operation/submit.go | 3 +- weed/operation/sync_volume.go | 1 + weed/pb/filer_pb/filer.pb.go | 5 ++-- weed/pb/filer_pb/filer_client_bfs.go | 3 +- weed/pb/filer_pb/filer_grpc.pb.go | 1 + weed/pb/filer_pb_tail.go | 5 ++-- weed/pb/iam_pb/iam.pb.go | 5 ++-- weed/pb/master_pb/master.pb.go | 5 ++-- weed/pb/master_pb/master_grpc.pb.go | 1 + weed/pb/mount_pb/mount.pb.go | 5 ++-- weed/pb/mount_pb/mount_grpc.pb.go | 1 + weed/pb/mq_agent_pb/mq_agent.pb.go | 7 +++-- weed/pb/mq_agent_pb/mq_agent_grpc.pb.go | 1 + weed/pb/mq_agent_pb/publish_response_test.go | 3 +- weed/pb/mq_pb/mq_broker.pb.go | 7 +++-- weed/pb/mq_pb/mq_broker_grpc.pb.go | 1 + weed/pb/remote_pb/remote.pb.go | 5 ++-- weed/pb/s3_pb/s3.pb.go | 5 ++-- weed/pb/s3_pb/s3_grpc.pb.go | 1 + weed/pb/schema_pb/mq_schema.pb.go | 5 ++-- weed/pb/schema_pb/offset_test.go | 3 +- weed/pb/server_discovery.go | 3 +- weed/pb/volume_server_pb/volume_server.pb.go | 7 +++-- .../volume_server_pb/volume_server_grpc.pb.go | 1 + weed/pb/worker_pb/worker.pb.go | 5 ++-- weed/pb/worker_pb/worker_grpc.pb.go | 1 + weed/remote_storage/remote_storage.go | 7 +++-- weed/remote_storage/s3/aliyun.go | 3 +- weed/remote_storage/s3/backblaze.go | 1 + weed/remote_storage/s3/filebase.go | 3 +- weed/remote_storage/s3/s3_storage_client.go | 2 +- weed/remote_storage/s3/storj.go | 3 +- weed/remote_storage/s3/tencent.go | 3 +- weed/remote_storage/s3/wasabi.go | 1 + weed/remote_storage/track_sync_offset.go | 1 + weed/replication/replicator.go | 4 +-- weed/replication/sink/b2sink/b2_sink.go | 2 +- weed/replication/sink/filersink/filer_sink.go | 3 +- weed/replication/sink/localsink/local_sink.go | 7 +++-- weed/replication/sink/s3sink/s3_sink.go | 5 ++-- .../sub/notification_gocdk_pub_sub.go | 11 +++---- weed/s3api/bucket_metadata_test.go | 9 +++--- weed/s3api/filer_multipart_test.go | 10 +++---- weed/s3api/filer_util_tags.go | 2 +- weed/s3api/policy/post-policy.go | 3 +- weed/s3api/s3_constants/buckets.go | 1 - weed/s3api/s3_constants/extend_key.go | 12 ++++---- weed/s3api/s3_existing_object_tag_test.go | 1 - weed/s3api/s3api_acl_helper_test.go | 7 +++-- weed/s3api/s3api_acp.go | 3 +- ...3api_bucket_handlers_object_lock_config.go | 2 +- weed/s3api/s3api_circuit_breaker.go | 10 +++---- weed/s3api/s3api_circuit_breaker_test.go | 7 +++-- .../s3api/s3api_encrypted_volume_copy_test.go | 1 - weed/s3api/s3api_handlers.go | 22 +++++++------- weed/s3api/s3api_list_normalization_test.go | 6 ++-- weed/s3api/s3api_server_grpc.go | 1 + weed/s3api/s3api_status_handlers.go | 3 +- weed/s3api/s3api_streaming_copy.go | 4 +-- weed/s3api/s3api_test.go | 3 +- weed/s3api/s3api_version_id_test.go | 1 - weed/s3api/s3bucket/s3api_bucket_test.go | 3 +- weed/sequence/snowflake_sequencer_test.go | 3 +- weed/server/filer_grpc_server_admin.go | 2 +- weed/server/filer_grpc_server_kv.go | 1 + .../filer_grpc_server_traverse_meta_test.go | 3 +- weed/server/filer_server_handlers.go | 6 ++-- weed/server/filer_server_handlers_read_dir.go | 2 +- weed/server/filer_ui/templates.go | 3 +- weed/server/master_grpc_server_admin.go | 5 ++-- weed/server/master_grpc_server_cluster.go | 3 +- weed/server/raft_server_handlers.go | 5 ++-- weed/server/volume_grpc_copy.go | 8 ++--- weed/server/volume_grpc_read_all.go | 1 + weed/server/volume_grpc_read_write.go | 1 + weed/server/volume_grpc_remote.go | 5 ++-- weed/server/wrapped_webdav_fs.go | 3 +- weed/shell/command_cluster_check.go | 2 +- weed/shell/command_cluster_ps.go | 5 ++-- weed/shell/command_cluster_raft_add.go | 3 +- .../command_cluster_raft_leader_transfer.go | 1 - ...mmand_cluster_raft_leader_transfer_test.go | 1 - weed/shell/command_cluster_raft_ps.go | 3 +- weed/shell/command_cluster_raft_remove.go | 3 +- weed/shell/command_collection_list.go | 3 +- weed/shell/command_fs_log.go | 5 ++-- weed/shell/command_fs_verify.go | 3 +- weed/shell/command_lock_unlock.go | 3 +- weed/shell/command_mq_balance.go | 3 +- weed/shell/command_mq_topic_configure.go | 3 +- weed/shell/command_mq_topic_desc.go | 3 +- weed/shell/command_mq_topic_list.go | 3 +- weed/shell/command_remote_meta_sync.go | 3 +- weed/shell/command_remote_mount.go | 9 +++--- weed/shell/command_remote_mount_buckets.go | 7 +++-- weed/shell/command_remote_unmount.go | 5 ++-- weed/shell/command_volume_copy.go | 2 +- weed/shell/command_volume_delete.go | 2 +- weed/shell/command_volume_grow.go | 3 +- weed/shell/command_volume_mount.go | 2 +- .../command_volume_replica_check_test.go | 1 - weed/shell/command_volume_unmount.go | 2 +- weed/stats/disk_windows.go | 5 ++-- weed/stats/metrics_buildinfo_test.go | 3 +- weed/storage/backend/backend.go | 2 +- weed/storage/backend/disk_file.go | 5 ++-- .../memory_map/os_overloads/file_windows.go | 2 +- .../backend/rclone_backend/rclone_backend.go | 6 ++-- .../storage/backend/s3_backend/s3_sessions.go | 2 +- weed/storage/backend/s3_backend/s3_upload.go | 5 ++-- weed/storage/disk_location_test.go | 2 +- .../erasure_coding/distribution/analysis.go | 29 +++++++++---------- .../distribution/distribution.go | 1 - .../erasure_coding/distribution/rebalancer.go | 9 +++--- weed/storage/erasure_coding/ec_test.go | 3 +- .../placement/placement_test.go | 16 +++++----- weed/storage/needle/file_id_test.go | 3 +- weed/storage/types/needle_id_type.go | 3 +- weed/storage/volume_checking.go | 2 +- weed/storage/volume_info/volume_info.go | 2 +- weed/topology/cluster_commands.go | 1 + weed/topology/collection.go | 1 + weed/topology/store_replicate.go | 2 +- weed/topology/topology_info.go | 3 +- .../util/chunk_cache/chunk_cache_in_memory.go | 3 +- weed/util/chunk_cache/on_disk_cache_layer.go | 5 ++-- weed/util/file_util.go | 3 +- weed/util/grace/signal_handling.go | 3 +- weed/util/http/client/http_client.go | 5 ++-- weed/util/inits_test.go | 3 +- weed/util/limited_async_pool_test.go | 3 +- weed/util/log_buffer/log_read.go | 6 ++-- weed/util/mem/slot_pool_test.go | 3 +- weed/util/minfreespace.go | 3 +- weed/util/queue_test.go | 3 +- weed/util/skiplist/name_batch.go | 5 ++-- weed/util/skiplist/skiplist.pb.go | 5 ++-- weed/wdclient/masterclient_test.go | 2 -- weed/wdclient/net2/managed_connection.go | 1 + weed/wdclient/vid_map_test.go | 5 ++-- 271 files changed, 608 insertions(+), 461 deletions(-) diff --git a/other/mq_client_example/agent_pub_record/agent_pub_record.go b/other/mq_client_example/agent_pub_record/agent_pub_record.go index 48e78f530..8f93281c5 100644 --- a/other/mq_client_example/agent_pub_record/agent_pub_record.go +++ b/other/mq_client_example/agent_pub_record/agent_pub_record.go @@ -3,13 +3,14 @@ package main import ( "flag" "fmt" - "github.com/seaweedfs/seaweedfs/other/mq_client_example/example" - "github.com/seaweedfs/seaweedfs/weed/mq/client/agent_client" - "github.com/seaweedfs/seaweedfs/weed/mq/schema" "log" "sync" "sync/atomic" "time" + + "github.com/seaweedfs/seaweedfs/other/mq_client_example/example" + "github.com/seaweedfs/seaweedfs/weed/mq/client/agent_client" + "github.com/seaweedfs/seaweedfs/weed/mq/schema" ) var ( diff --git a/other/mq_client_example/agent_sub_record/agent_sub_record.go b/other/mq_client_example/agent_sub_record/agent_sub_record.go index 21c74a46d..bc807b3cc 100644 --- a/other/mq_client_example/agent_sub_record/agent_sub_record.go +++ b/other/mq_client_example/agent_sub_record/agent_sub_record.go @@ -3,13 +3,14 @@ package main import ( "flag" "fmt" + "log" + "time" + "github.com/seaweedfs/seaweedfs/other/mq_client_example/example" "github.com/seaweedfs/seaweedfs/weed/mq/client/agent_client" "github.com/seaweedfs/seaweedfs/weed/mq/topic" "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" "github.com/seaweedfs/seaweedfs/weed/util" - "log" - "time" ) var ( diff --git a/seaweedfs-rdma-sidecar/pkg/rdma/client.go b/seaweedfs-rdma-sidecar/pkg/rdma/client.go index 156bb5497..08ad76042 100644 --- a/seaweedfs-rdma-sidecar/pkg/rdma/client.go +++ b/seaweedfs-rdma-sidecar/pkg/rdma/client.go @@ -419,7 +419,7 @@ func (c *Client) Read(ctx context.Context, req *ReadRequest) (*ReadResponse, err }).Info("✅ RDMA read completed successfully") // MOCK DATA IMPLEMENTATION - FOR DEVELOPMENT/TESTING ONLY - // + // // This section generates placeholder data for the mock RDMA implementation. // In a production RDMA implementation, this should be replaced with: // @@ -472,7 +472,7 @@ func (c *Client) ReadFileRange(ctx context.Context, fileID string, offset, size if err != nil { return nil, fmt.Errorf("invalid file ID %s: %w", fileID, err) } - + req := &ReadRequest{ VolumeID: volumeID, NeedleID: needleID, diff --git a/seaweedfs-rdma-sidecar/pkg/seaweedfs/client.go b/seaweedfs-rdma-sidecar/pkg/seaweedfs/client.go index 5073c349a..22047e504 100644 --- a/seaweedfs-rdma-sidecar/pkg/seaweedfs/client.go +++ b/seaweedfs-rdma-sidecar/pkg/seaweedfs/client.go @@ -8,6 +8,7 @@ import ( "net/http" "os" "path/filepath" + "strings" "time" "seaweedfs-rdma-sidecar/pkg/rdma" diff --git a/telemetry/proto/telemetry.pb.go b/telemetry/proto/telemetry.pb.go index a400b8c37..8aa6ab626 100644 --- a/telemetry/proto/telemetry.pb.go +++ b/telemetry/proto/telemetry.pb.go @@ -7,10 +7,11 @@ package proto import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/test/fuse_integration/framework.go b/test/fuse_integration/framework.go index 2fe7ef343..25fa2beb8 100644 --- a/test/fuse_integration/framework.go +++ b/test/fuse_integration/framework.go @@ -3,6 +3,7 @@ package fuse_test import ( "fmt" "io/fs" + "net" "os" "os/exec" "path/filepath" diff --git a/test/fuse_integration/minimal_test.go b/test/fuse_integration/minimal_test.go index 8d849fe77..13632df96 100644 --- a/test/fuse_integration/minimal_test.go +++ b/test/fuse_integration/minimal_test.go @@ -3,5 +3,5 @@ package fuse_test import "testing" func TestMinimal(t *testing.T) { - t.Log("minimal test") + t.Log("minimal test") } diff --git a/test/kafka/integration/rebalancing_test.go b/test/kafka/integration/rebalancing_test.go index f5ddeed56..fb962f888 100644 --- a/test/kafka/integration/rebalancing_test.go +++ b/test/kafka/integration/rebalancing_test.go @@ -152,7 +152,7 @@ func testTwoConsumersRebalance(t *testing.T, addr, topicName, groupID string) { // Wait for rebalancing to occur - both consumers should get new assignments var rebalancedAssignment1, rebalancedAssignment2 []int32 - + // Consumer1 should get a rebalance assignment select { case partitions := <-handler1.assignments: @@ -372,7 +372,7 @@ func testMultipleConsumersJoin(t *testing.T, addr, topicName, groupID string) { t.Errorf("Partition %d assigned to multiple consumers", partition) } } - + // Each consumer should get exactly 1 partition (4 partitions / 4 consumers) if len(assignment) != 1 { t.Errorf("Consumer%d should get exactly 1 partition, got %d", i, len(assignment)) @@ -408,7 +408,7 @@ func (h *RebalanceTestHandler) Setup(session sarama.ConsumerGroupSession) error h.readyOnce.Do(func() { close(h.ready) }) - + // Send partition assignment partitions := make([]int32, 0) for topic, partitionList := range session.Claims() { @@ -417,13 +417,13 @@ func (h *RebalanceTestHandler) Setup(session sarama.ConsumerGroupSession) error partitions = append(partitions, partition) } } - + select { case h.assignments <- partitions: default: // Channel might be full, that's ok } - + return nil } diff --git a/test/kafka/integration/schema_end_to_end_test.go b/test/kafka/integration/schema_end_to_end_test.go index 414056dd0..c0115e1e2 100644 --- a/test/kafka/integration/schema_end_to_end_test.go +++ b/test/kafka/integration/schema_end_to_end_test.go @@ -86,7 +86,7 @@ func TestSchemaEndToEnd_AvroRoundTrip(t *testing.T) { // Verify all fields assert.Equal(t, int32(12345), decodedMap["id"]) assert.Equal(t, "Alice Johnson", decodedMap["name"]) - + // Verify union fields emailUnion, ok := decodedMap["email"].(map[string]interface{}) require.True(t, ok, "Email should be a union") @@ -126,7 +126,7 @@ func TestSchemaEndToEnd_ProtobufRoundTrip(t *testing.T) { require.Equal(t, uint32(2), envelope.SchemaID, "Schema ID should match") // Note: ParseConfluentEnvelope defaults to FormatAvro; format detection requires schema registry require.Equal(t, schema.FormatAvro, envelope.Format, "Format defaults to Avro without schema registry lookup") - + // For Protobuf with indexes, we need to use the specialized parser protobufEnvelope, ok := schema.ParseConfluentProtobufEnvelopeWithIndexCount(confluentMsg, 1) require.True(t, ok, "Message should be a valid Protobuf envelope") @@ -269,7 +269,6 @@ func createMockSchemaRegistryForE2E(t *testing.T) *httptest.Server { })) } - func getUserAvroSchemaForE2E() string { return `{ "type": "record", diff --git a/test/kafka/kafka-client-loadtest/internal/consumer/consumer_stalling_test.go b/test/kafka/kafka-client-loadtest/internal/consumer/consumer_stalling_test.go index 8e67f703e..359a9e547 100644 --- a/test/kafka/kafka-client-loadtest/internal/consumer/consumer_stalling_test.go +++ b/test/kafka/kafka-client-loadtest/internal/consumer/consumer_stalling_test.go @@ -5,7 +5,7 @@ import ( ) // TestConsumerStallingPattern is a REPRODUCER for the consumer stalling bug. -// +// // This test simulates the exact pattern that causes consumers to stall: // 1. Consumer reads messages in batches // 2. Consumer commits offset after each batch @@ -24,7 +24,7 @@ import ( // If the test PASSES, it means consumer successfully fetches all messages (bug fixed) func TestConsumerStallingPattern(t *testing.T) { t.Skip("REPRODUCER TEST: Requires running load test infrastructure. See comments for setup.") - + // This test documents the exact stalling pattern: // - Consumers consume messages 0-163, commit offset 163 // - Next iteration: fetch offset 164+ @@ -36,7 +36,7 @@ func TestConsumerStallingPattern(t *testing.T) { // 2. Empty fetch doesn't mean "end of partition" (could be transient) // 3. Consumer retries on empty fetch instead of giving up // 4. Logging shows why fetch stopped - + t.Logf("=== CONSUMER STALLING REPRODUCER ===") t.Logf("") t.Logf("Setup Steps:") @@ -72,27 +72,27 @@ func TestConsumerStallingPattern(t *testing.T) { // This is a UNIT reproducer that can run standalone func TestOffsetPlusOneCalculation(t *testing.T) { testCases := []struct { - name string - committedOffset int64 + name string + committedOffset int64 expectedNextOffset int64 }{ {"Offset 0", 0, 1}, {"Offset 99", 99, 100}, - {"Offset 163", 163, 164}, // The exact stalling point! + {"Offset 163", 163, 164}, // The exact stalling point! {"Offset 999", 999, 1000}, {"Large offset", 10000, 10001}, } - + for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { // This is the critical calculation nextOffset := tc.committedOffset + 1 - + if nextOffset != tc.expectedNextOffset { t.Fatalf("OFFSET MATH BUG: committed=%d, next=%d (expected %d)", tc.committedOffset, nextOffset, tc.expectedNextOffset) } - + t.Logf("✓ offset %d → next fetch at %d", tc.committedOffset, nextOffset) }) } @@ -105,18 +105,18 @@ func TestEmptyFetchShouldNotStopConsumer(t *testing.T) { // Scenario: Consumer committed offset 163, then fetches 164+ committedOffset := int64(163) nextFetchOffset := committedOffset + 1 - + // First attempt: get empty (transient - data might not be available yet) // WRONG behavior (bug): Consumer sees 0 bytes and stops // wrongConsumerLogic := (firstFetchResult == 0) // gives up! - + // CORRECT behavior: Consumer should retry - correctConsumerLogic := true // continues retrying - + correctConsumerLogic := true // continues retrying + if !correctConsumerLogic { t.Fatalf("Consumer incorrectly gave up after empty fetch at offset %d", nextFetchOffset) } - + t.Logf("✓ Empty fetch doesn't stop consumer, continues retrying") }) } diff --git a/test/kafka/kafka-client-loadtest/internal/schema/pb/loadtest.pb.go b/test/kafka/kafka-client-loadtest/internal/schema/pb/loadtest.pb.go index 3ed58aa9e..f70414f7b 100644 --- a/test/kafka/kafka-client-loadtest/internal/schema/pb/loadtest.pb.go +++ b/test/kafka/kafka-client-loadtest/internal/schema/pb/loadtest.pb.go @@ -7,11 +7,12 @@ package pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/test/kafka/loadtest/resume_million_test.go b/test/kafka/loadtest/resume_million_test.go index 48656c154..699236d5c 100644 --- a/test/kafka/loadtest/resume_million_test.go +++ b/test/kafka/loadtest/resume_million_test.go @@ -205,4 +205,3 @@ func TestResumeMillionRecords_Fixed(t *testing.T) { glog.Infof("🏆 MILLION RECORD KAFKA INTEGRATION TEST COMPLETED SUCCESSFULLY!") } - diff --git a/test/kafka/unit/gateway_test.go b/test/kafka/unit/gateway_test.go index 7f6d076e0..e6d4c9cfc 100644 --- a/test/kafka/unit/gateway_test.go +++ b/test/kafka/unit/gateway_test.go @@ -16,7 +16,7 @@ func TestGatewayBasicFunctionality(t *testing.T) { defer gateway.CleanupAndClose() addr := gateway.StartAndWait() - + // Give the gateway a bit more time to be fully ready time.Sleep(200 * time.Millisecond) @@ -32,17 +32,17 @@ func TestGatewayBasicFunctionality(t *testing.T) { func testGatewayAcceptsConnections(t *testing.T, addr string) { // Test basic TCP connection to gateway t.Logf("Testing connection to gateway at %s", addr) - + conn, err := net.DialTimeout("tcp", addr, 5*time.Second) if err != nil { t.Fatalf("Failed to connect to gateway: %v", err) } defer conn.Close() - + // Test that we can establish a connection and the gateway is listening // We don't need to send a full Kafka request for this basic test t.Logf("Successfully connected to gateway at %s", addr) - + // Optional: Test that we can write some data without error testData := []byte("test") conn.SetWriteDeadline(time.Now().Add(1 * time.Second)) @@ -57,19 +57,19 @@ func testGatewayRefusesAfterClose(t *testing.T, gateway *testutil.GatewayTestSer // Get the address from the gateway's listener host, port := gateway.GetListenerAddr() addr := fmt.Sprintf("%s:%d", host, port) - + // Close the gateway gateway.CleanupAndClose() - + t.Log("Testing that gateway refuses connections after close") - + // Attempt to connect - should fail conn, err := net.DialTimeout("tcp", addr, 2*time.Second) if err == nil { conn.Close() t.Fatal("Expected connection to fail after gateway close, but it succeeded") } - + // Verify it's a connection refused error if !strings.Contains(err.Error(), "connection refused") && !strings.Contains(err.Error(), "connect: connection refused") { t.Logf("Connection failed as expected with error: %v", err) diff --git a/test/s3/etag/s3_etag_test.go b/test/s3/etag/s3_etag_test.go index 1b87eaf12..9b1e948b0 100644 --- a/test/s3/etag/s3_etag_test.go +++ b/test/s3/etag/s3_etag_test.go @@ -63,11 +63,11 @@ const ( autoChunkSize = 8 * 1024 * 1024 // Test sizes - smallFileSize = 1 * 1024 // 1KB - single chunk - mediumFileSize = 256 * 1024 // 256KB - single chunk (at threshold) - largeFileSize = 10 * 1024 * 1024 // 10MB - triggers auto-chunking (2 chunks) - xlFileSize = 25 * 1024 * 1024 // 25MB - triggers auto-chunking (4 chunks) - multipartSize = 5 * 1024 * 1024 // 5MB per part for multipart uploads + smallFileSize = 1 * 1024 // 1KB - single chunk + mediumFileSize = 256 * 1024 // 256KB - single chunk (at threshold) + largeFileSize = 10 * 1024 * 1024 // 10MB - triggers auto-chunking (2 chunks) + xlFileSize = 25 * 1024 * 1024 // 25MB - triggers auto-chunking (4 chunks) + multipartSize = 5 * 1024 * 1024 // 5MB per part for multipart uploads ) // ETag format patterns @@ -540,4 +540,3 @@ func TestMultipleLargeFileUploads(t *testing.T) { assert.NoError(t, err, "File %d ETag should be valid hex", i) } } - diff --git a/test/s3/iam/s3_iam_integration_test.go b/test/s3/iam/s3_iam_integration_test.go index ecf5f0eba..478e330cd 100644 --- a/test/s3/iam/s3_iam_integration_test.go +++ b/test/s3/iam/s3_iam_integration_test.go @@ -443,7 +443,7 @@ func TestS3IAMBucketPolicyIntegration(t *testing.T) { require.NoError(t, err) assert.Equal(t, testObjectData, string(data)) result.Body.Close() - + // Clean up bucket policy after this test _, err = adminClient.DeleteBucketPolicy(&s3.DeleteBucketPolicyInput{ Bucket: aws.String(bucketName), @@ -481,7 +481,7 @@ func TestS3IAMBucketPolicyIntegration(t *testing.T) { assert.Contains(t, *policyResult.Policy, "Deny") // NOTE: Enforcement test is commented out due to known architectural limitation: - // + // // KNOWN LIMITATION: DeleteObject uses the coarse-grained ACTION_WRITE constant, // which convertActionToS3Format maps to "s3:PutObject" (not "s3:DeleteObject"). // This means the policy engine evaluates the deny policy against "s3:PutObject", @@ -499,7 +499,7 @@ func TestS3IAMBucketPolicyIntegration(t *testing.T) { // awsErr, ok := err.(awserr.Error) // require.True(t, ok, "Error should be an awserr.Error") // assert.Equal(t, "AccessDenied", awsErr.Code(), "Expected AccessDenied error code") - + // Clean up bucket policy after this test _, err = adminClient.DeleteBucketPolicy(&s3.DeleteBucketPolicyInput{ Bucket: aws.String(bucketName), diff --git a/test/s3/s3client/s3client.go b/test/s3/s3client/s3client.go index e789c57c6..0179ad27c 100644 --- a/test/s3/s3client/s3client.go +++ b/test/s3/s3client/s3client.go @@ -2,12 +2,13 @@ package main import ( "context" + "time" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/retry" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/service/s3" - "time" ) func main() { diff --git a/test/s3/sse/github_7562_copy_test.go b/test/s3/sse/github_7562_copy_test.go index 5831c0b80..088ae93ad 100644 --- a/test/s3/sse/github_7562_copy_test.go +++ b/test/s3/sse/github_7562_copy_test.go @@ -502,4 +502,3 @@ func TestGitHub7562LargeFile(t *testing.T) { t.Log("Large file test passed!") } - diff --git a/test/s3/versioning/s3_versioning_multipart_test.go b/test/s3/versioning/s3_versioning_multipart_test.go index 8fb51380c..23520c806 100644 --- a/test/s3/versioning/s3_versioning_multipart_test.go +++ b/test/s3/versioning/s3_versioning_multipart_test.go @@ -518,4 +518,3 @@ func TestMultipartUploadDeleteMarkerListBehavior(t *testing.T) { t.Logf("Object restored after delete marker removal, ETag=%s", multipartETag) } - diff --git a/test/s3/versioning/s3_versioning_pagination_stress_test.go b/test/s3/versioning/s3_versioning_pagination_stress_test.go index acd716f15..ae18cac65 100644 --- a/test/s3/versioning/s3_versioning_pagination_stress_test.go +++ b/test/s3/versioning/s3_versioning_pagination_stress_test.go @@ -319,4 +319,3 @@ func listAllVersions(t *testing.T, client *s3.Client, bucketName, objectKey stri t.Logf("Total: %d versions in %d pages", len(allVersions), pageCount) return allVersions } - diff --git a/test/sftp/basic_test.go b/test/sftp/basic_test.go index e5ffe90d1..bad875208 100644 --- a/test/sftp/basic_test.go +++ b/test/sftp/basic_test.go @@ -540,11 +540,11 @@ func TestPathEdgeCases(t *testing.T) { // Therefore, we cannot trigger the server-side path traversal block with this client. // Instead, we verify that the file is created successfully within the jail (contained). // The server-side protection logic is verified in unit tests (sftpd/sftp_server_test.go). - + file, err := sftpClient.Create(traversalPath) require.NoError(t, err, "creation should succeed because client sanitizes path") file.Close() - + // Clean up err = sftpClient.Remove(traversalPath) require.NoError(t, err) @@ -649,4 +649,3 @@ func TestFileContent(t *testing.T) { sftpClient.Remove(filename) }) } - diff --git a/test/sftp/framework.go b/test/sftp/framework.go index ea4ac3e35..73b122e30 100644 --- a/test/sftp/framework.go +++ b/test/sftp/framework.go @@ -420,4 +420,3 @@ func findTestDataPath() string { return "./testdata" } - diff --git a/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go b/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go index 0544e5f2b..3f15c30ad 100644 --- a/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go +++ b/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go @@ -4,6 +4,10 @@ import ( "context" "flag" "fmt" + "strconv" + "strings" + "time" + "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" @@ -11,9 +15,6 @@ import ( util_http "github.com/seaweedfs/seaweedfs/weed/util/http" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "strconv" - "strings" - "time" ) var ( diff --git a/unmaintained/repeated_vacuum/repeated_vacuum.go b/unmaintained/repeated_vacuum/repeated_vacuum.go index 0a796a92f..983db9267 100644 --- a/unmaintained/repeated_vacuum/repeated_vacuum.go +++ b/unmaintained/repeated_vacuum/repeated_vacuum.go @@ -4,17 +4,16 @@ import ( "context" "flag" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb" "log" "math/rand" "time" - "google.golang.org/grpc" - "github.com/seaweedfs/seaweedfs/weed/operation" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/security" "github.com/seaweedfs/seaweedfs/weed/util" util_http "github.com/seaweedfs/seaweedfs/weed/util/http" + "google.golang.org/grpc" ) var ( diff --git a/unmaintained/s3/presigned_put/presigned_put.go b/unmaintained/s3/presigned_put/presigned_put.go index 46e4cbf06..f4c7ad6e8 100644 --- a/unmaintained/s3/presigned_put/presigned_put.go +++ b/unmaintained/s3/presigned_put/presigned_put.go @@ -4,13 +4,14 @@ import ( "crypto/md5" "encoding/base64" "fmt" + "net/http" + "strings" + "time" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" util_http "github.com/seaweedfs/seaweedfs/weed/util/http" - "net/http" - "strings" - "time" ) // Downloads an item from an S3 Bucket in the region configured in the shared config diff --git a/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go b/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go index a98da1d01..0cc06c03a 100644 --- a/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go +++ b/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go @@ -4,7 +4,6 @@ import ( "bytes" "flag" "fmt" - util_http "github.com/seaweedfs/seaweedfs/weed/util/http" "io" "log" "math/rand" @@ -14,6 +13,8 @@ import ( "strings" "sync" "time" + + util_http "github.com/seaweedfs/seaweedfs/weed/util/http" ) var ( diff --git a/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go b/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go index 1c3befe3d..d8b306b52 100644 --- a/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go +++ b/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go @@ -4,7 +4,6 @@ import ( "bytes" "flag" "fmt" - util_http "github.com/seaweedfs/seaweedfs/weed/util/http" "io" "log" "math/rand" @@ -15,6 +14,8 @@ import ( "strings" "sync" "time" + + util_http "github.com/seaweedfs/seaweedfs/weed/util/http" ) var ( diff --git a/unmaintained/volume_tailer/volume_tailer.go b/unmaintained/volume_tailer/volume_tailer.go index 03f728ad0..48f9d5e15 100644 --- a/unmaintained/volume_tailer/volume_tailer.go +++ b/unmaintained/volume_tailer/volume_tailer.go @@ -3,11 +3,11 @@ package main import ( "context" "flag" - "github.com/seaweedfs/seaweedfs/weed/pb" "log" "time" "github.com/seaweedfs/seaweedfs/weed/operation" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/security" "github.com/seaweedfs/seaweedfs/weed/storage/needle" util2 "github.com/seaweedfs/seaweedfs/weed/util" diff --git a/weed/cluster/cluster_test.go b/weed/cluster/cluster_test.go index db8384d88..d7a0047e2 100644 --- a/weed/cluster/cluster_test.go +++ b/weed/cluster/cluster_test.go @@ -1,10 +1,11 @@ package cluster import ( - "github.com/seaweedfs/seaweedfs/weed/pb" "strconv" "sync" "testing" + + "github.com/seaweedfs/seaweedfs/weed/pb" ) func TestConcurrentAddRemoveNodes(t *testing.T) { diff --git a/weed/cluster/group_members.go b/weed/cluster/group_members.go index 79bd78790..5c0c09977 100644 --- a/weed/cluster/group_members.go +++ b/weed/cluster/group_members.go @@ -1,8 +1,9 @@ package cluster import ( - "github.com/seaweedfs/seaweedfs/weed/pb" "time" + + "github.com/seaweedfs/seaweedfs/weed/pb" ) type GroupMembers struct { diff --git a/weed/cluster/lock_manager/distributed_lock_manager.go b/weed/cluster/lock_manager/distributed_lock_manager.go index 7de78410f..31f8b979f 100644 --- a/weed/cluster/lock_manager/distributed_lock_manager.go +++ b/weed/cluster/lock_manager/distributed_lock_manager.go @@ -2,9 +2,10 @@ package lock_manager import ( "fmt" + "time" + "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb" - "time" ) const RenewInterval = time.Second * 3 diff --git a/weed/cluster/lock_manager/lock_manager.go b/weed/cluster/lock_manager/lock_manager.go index ebc9dfeaa..4f7c6f9c6 100644 --- a/weed/cluster/lock_manager/lock_manager.go +++ b/weed/cluster/lock_manager/lock_manager.go @@ -2,10 +2,11 @@ package lock_manager import ( "fmt" - "github.com/google/uuid" - "github.com/seaweedfs/seaweedfs/weed/glog" "sync" "time" + + "github.com/google/uuid" + "github.com/seaweedfs/seaweedfs/weed/glog" ) var LockErrorNonEmptyTokenOnNewLock = fmt.Errorf("lock: non-empty token on a new lock") diff --git a/weed/command/autocomplete.go b/weed/command/autocomplete.go index 6a74311dc..4422e3b2d 100644 --- a/weed/command/autocomplete.go +++ b/weed/command/autocomplete.go @@ -2,12 +2,13 @@ package command import ( "fmt" - "github.com/posener/complete" - completeinstall "github.com/posener/complete/cmd/install" - flag "github.com/seaweedfs/seaweedfs/weed/util/fla9" "os" "path/filepath" "runtime" + + "github.com/posener/complete" + completeinstall "github.com/posener/complete/cmd/install" + flag "github.com/seaweedfs/seaweedfs/weed/util/fla9" ) func AutocompleteMain(commands []*Command) bool { diff --git a/weed/command/benchmark.go b/weed/command/benchmark.go index c9e6f6766..91ec1cfb0 100644 --- a/weed/command/benchmark.go +++ b/weed/command/benchmark.go @@ -4,8 +4,6 @@ import ( "bufio" "context" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb" - "github.com/seaweedfs/seaweedfs/weed/util/version" "io" "math" "math/rand" @@ -16,14 +14,15 @@ import ( "sync" "time" - "google.golang.org/grpc" - "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/operation" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/security" "github.com/seaweedfs/seaweedfs/weed/util" util_http "github.com/seaweedfs/seaweedfs/weed/util/http" + "github.com/seaweedfs/seaweedfs/weed/util/version" "github.com/seaweedfs/seaweedfs/weed/wdclient" + "google.golang.org/grpc" ) type BenchmarkOptions struct { diff --git a/weed/command/filer_meta_tail.go b/weed/command/filer_meta_tail.go index d7a169535..94481c28d 100644 --- a/weed/command/filer_meta_tail.go +++ b/weed/command/filer_meta_tail.go @@ -2,13 +2,13 @@ package command import ( "fmt" - "github.com/seaweedfs/seaweedfs/weed/filer" - "github.com/seaweedfs/seaweedfs/weed/pb" "os" "path/filepath" "strings" "time" + "github.com/seaweedfs/seaweedfs/weed/filer" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/security" "github.com/seaweedfs/seaweedfs/weed/util" diff --git a/weed/command/filer_meta_tail_elastic.go b/weed/command/filer_meta_tail_elastic.go index a72f88902..6e18638dd 100644 --- a/weed/command/filer_meta_tail_elastic.go +++ b/weed/command/filer_meta_tail_elastic.go @@ -5,11 +5,12 @@ package command import ( "context" + "strings" + jsoniter "github.com/json-iterator/go" elastic "github.com/olivere/elastic/v7" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/util" - "strings" ) type EsDocument struct { diff --git a/weed/command/filer_remote_gateway.go b/weed/command/filer_remote_gateway.go index 3e52e8d3f..2156c1655 100644 --- a/weed/command/filer_remote_gateway.go +++ b/weed/command/filer_remote_gateway.go @@ -3,6 +3,9 @@ package command import ( "context" "fmt" + "os" + "time" + "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" @@ -11,8 +14,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/security" "github.com/seaweedfs/seaweedfs/weed/util" "google.golang.org/grpc" - "os" - "time" ) type RemoteGatewayOptions struct { diff --git a/weed/command/filer_remote_gateway_buckets.go b/weed/command/filer_remote_gateway_buckets.go index 5c7e0ae21..53fb50da7 100644 --- a/weed/command/filer_remote_gateway_buckets.go +++ b/weed/command/filer_remote_gateway_buckets.go @@ -3,6 +3,12 @@ package command import ( "context" "fmt" + "math" + "math/rand" + "path/filepath" + "strings" + "time" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb" @@ -12,11 +18,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/replication/source" "github.com/seaweedfs/seaweedfs/weed/util" "google.golang.org/protobuf/proto" - "math" - "math/rand" - "path/filepath" - "strings" - "time" ) func (option *RemoteGatewayOptions) followBucketUpdatesAndUploadToRemote(filerSource *source.FilerSource) error { diff --git a/weed/command/filer_remote_sync.go b/weed/command/filer_remote_sync.go index 77dd95134..9e96f6d06 100644 --- a/weed/command/filer_remote_sync.go +++ b/weed/command/filer_remote_sync.go @@ -2,6 +2,8 @@ package command import ( "fmt" + "time" + "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" @@ -9,7 +11,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/security" "github.com/seaweedfs/seaweedfs/weed/util" "google.golang.org/grpc" - "time" ) type RemoteSyncOptions struct { diff --git a/weed/command/filer_sync_jobs.go b/weed/command/filer_sync_jobs.go index d49031b98..1c75eb0e1 100644 --- a/weed/command/filer_sync_jobs.go +++ b/weed/command/filer_sync_jobs.go @@ -1,12 +1,13 @@ package command import ( + "sync" + "sync/atomic" + "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/util" - "sync" - "sync/atomic" ) type MetadataProcessor struct { diff --git a/weed/command/mini.go b/weed/command/mini.go index f246a9d88..815eba72a 100644 --- a/weed/command/mini.go +++ b/weed/command/mini.go @@ -1105,7 +1105,6 @@ func startMiniWorker() { glog.Infof("Maintenance worker %s started successfully", workerInstance.ID()) } - const credentialsInstructionTemplate = ` To create S3 credentials, you have two options: @@ -1166,10 +1165,10 @@ func printWelcomeMessage() { fmt.Fprintf(&sb, credentialsInstructionTemplate, *miniIp, *miniAdminOptions.port) } else { sb.WriteString("\n To create S3 credentials, use environment variables:\n\n") - sb.WriteString(" export AWS_ACCESS_KEY_ID=your-access-key\\n") - sb.WriteString(" export AWS_SECRET_ACCESS_KEY=your-secret-key\\n") - sb.WriteString(" weed mini -dir=/data\\n") - sb.WriteString(" This will create initial credentials for the 'mini' user.\\n") + sb.WriteString(" export AWS_ACCESS_KEY_ID=your-access-key\\n") + sb.WriteString(" export AWS_SECRET_ACCESS_KEY=your-secret-key\\n") + sb.WriteString(" weed mini -dir=/data\\n") + sb.WriteString(" This will create initial credentials for the 'mini' user.\\n") } fmt.Print(sb.String()) diff --git a/weed/command/mount_linux.go b/weed/command/mount_linux.go index 1d1727519..2d5f11c26 100644 --- a/weed/command/mount_linux.go +++ b/weed/command/mount_linux.go @@ -3,10 +3,11 @@ package command import ( "bufio" "fmt" - "github.com/seaweedfs/seaweedfs/weed/glog" "io" "os" "strings" + + "github.com/seaweedfs/seaweedfs/weed/glog" ) const ( diff --git a/weed/command/sftp.go b/weed/command/sftp.go index 58cc5b14a..07b5b0076 100644 --- a/weed/command/sftp.go +++ b/weed/command/sftp.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "github.com/seaweedfs/seaweedfs/weed/util/version" "net" "os" "runtime" @@ -17,6 +16,7 @@ import ( stats_collect "github.com/seaweedfs/seaweedfs/weed/stats" "github.com/seaweedfs/seaweedfs/weed/util" "github.com/seaweedfs/seaweedfs/weed/util/grace" + "github.com/seaweedfs/seaweedfs/weed/util/version" ) var ( diff --git a/weed/command/shell.go b/weed/command/shell.go index 1e921411b..962fe26ee 100644 --- a/weed/command/shell.go +++ b/weed/command/shell.go @@ -2,6 +2,7 @@ package command import ( "fmt" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/security" diff --git a/weed/command/update.go b/weed/command/update.go index cc464dd28..57953c565 100644 --- a/weed/command/update.go +++ b/weed/command/update.go @@ -10,7 +10,6 @@ import ( "encoding/hex" "encoding/json" "fmt" - swv "github.com/seaweedfs/seaweedfs/weed/util/version" "io" "net/http" "os" @@ -22,6 +21,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/util" util_http "github.com/seaweedfs/seaweedfs/weed/util/http" + swv "github.com/seaweedfs/seaweedfs/weed/util/version" "golang.org/x/net/context/ctxhttp" ) diff --git a/weed/command/version.go b/weed/command/version.go index fdde081ad..d62607f0c 100644 --- a/weed/command/version.go +++ b/weed/command/version.go @@ -2,8 +2,9 @@ package command import ( "fmt" - "github.com/seaweedfs/seaweedfs/weed/util/version" "runtime" + + "github.com/seaweedfs/seaweedfs/weed/util/version" ) var cmdVersion = &Command{ diff --git a/weed/credential/filer_etc/filer_etc_identity.go b/weed/credential/filer_etc/filer_etc_identity.go index 71de39b4d..5648167e5 100644 --- a/weed/credential/filer_etc/filer_etc_identity.go +++ b/weed/credential/filer_etc/filer_etc_identity.go @@ -15,7 +15,7 @@ import ( func (store *FilerEtcStore) LoadConfiguration(ctx context.Context) (*iam_pb.S3ApiConfiguration, error) { s3cfg := &iam_pb.S3ApiConfiguration{} - glog.V(1).Infof("Loading IAM configuration from %s/%s (using current active filer)", + glog.V(1).Infof("Loading IAM configuration from %s/%s (using current active filer)", filer.IamConfigDirectory, filer.IamIdentityFile) err := store.withFilerClient(func(client filer_pb.SeaweedFilerClient) error { @@ -25,31 +25,31 @@ func (store *FilerEtcStore) LoadConfiguration(ctx context.Context) (*iam_pb.S3Ap content, err := filer.ReadInsideFiler(client, filer.IamConfigDirectory, filer.IamIdentityFile) if err != nil { if err == filer_pb.ErrNotFound { - glog.V(1).Infof("IAM identity file not found at %s/%s, no credentials loaded", + glog.V(1).Infof("IAM identity file not found at %s/%s, no credentials loaded", filer.IamConfigDirectory, filer.IamIdentityFile) return nil } - glog.Errorf("Failed to read IAM identity file from %s/%s: %v", + glog.Errorf("Failed to read IAM identity file from %s/%s: %v", filer.IamConfigDirectory, filer.IamIdentityFile, err) return err } - + if len(content) == 0 { - glog.V(1).Infof("IAM identity file at %s/%s is empty", + glog.V(1).Infof("IAM identity file at %s/%s is empty", filer.IamConfigDirectory, filer.IamIdentityFile) return nil } - - glog.V(2).Infof("Read %d bytes from %s/%s", + + glog.V(2).Infof("Read %d bytes from %s/%s", len(content), filer.IamConfigDirectory, filer.IamIdentityFile) - + if err := filer.ParseS3ConfigurationFromBytes(content, s3cfg); err != nil { - glog.Errorf("Failed to parse IAM configuration from %s/%s: %v", + glog.Errorf("Failed to parse IAM configuration from %s/%s: %v", filer.IamConfigDirectory, filer.IamIdentityFile, err) return err } - - glog.V(1).Infof("Successfully parsed IAM configuration with %d identities and %d accounts", + + glog.V(1).Infof("Successfully parsed IAM configuration with %d identities and %d accounts", len(s3cfg.Identities), len(s3cfg.Accounts)) return nil }) @@ -63,7 +63,7 @@ func (store *FilerEtcStore) LoadConfiguration(ctx context.Context) (*iam_pb.S3Ap for _, identity := range s3cfg.Identities { credCount := len(identity.Credentials) actionCount := len(identity.Actions) - glog.V(2).Infof(" Identity: %s (credentials: %d, actions: %d)", + glog.V(2).Infof(" Identity: %s (credentials: %d, actions: %d)", identity.Name, credCount, actionCount) for _, cred := range identity.Credentials { glog.V(3).Infof(" Access Key: %s", cred.AccessKey) diff --git a/weed/credential/filer_etc/filer_etc_policy.go b/weed/credential/filer_etc/filer_etc_policy.go index 99931bae8..96ef0cca7 100644 --- a/weed/credential/filer_etc/filer_etc_policy.go +++ b/weed/credential/filer_etc/filer_etc_policy.go @@ -24,14 +24,14 @@ func (store *FilerEtcStore) GetPolicies(ctx context.Context) (map[string]policy_ store.mu.RLock() configured := store.filerAddressFunc != nil store.mu.RUnlock() - + if !configured { glog.V(1).Infof("Filer client not configured for policy retrieval, returning empty policies") // Return empty policies if filer client is not configured return policiesCollection.Policies, nil } - glog.V(2).Infof("Loading IAM policies from %s/%s (using current active filer)", + glog.V(2).Infof("Loading IAM policies from %s/%s (using current active filer)", filer.IamConfigDirectory, filer.IamPoliciesFile) err := store.withFilerClient(func(client filer_pb.SeaweedFilerClient) error { @@ -41,27 +41,27 @@ func (store *FilerEtcStore) GetPolicies(ctx context.Context) (map[string]policy_ content, err := filer.ReadInsideFiler(client, filer.IamConfigDirectory, filer.IamPoliciesFile) if err != nil { if err == filer_pb.ErrNotFound { - glog.V(1).Infof("Policies file not found at %s/%s, returning empty policies", + glog.V(1).Infof("Policies file not found at %s/%s, returning empty policies", filer.IamConfigDirectory, filer.IamPoliciesFile) // If file doesn't exist, return empty collection return nil } - glog.Errorf("Failed to read IAM policies file from %s/%s: %v", + glog.Errorf("Failed to read IAM policies file from %s/%s: %v", filer.IamConfigDirectory, filer.IamPoliciesFile, err) return err } if len(content) == 0 { - glog.V(2).Infof("IAM policies file at %s/%s is empty", + glog.V(2).Infof("IAM policies file at %s/%s is empty", filer.IamConfigDirectory, filer.IamPoliciesFile) return nil } - glog.V(2).Infof("Read %d bytes from %s/%s", + glog.V(2).Infof("Read %d bytes from %s/%s", len(content), filer.IamConfigDirectory, filer.IamPoliciesFile) if err := json.Unmarshal(content, policiesCollection); err != nil { - glog.Errorf("Failed to parse IAM policies from %s/%s: %v", + glog.Errorf("Failed to parse IAM policies from %s/%s: %v", filer.IamConfigDirectory, filer.IamPoliciesFile, err) return err } diff --git a/weed/credential/filer_etc/filer_etc_store.go b/weed/credential/filer_etc/filer_etc_store.go index e174b5ef4..a9f7cc1e7 100644 --- a/weed/credential/filer_etc/filer_etc_store.go +++ b/weed/credential/filer_etc/filer_etc_store.go @@ -64,7 +64,7 @@ func (store *FilerEtcStore) withFilerClient(fn func(client filer_pb.SeaweedFiler filerAddress := store.filerAddressFunc() dialOption := store.grpcDialOption store.mu.RUnlock() - + if filerAddress == "" { return fmt.Errorf("filer_etc: no filer discovered yet - please ensure a filer is running and accessible") } diff --git a/weed/filer/abstract_sql/abstract_sql_store_kv.go b/weed/filer/abstract_sql/abstract_sql_store_kv.go index ad9e6ab41..41a7196a9 100644 --- a/weed/filer/abstract_sql/abstract_sql_store_kv.go +++ b/weed/filer/abstract_sql/abstract_sql_store_kv.go @@ -5,10 +5,11 @@ import ( "database/sql" "encoding/base64" "fmt" + "strings" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/util" - "strings" ) func (store *AbstractSqlStore) KvPut(ctx context.Context, key []byte, value []byte) (err error) { diff --git a/weed/filer/arangodb/arangodb_store_bucket.go b/weed/filer/arangodb/arangodb_store_bucket.go index 44aeeadea..b3a4e71d0 100644 --- a/weed/filer/arangodb/arangodb_store_bucket.go +++ b/weed/filer/arangodb/arangodb_store_bucket.go @@ -2,11 +2,10 @@ package arangodb import ( "context" - "github.com/arangodb/go-driver" "time" + "github.com/arangodb/go-driver" "github.com/seaweedfs/seaweedfs/weed/filer" - "github.com/seaweedfs/seaweedfs/weed/glog" ) diff --git a/weed/filer/cassandra/cassandra_store_kv.go b/weed/filer/cassandra/cassandra_store_kv.go index eea59ffbd..49dc542de 100644 --- a/weed/filer/cassandra/cassandra_store_kv.go +++ b/weed/filer/cassandra/cassandra_store_kv.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "fmt" + "github.com/gocql/gocql" "github.com/seaweedfs/seaweedfs/weed/filer" ) diff --git a/weed/filer/cassandra2/cassandra_store_kv.go b/weed/filer/cassandra2/cassandra_store_kv.go index e11193b8b..3c1db7a45 100644 --- a/weed/filer/cassandra2/cassandra_store_kv.go +++ b/weed/filer/cassandra2/cassandra_store_kv.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "fmt" + "github.com/gocql/gocql" "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/util" diff --git a/weed/filer/configuration.go b/weed/filer/configuration.go index db4af1559..550fcb434 100644 --- a/weed/filer/configuration.go +++ b/weed/filer/configuration.go @@ -1,11 +1,12 @@ package filer import ( - "github.com/seaweedfs/seaweedfs/weed/glog" - "github.com/seaweedfs/seaweedfs/weed/util" "os" "reflect" "strings" + + "github.com/seaweedfs/seaweedfs/weed/glog" + "github.com/seaweedfs/seaweedfs/weed/util" ) var ( diff --git a/weed/filer/empty_folder_cleanup/cleanup_queue.go b/weed/filer/empty_folder_cleanup/cleanup_queue.go index aabcaeaf9..b2f66a835 100644 --- a/weed/filer/empty_folder_cleanup/cleanup_queue.go +++ b/weed/filer/empty_folder_cleanup/cleanup_queue.go @@ -203,6 +203,3 @@ func (q *CleanupQueue) OldestAge() time.Duration { item := front.Value.(*queueItem) return time.Since(item.queueTime) } - - - diff --git a/weed/filer/empty_folder_cleanup/cleanup_queue_test.go b/weed/filer/empty_folder_cleanup/cleanup_queue_test.go index 1295fa0d4..0e26495dd 100644 --- a/weed/filer/empty_folder_cleanup/cleanup_queue_test.go +++ b/weed/filer/empty_folder_cleanup/cleanup_queue_test.go @@ -367,6 +367,3 @@ func TestCleanupQueue_Concurrent(t *testing.T) { // Just verify no panic occurred and queue is in consistent state _ = q.Len() } - - - diff --git a/weed/filer/empty_folder_cleanup/empty_folder_cleaner.go b/weed/filer/empty_folder_cleanup/empty_folder_cleaner.go index 70856aaf1..f7d7b8864 100644 --- a/weed/filer/empty_folder_cleanup/empty_folder_cleaner.go +++ b/weed/filer/empty_folder_cleanup/empty_folder_cleaner.go @@ -433,4 +433,3 @@ func (efc *EmptyFolderCleaner) GetCachedFolderCount(folder string) (int, bool) { } return 0, false } - diff --git a/weed/filer/empty_folder_cleanup/empty_folder_cleaner_test.go b/weed/filer/empty_folder_cleanup/empty_folder_cleaner_test.go index fbc05ccf8..1c62a5dd1 100644 --- a/weed/filer/empty_folder_cleanup/empty_folder_cleaner_test.go +++ b/weed/filer/empty_folder_cleanup/empty_folder_cleaner_test.go @@ -566,4 +566,3 @@ func TestEmptyFolderCleaner_queueFIFOOrder(t *testing.T) { cleaner.Stop() } - diff --git a/weed/filer/entry.go b/weed/filer/entry.go index 25fc26feb..237ddc964 100644 --- a/weed/filer/entry.go +++ b/weed/filer/entry.go @@ -1,11 +1,11 @@ package filer import ( - "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "os" "time" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "github.com/seaweedfs/seaweedfs/weed/util" ) diff --git a/weed/filer/etcd/etcd_store_kv.go b/weed/filer/etcd/etcd_store_kv.go index e2536ba1c..8a9ed6854 100644 --- a/weed/filer/etcd/etcd_store_kv.go +++ b/weed/filer/etcd/etcd_store_kv.go @@ -3,6 +3,7 @@ package etcd import ( "context" "fmt" + "github.com/seaweedfs/seaweedfs/weed/filer" ) diff --git a/weed/filer/etcd/etcd_store_test.go b/weed/filer/etcd/etcd_store_test.go index 6abb74697..127e10cb0 100644 --- a/weed/filer/etcd/etcd_store_test.go +++ b/weed/filer/etcd/etcd_store_test.go @@ -1,8 +1,9 @@ package etcd import ( - "github.com/seaweedfs/seaweedfs/weed/filer/store_test" "testing" + + "github.com/seaweedfs/seaweedfs/weed/filer/store_test" ) func TestStore(t *testing.T) { diff --git a/weed/filer/filechunk_section_test.go b/weed/filer/filechunk_section_test.go index 7b76c8456..97ead8ead 100644 --- a/weed/filer/filechunk_section_test.go +++ b/weed/filer/filechunk_section_test.go @@ -1,8 +1,9 @@ package filer import ( - "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "testing" + + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" ) func Test_removeGarbageChunks(t *testing.T) { diff --git a/weed/filer/filechunks.go b/weed/filer/filechunks.go index 43261a970..8a82470c8 100644 --- a/weed/filer/filechunks.go +++ b/weed/filer/filechunks.go @@ -4,11 +4,11 @@ import ( "bytes" "context" "fmt" - "github.com/seaweedfs/seaweedfs/weed/wdclient" "math" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/util" + "github.com/seaweedfs/seaweedfs/weed/wdclient" ) func TotalSize(chunks []*filer_pb.FileChunk) (size uint64) { diff --git a/weed/filer/filechunks2_test.go b/weed/filer/filechunks2_test.go index b735b8a27..9c8a916e6 100644 --- a/weed/filer/filechunks2_test.go +++ b/weed/filer/filechunks2_test.go @@ -2,13 +2,13 @@ package filer import ( "context" - "github.com/stretchr/testify/assert" "log" "slices" "testing" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" + "github.com/stretchr/testify/assert" ) func TestDoMinusChunks(t *testing.T) { diff --git a/weed/filer/filechunks_read.go b/weed/filer/filechunks_read.go index 756e18b34..59a00e6ff 100644 --- a/weed/filer/filechunks_read.go +++ b/weed/filer/filechunks_read.go @@ -2,8 +2,9 @@ package filer import ( "container/list" - "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "slices" + + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" ) func readResolvedChunks(chunks []*filer_pb.FileChunk, startOffset int64, stopOffset int64) (visibles *IntervalList[*VisibleInterval]) { diff --git a/weed/filer/filechunks_read_test.go b/weed/filer/filechunks_read_test.go index c66a874bc..5bfd34cfd 100644 --- a/weed/filer/filechunks_read_test.go +++ b/weed/filer/filechunks_read_test.go @@ -2,10 +2,11 @@ package filer import ( "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "math" "math/rand" "testing" + + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" ) func TestReadResolvedChunks(t *testing.T) { diff --git a/weed/filer/filerstore_wrapper.go b/weed/filer/filerstore_wrapper.go index 5114955c7..485f3c9ea 100644 --- a/weed/filer/filerstore_wrapper.go +++ b/weed/filer/filerstore_wrapper.go @@ -32,9 +32,9 @@ type VirtualFilerStore interface { } type FilerStoreWrapper struct { - defaultStore FilerStore - pathToStore ptrie.Trie[string] - storeIdToStore map[string]FilerStore + defaultStore FilerStore + pathToStore ptrie.Trie[string] + storeIdToStore map[string]FilerStore hasPathSpecificStore bool // fast check to skip MatchPrefix when no path-specific stores } diff --git a/weed/filer/hbase/hbase_store_kv.go b/weed/filer/hbase/hbase_store_kv.go index 0939b8752..e270a1a04 100644 --- a/weed/filer/hbase/hbase_store_kv.go +++ b/weed/filer/hbase/hbase_store_kv.go @@ -2,9 +2,10 @@ package hbase import ( "context" + "time" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/tsuna/gohbase/hrpc" - "time" ) const ( diff --git a/weed/filer/interval_list_test.go b/weed/filer/interval_list_test.go index dea510fed..304222c01 100644 --- a/weed/filer/interval_list_test.go +++ b/weed/filer/interval_list_test.go @@ -2,8 +2,9 @@ package filer import ( "fmt" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) type IntervalInt int diff --git a/weed/filer/leveldb/leveldb_store_kv.go b/weed/filer/leveldb/leveldb_store_kv.go index c961b5e91..de189607d 100644 --- a/weed/filer/leveldb/leveldb_store_kv.go +++ b/weed/filer/leveldb/leveldb_store_kv.go @@ -3,6 +3,7 @@ package leveldb import ( "context" "fmt" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/syndtr/goleveldb/leveldb" ) diff --git a/weed/filer/leveldb/leveldb_store_test.go b/weed/filer/leveldb/leveldb_store_test.go index 5676b1617..a491d969b 100644 --- a/weed/filer/leveldb/leveldb_store_test.go +++ b/weed/filer/leveldb/leveldb_store_test.go @@ -3,12 +3,12 @@ package leveldb import ( "context" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb" "os" "testing" "time" "github.com/seaweedfs/seaweedfs/weed/filer" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/util" ) diff --git a/weed/filer/leveldb2/leveldb2_store_test.go b/weed/filer/leveldb2/leveldb2_store_test.go index 34dc762da..6f6667422 100644 --- a/weed/filer/leveldb2/leveldb2_store_test.go +++ b/weed/filer/leveldb2/leveldb2_store_test.go @@ -2,10 +2,10 @@ package leveldb import ( "context" - "github.com/seaweedfs/seaweedfs/weed/pb" "testing" "github.com/seaweedfs/seaweedfs/weed/filer" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/util" ) diff --git a/weed/filer/leveldb3/leveldb3_store_bucket.go b/weed/filer/leveldb3/leveldb3_store_bucket.go index 8cd3732ae..feb2a4b04 100644 --- a/weed/filer/leveldb3/leveldb3_store_bucket.go +++ b/weed/filer/leveldb3/leveldb3_store_bucket.go @@ -1,8 +1,9 @@ package leveldb import ( - "github.com/seaweedfs/seaweedfs/weed/filer" "os" + + "github.com/seaweedfs/seaweedfs/weed/filer" ) var _ filer.BucketAware = (*LevelDB3Store)(nil) diff --git a/weed/filer/leveldb3/leveldb3_store_test.go b/weed/filer/leveldb3/leveldb3_store_test.go index 6056e0955..aea6edd04 100644 --- a/weed/filer/leveldb3/leveldb3_store_test.go +++ b/weed/filer/leveldb3/leveldb3_store_test.go @@ -2,10 +2,10 @@ package leveldb import ( "context" - "github.com/seaweedfs/seaweedfs/weed/pb" "testing" "github.com/seaweedfs/seaweedfs/weed/filer" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/util" ) diff --git a/weed/filer/mysql/mysql_store.go b/weed/filer/mysql/mysql_store.go index 9dbe09069..a37d4dbd3 100644 --- a/weed/filer/mysql/mysql_store.go +++ b/weed/filer/mysql/mysql_store.go @@ -5,14 +5,13 @@ import ( "crypto/x509" "database/sql" "fmt" - "github.com/go-sql-driver/mysql" "os" "strings" "time" - "github.com/seaweedfs/seaweedfs/weed/filer" - + "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/filer/abstract_sql" "github.com/seaweedfs/seaweedfs/weed/util" ) diff --git a/weed/filer/read_remote.go b/weed/filer/read_remote.go index bac0e5e82..474681049 100644 --- a/weed/filer/read_remote.go +++ b/weed/filer/read_remote.go @@ -2,6 +2,7 @@ package filer import ( "context" + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/util" diff --git a/weed/filer/reader_cache_test.go b/weed/filer/reader_cache_test.go index 0480de8a7..3d04b73c7 100644 --- a/weed/filer/reader_cache_test.go +++ b/weed/filer/reader_cache_test.go @@ -311,7 +311,7 @@ func TestSingleChunkCacherDoneSignal(t *testing.T) { // TestSingleChunkCacherLookupError tests handling of lookup errors func TestSingleChunkCacherLookupError(t *testing.T) { cache := newMockChunkCacheForReaderCache() - + // Lookup function that returns an error lookupFn := func(ctx context.Context, fileId string) ([]string, error) { return nil, fmt.Errorf("lookup failed for %s", fileId) @@ -322,7 +322,7 @@ func TestSingleChunkCacherLookupError(t *testing.T) { buffer := make([]byte, 100) _, err := rc.ReadChunkAt(context.Background(), buffer, "error-test", nil, false, 0, 100, true) - + if err == nil { t.Error("Expected an error, got nil") } diff --git a/weed/filer/redis2/redis_sentinel_store.go b/weed/filer/redis2/redis_sentinel_store.go index dc15285bd..10ed62273 100644 --- a/weed/filer/redis2/redis_sentinel_store.go +++ b/weed/filer/redis2/redis_sentinel_store.go @@ -1,10 +1,11 @@ package redis2 import ( + "time" + "github.com/redis/go-redis/v9" "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/util" - "time" ) func init() { diff --git a/weed/filer/redis3/kv_directory_children_test.go b/weed/filer/redis3/kv_directory_children_test.go index 76a8dc00f..3a42487db 100644 --- a/weed/filer/redis3/kv_directory_children_test.go +++ b/weed/filer/redis3/kv_directory_children_test.go @@ -3,11 +3,12 @@ package redis3 import ( "context" "fmt" - "github.com/redis/go-redis/v9" - "github.com/stvp/tempredis" "strconv" "testing" "time" + + "github.com/redis/go-redis/v9" + "github.com/stvp/tempredis" ) var names = []string{ diff --git a/weed/filer/redis3/skiplist_element_store.go b/weed/filer/redis3/skiplist_element_store.go index 46506187e..834e18718 100644 --- a/weed/filer/redis3/skiplist_element_store.go +++ b/weed/filer/redis3/skiplist_element_store.go @@ -3,6 +3,7 @@ package redis3 import ( "context" "fmt" + "github.com/redis/go-redis/v9" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/util/skiplist" diff --git a/weed/filer/redis_lua/redis_sentinel_store.go b/weed/filer/redis_lua/redis_sentinel_store.go index 12a582ac3..6dd85dd06 100644 --- a/weed/filer/redis_lua/redis_sentinel_store.go +++ b/weed/filer/redis_lua/redis_sentinel_store.go @@ -1,10 +1,11 @@ package redis_lua import ( + "time" + "github.com/redis/go-redis/v9" "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/util" - "time" ) func init() { diff --git a/weed/filer/redis_lua/stored_procedure/init.go b/weed/filer/redis_lua/stored_procedure/init.go index 9373cc5a3..685ea364d 100644 --- a/weed/filer/redis_lua/stored_procedure/init.go +++ b/weed/filer/redis_lua/stored_procedure/init.go @@ -2,6 +2,7 @@ package stored_procedure import ( _ "embed" + "github.com/redis/go-redis/v9" ) diff --git a/weed/filer/remote_mapping.go b/weed/filer/remote_mapping.go index cc48d859e..194411d54 100644 --- a/weed/filer/remote_mapping.go +++ b/weed/filer/remote_mapping.go @@ -2,6 +2,7 @@ package filer import ( "fmt" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" diff --git a/weed/filer/remote_storage.go b/weed/filer/remote_storage.go index 3764fbac6..e52cc3ff3 100644 --- a/weed/filer/remote_storage.go +++ b/weed/filer/remote_storage.go @@ -3,14 +3,15 @@ package filer import ( "context" "fmt" + "math" + "strings" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" "google.golang.org/grpc" "google.golang.org/protobuf/proto" - "math" - "strings" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" diff --git a/weed/filer/remote_storage_test.go b/weed/filer/remote_storage_test.go index b3785db85..57c08634d 100644 --- a/weed/filer/remote_storage_test.go +++ b/weed/filer/remote_storage_test.go @@ -1,9 +1,10 @@ package filer import ( + "testing" + "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/stretchr/testify/assert" - "testing" ) func TestFilerRemoteStorage_FindRemoteStorageClient(t *testing.T) { diff --git a/weed/filer/ydb/ydb_store_kv.go b/weed/filer/ydb/ydb_store_kv.go index 070f17e23..decec14ea 100644 --- a/weed/filer/ydb/ydb_store_kv.go +++ b/weed/filer/ydb/ydb_store_kv.go @@ -6,6 +6,7 @@ package ydb import ( "context" "fmt" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/filer/abstract_sql" "github.com/seaweedfs/seaweedfs/weed/util" diff --git a/weed/filer/ydb/ydb_store_test.go b/weed/filer/ydb/ydb_store_test.go index 1deef465c..14ff769e9 100644 --- a/weed/filer/ydb/ydb_store_test.go +++ b/weed/filer/ydb/ydb_store_test.go @@ -4,8 +4,9 @@ package ydb import ( - "github.com/seaweedfs/seaweedfs/weed/filer/store_test" "testing" + + "github.com/seaweedfs/seaweedfs/weed/filer/store_test" ) func TestStore(t *testing.T) { diff --git a/weed/filer/ydb/ydb_types.go b/weed/filer/ydb/ydb_types.go index 05e0b7173..af6ceec05 100644 --- a/weed/filer/ydb/ydb_types.go +++ b/weed/filer/ydb/ydb_types.go @@ -5,6 +5,7 @@ package ydb import ( "fmt" + "github.com/ydb-platform/ydb-go-sdk/v3/table" "github.com/ydb-platform/ydb-go-sdk/v3/table/options" "github.com/ydb-platform/ydb-go-sdk/v3/table/types" diff --git a/weed/glog/glog_file.go b/weed/glog/glog_file.go index 631a4cc99..eef89802a 100644 --- a/weed/glog/glog_file.go +++ b/weed/glog/glog_file.go @@ -21,7 +21,6 @@ package glog import ( "errors" "fmt" - flag "github.com/seaweedfs/seaweedfs/weed/util/fla9" "os" "os/user" "path/filepath" @@ -29,6 +28,8 @@ import ( "strings" "sync" "time" + + flag "github.com/seaweedfs/seaweedfs/weed/util/fla9" ) // MaxSize is the maximum size of a log file in bytes. diff --git a/weed/iam/sts/constants.go b/weed/iam/sts/constants.go index b54951903..021aca906 100644 --- a/weed/iam/sts/constants.go +++ b/weed/iam/sts/constants.go @@ -42,16 +42,16 @@ const ( // Configuration Field Names const ( - ConfigFieldFilerAddress = "filerAddress" - ConfigFieldBasePath = "basePath" - ConfigFieldIssuer = "issuer" - ConfigFieldClientID = "clientId" - ConfigFieldClientSecret = "clientSecret" - ConfigFieldJWKSUri = "jwksUri" - ConfigFieldScopes = "scopes" - ConfigFieldUserInfoUri = "userInfoUri" - ConfigFieldRedirectUri = "redirectUri" - ConfigFieldTLSCACert = "tlsCaCert" + ConfigFieldFilerAddress = "filerAddress" + ConfigFieldBasePath = "basePath" + ConfigFieldIssuer = "issuer" + ConfigFieldClientID = "clientId" + ConfigFieldClientSecret = "clientSecret" + ConfigFieldJWKSUri = "jwksUri" + ConfigFieldScopes = "scopes" + ConfigFieldUserInfoUri = "userInfoUri" + ConfigFieldRedirectUri = "redirectUri" + ConfigFieldTLSCACert = "tlsCaCert" ConfigFieldTLSInsecureSkipVerify = "tlsInsecureSkipVerify" ) diff --git a/weed/iam/sts/sts_service_test.go b/weed/iam/sts/sts_service_test.go index 56b6755de..7ab58c189 100644 --- a/weed/iam/sts/sts_service_test.go +++ b/weed/iam/sts/sts_service_test.go @@ -457,7 +457,7 @@ func TestSessionDurationCappedByTokenExpiration(t *testing.T) { service := NewSTSService() config := &STSConfig{ - TokenDuration: FlexibleDuration{time.Hour}, // Default: 1 hour + TokenDuration: FlexibleDuration{time.Hour}, // Default: 1 hour MaxSessionLength: FlexibleDuration{time.Hour * 12}, Issuer: "test-sts", SigningKey: []byte("test-signing-key-32-characters-long"), diff --git a/weed/iam/utils/arn_utils_test.go b/weed/iam/utils/arn_utils_test.go index 7d0a8ce2d..662297600 100644 --- a/weed/iam/utils/arn_utils_test.go +++ b/weed/iam/utils/arn_utils_test.go @@ -453,10 +453,10 @@ func TestSecurityMaliciousSTSUserARNs(t *testing.T) { // should be accepted as a valid role name "role/name". func TestEdgeCaseMultipleRoleMarkers(t *testing.T) { testCases := []struct { - name string - arn string - expected string - useSTS bool + name string + arn string + expected string + useSTS bool }{ { name: "legacy_format_role_in_path", diff --git a/weed/images/orientation_test.go b/weed/images/orientation_test.go index c90b85a44..fa4fdde15 100644 --- a/weed/images/orientation_test.go +++ b/weed/images/orientation_test.go @@ -1,9 +1,10 @@ package images import ( - "github.com/seaweedfs/seaweedfs/weed/util" "os" "testing" + + "github.com/seaweedfs/seaweedfs/weed/util" ) func TestXYZ(t *testing.T) { diff --git a/weed/images/resizing_test.go b/weed/images/resizing_test.go index 8e4bfaa25..352cf660c 100644 --- a/weed/images/resizing_test.go +++ b/weed/images/resizing_test.go @@ -2,9 +2,10 @@ package images import ( "bytes" - "github.com/seaweedfs/seaweedfs/weed/util" "os" "testing" + + "github.com/seaweedfs/seaweedfs/weed/util" ) func TestResizing(t *testing.T) { diff --git a/weed/mount/inode_to_path_test.go b/weed/mount/inode_to_path_test.go index bbe9c4faa..63da42fee 100644 --- a/weed/mount/inode_to_path_test.go +++ b/weed/mount/inode_to_path_test.go @@ -1,8 +1,9 @@ package mount import ( - "github.com/seaweedfs/seaweedfs/weed/util" "testing" + + "github.com/seaweedfs/seaweedfs/weed/util" ) func TestInodeEntry_removeOnePath(t *testing.T) { diff --git a/weed/mount/locked_entry.go b/weed/mount/locked_entry.go index c5fbaee91..0ea1fbfc9 100644 --- a/weed/mount/locked_entry.go +++ b/weed/mount/locked_entry.go @@ -1,8 +1,9 @@ package mount import ( - "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "sync" + + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" ) type LockedEntry struct { diff --git a/weed/mount/meta_cache/meta_cache.go b/weed/mount/meta_cache/meta_cache.go index 45aff7aac..0b0794998 100644 --- a/weed/mount/meta_cache/meta_cache.go +++ b/weed/mount/meta_cache/meta_cache.go @@ -19,8 +19,8 @@ import ( // e.g. fill fileId field for chunks type MetaCache struct { - root util.FullPath - localStore filer.VirtualFilerStore + root util.FullPath + localStore filer.VirtualFilerStore leveldbStore *leveldb.LevelDBStore // direct reference for batch operations sync.RWMutex uidGidMapper *UidGidMapper diff --git a/weed/mount/meta_cache/meta_cache_subscribe.go b/weed/mount/meta_cache/meta_cache_subscribe.go index 9a4553013..fd4271c39 100644 --- a/weed/mount/meta_cache/meta_cache_subscribe.go +++ b/weed/mount/meta_cache/meta_cache_subscribe.go @@ -2,12 +2,13 @@ package meta_cache import ( "context" + "strings" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/util" - "strings" ) type MetadataFollower struct { diff --git a/weed/mount/page_writer/chunk_interval_list_test.go b/weed/mount/page_writer/chunk_interval_list_test.go index eb1d5ff46..802130d6f 100644 --- a/weed/mount/page_writer/chunk_interval_list_test.go +++ b/weed/mount/page_writer/chunk_interval_list_test.go @@ -1,8 +1,9 @@ package page_writer import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func Test_PageChunkWrittenIntervalList(t *testing.T) { diff --git a/weed/mount/weedfs_forget.go b/weed/mount/weedfs_forget.go index 0a45aba6b..8cfd47dac 100644 --- a/weed/mount/weedfs_forget.go +++ b/weed/mount/weedfs_forget.go @@ -2,6 +2,7 @@ package mount import ( "context" + "github.com/seaweedfs/seaweedfs/weed/util" ) diff --git a/weed/mount/weedfs_grpc_server.go b/weed/mount/weedfs_grpc_server.go index f867f2d80..a247edbea 100644 --- a/weed/mount/weedfs_grpc_server.go +++ b/weed/mount/weedfs_grpc_server.go @@ -3,6 +3,7 @@ package mount import ( "context" "fmt" + "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/mount_pb" ) diff --git a/weed/mount/weedfs_quota_test.go b/weed/mount/weedfs_quota_test.go index 47ae30341..9df747c95 100644 --- a/weed/mount/weedfs_quota_test.go +++ b/weed/mount/weedfs_quota_test.go @@ -215,4 +215,3 @@ func TestNoQuotaTrackingWhenDisabled(t *testing.T) { t.Errorf("Should not track uncommitted bytes when quota disabled: got %d", got) } } - diff --git a/weed/mount/weedfs_stats.go b/weed/mount/weedfs_stats.go index 3e8d9f3bd..a7975a619 100644 --- a/weed/mount/weedfs_stats.go +++ b/weed/mount/weedfs_stats.go @@ -3,11 +3,12 @@ package mount import ( "context" "fmt" + "math" + "time" + "github.com/seaweedfs/go-fuse/v2/fuse" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" - "math" - "time" ) const blockSize = 512 diff --git a/weed/mq/agent/agent_grpc_pub_session.go b/weed/mq/agent/agent_grpc_pub_session.go index 7cf857da1..e642e35bb 100644 --- a/weed/mq/agent/agent_grpc_pub_session.go +++ b/weed/mq/agent/agent_grpc_pub_session.go @@ -2,11 +2,12 @@ package agent import ( "context" + "log/slog" + "math/rand/v2" + "github.com/seaweedfs/seaweedfs/weed/mq/client/pub_client" "github.com/seaweedfs/seaweedfs/weed/mq/topic" "github.com/seaweedfs/seaweedfs/weed/pb/mq_agent_pb" - "log/slog" - "math/rand/v2" ) func (a *MessageQueueAgent) StartPublishSession(ctx context.Context, req *mq_agent_pb.StartPublishSessionRequest) (*mq_agent_pb.StartPublishSessionResponse, error) { diff --git a/weed/mq/agent/agent_grpc_publish.go b/weed/mq/agent/agent_grpc_publish.go index 0b666ff6d..5b776ad97 100644 --- a/weed/mq/agent/agent_grpc_publish.go +++ b/weed/mq/agent/agent_grpc_publish.go @@ -2,6 +2,7 @@ package agent import ( "fmt" + "github.com/seaweedfs/seaweedfs/weed/pb/mq_agent_pb" ) diff --git a/weed/mq/agent/agent_server.go b/weed/mq/agent/agent_server.go index f1d6ec679..97a80c435 100644 --- a/weed/mq/agent/agent_server.go +++ b/weed/mq/agent/agent_server.go @@ -1,12 +1,13 @@ package agent import ( + "sync" + "github.com/seaweedfs/seaweedfs/weed/mq/client/pub_client" "github.com/seaweedfs/seaweedfs/weed/mq/client/sub_client" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/mq_agent_pb" "google.golang.org/grpc" - "sync" ) type SessionId int64 diff --git a/weed/mq/broker/broker_grpc_admin.go b/weed/mq/broker/broker_grpc_admin.go index 3c9ef282c..f40a1d97d 100644 --- a/weed/mq/broker/broker_grpc_admin.go +++ b/weed/mq/broker/broker_grpc_admin.go @@ -2,6 +2,7 @@ package broker import ( "context" + "github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" diff --git a/weed/mq/broker/broker_grpc_balance.go b/weed/mq/broker/broker_grpc_balance.go index 54634c9d1..28baa228e 100644 --- a/weed/mq/broker/broker_grpc_balance.go +++ b/weed/mq/broker/broker_grpc_balance.go @@ -2,6 +2,7 @@ package broker import ( "context" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" ) diff --git a/weed/mq/broker/broker_grpc_topic_partition_control.go b/weed/mq/broker/broker_grpc_topic_partition_control.go index 66547b010..174a0a455 100644 --- a/weed/mq/broker/broker_grpc_topic_partition_control.go +++ b/weed/mq/broker/broker_grpc_topic_partition_control.go @@ -2,6 +2,7 @@ package broker import ( "context" + "github.com/seaweedfs/seaweedfs/weed/mq/topic" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" ) diff --git a/weed/mq/client/agent_client/publish_session.go b/weed/mq/client/agent_client/publish_session.go index 384f12f48..223de6c89 100644 --- a/weed/mq/client/agent_client/publish_session.go +++ b/weed/mq/client/agent_client/publish_session.go @@ -3,6 +3,7 @@ package agent_client import ( "context" "fmt" + "github.com/seaweedfs/seaweedfs/weed/mq/schema" "github.com/seaweedfs/seaweedfs/weed/pb/mq_agent_pb" "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" diff --git a/weed/mq/client/pub_client/publish.go b/weed/mq/client/pub_client/publish.go index 1988e9279..42aa68d1c 100644 --- a/weed/mq/client/pub_client/publish.go +++ b/weed/mq/client/pub_client/publish.go @@ -2,12 +2,13 @@ package pub_client import ( "fmt" + "time" + "github.com/golang/protobuf/proto" "github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" "github.com/seaweedfs/seaweedfs/weed/util" - "time" ) func (p *TopicPublisher) Publish(key, value []byte) error { diff --git a/weed/mq/client/pub_client/publisher.go b/weed/mq/client/pub_client/publisher.go index f95d00602..cad0f6bb9 100644 --- a/weed/mq/client/pub_client/publisher.go +++ b/weed/mq/client/pub_client/publisher.go @@ -1,6 +1,9 @@ package pub_client import ( + "log" + "sync" + "github.com/rdleal/intervalst/interval" "github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer" "github.com/seaweedfs/seaweedfs/weed/mq/topic" @@ -9,8 +12,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/util/buffered_queue" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "log" - "sync" ) type PublisherConfiguration struct { diff --git a/weed/mq/pub_balancer/allocate_test.go b/weed/mq/pub_balancer/allocate_test.go index fc747634e..c55f19736 100644 --- a/weed/mq/pub_balancer/allocate_test.go +++ b/weed/mq/pub_balancer/allocate_test.go @@ -2,11 +2,12 @@ package pub_balancer import ( "fmt" + "testing" + cmap "github.com/orcaman/concurrent-map/v2" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" "github.com/stretchr/testify/assert" - "testing" ) func Test_allocateOneBroker(t *testing.T) { diff --git a/weed/mq/pub_balancer/balance_action.go b/weed/mq/pub_balancer/balance_action.go index a2d888b2a..1c68991d1 100644 --- a/weed/mq/pub_balancer/balance_action.go +++ b/weed/mq/pub_balancer/balance_action.go @@ -3,6 +3,7 @@ package pub_balancer import ( "context" "fmt" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" "google.golang.org/grpc" diff --git a/weed/mq/pub_balancer/balance_brokers_test.go b/weed/mq/pub_balancer/balance_brokers_test.go index 58731c24c..174680478 100644 --- a/weed/mq/pub_balancer/balance_brokers_test.go +++ b/weed/mq/pub_balancer/balance_brokers_test.go @@ -1,10 +1,11 @@ package pub_balancer import ( - cmap "github.com/orcaman/concurrent-map/v2" - "github.com/seaweedfs/seaweedfs/weed/mq/topic" "reflect" "testing" + + cmap "github.com/orcaman/concurrent-map/v2" + "github.com/seaweedfs/seaweedfs/weed/mq/topic" ) func TestBalanceTopicPartitionOnBrokers(t *testing.T) { diff --git a/weed/mq/pub_balancer/broker_stats.go b/weed/mq/pub_balancer/broker_stats.go index da016b7fd..d6282b9d7 100644 --- a/weed/mq/pub_balancer/broker_stats.go +++ b/weed/mq/pub_balancer/broker_stats.go @@ -2,6 +2,7 @@ package pub_balancer import ( "fmt" + cmap "github.com/orcaman/concurrent-map/v2" "github.com/seaweedfs/seaweedfs/weed/mq/topic" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" diff --git a/weed/mq/pub_balancer/lookup.go b/weed/mq/pub_balancer/lookup.go index 5f9c7f32f..9bf271271 100644 --- a/weed/mq/pub_balancer/lookup.go +++ b/weed/mq/pub_balancer/lookup.go @@ -2,6 +2,7 @@ package pub_balancer import ( "errors" + "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" ) diff --git a/weed/mq/pub_balancer/repair_test.go b/weed/mq/pub_balancer/repair_test.go index 08465c7e8..4ccf59e13 100644 --- a/weed/mq/pub_balancer/repair_test.go +++ b/weed/mq/pub_balancer/repair_test.go @@ -1,9 +1,10 @@ package pub_balancer import ( - "github.com/seaweedfs/seaweedfs/weed/mq/topic" "reflect" "testing" + + "github.com/seaweedfs/seaweedfs/weed/mq/topic" ) func Test_findMissingPartitions(t *testing.T) { diff --git a/weed/mq/schema/schema_test.go b/weed/mq/schema/schema_test.go index f7dc8ff55..2d0068b22 100644 --- a/weed/mq/schema/schema_test.go +++ b/weed/mq/schema/schema_test.go @@ -2,10 +2,11 @@ package schema import ( "encoding/json" + "testing" + "github.com/golang/protobuf/proto" . "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" "github.com/stretchr/testify/assert" - "testing" ) func TestEnumScalarType(t *testing.T) { diff --git a/weed/mq/schema/struct_to_schema_test.go b/weed/mq/schema/struct_to_schema_test.go index fae27ecef..9f21b854c 100644 --- a/weed/mq/schema/struct_to_schema_test.go +++ b/weed/mq/schema/struct_to_schema_test.go @@ -1,9 +1,10 @@ package schema import ( + "testing" + "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" "github.com/stretchr/testify/assert" - "testing" ) func TestStructToSchema(t *testing.T) { diff --git a/weed/mq/schema/to_parquet_levels.go b/weed/mq/schema/to_parquet_levels.go index f9fc073bb..36e84f9c9 100644 --- a/weed/mq/schema/to_parquet_levels.go +++ b/weed/mq/schema/to_parquet_levels.go @@ -2,6 +2,7 @@ package schema import ( "fmt" + "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" ) diff --git a/weed/mq/schema/to_parquet_levels_test.go b/weed/mq/schema/to_parquet_levels_test.go index 5200c0e02..8e6eacbd9 100644 --- a/weed/mq/schema/to_parquet_levels_test.go +++ b/weed/mq/schema/to_parquet_levels_test.go @@ -1,9 +1,10 @@ package schema import ( + "testing" + "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" "github.com/stretchr/testify/assert" - "testing" ) func TestToParquetLevels(t *testing.T) { diff --git a/weed/mq/segment/message_serde_test.go b/weed/mq/segment/message_serde_test.go index a54ce5708..52c9d8e55 100644 --- a/weed/mq/segment/message_serde_test.go +++ b/weed/mq/segment/message_serde_test.go @@ -1,10 +1,11 @@ package segment import ( + "testing" + flatbuffers "github.com/google/flatbuffers/go" "github.com/seaweedfs/seaweedfs/weed/pb/message_fbs" "github.com/stretchr/testify/assert" - "testing" ) func TestMessageSerde(t *testing.T) { diff --git a/weed/mq/sub_coordinator/consumer_group.go b/weed/mq/sub_coordinator/consumer_group.go index ba94f34b4..538ae4041 100644 --- a/weed/mq/sub_coordinator/consumer_group.go +++ b/weed/mq/sub_coordinator/consumer_group.go @@ -2,13 +2,14 @@ package sub_coordinator import ( "fmt" + "time" + cmap "github.com/orcaman/concurrent-map/v2" "github.com/seaweedfs/seaweedfs/weed/filer_client" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/mq/topic" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" - "time" ) type ConsumerGroup struct { diff --git a/weed/mq/sub_coordinator/inflight_message_tracker_test.go b/weed/mq/sub_coordinator/inflight_message_tracker_test.go index 5b7a1bdd8..a5c63d561 100644 --- a/weed/mq/sub_coordinator/inflight_message_tracker_test.go +++ b/weed/mq/sub_coordinator/inflight_message_tracker_test.go @@ -1,8 +1,9 @@ package sub_coordinator import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestRingBuffer(t *testing.T) { diff --git a/weed/mq/sub_coordinator/market.go b/weed/mq/sub_coordinator/market.go index df07edfd5..1df4e0df4 100644 --- a/weed/mq/sub_coordinator/market.go +++ b/weed/mq/sub_coordinator/market.go @@ -2,10 +2,11 @@ package sub_coordinator import ( "errors" - "github.com/seaweedfs/seaweedfs/weed/glog" - "github.com/seaweedfs/seaweedfs/weed/mq/topic" "sync" "time" + + "github.com/seaweedfs/seaweedfs/weed/glog" + "github.com/seaweedfs/seaweedfs/weed/mq/topic" ) /* diff --git a/weed/mq/sub_coordinator/partition_consumer_mapping.go b/weed/mq/sub_coordinator/partition_consumer_mapping.go index e900e4a33..e4d00a0dd 100644 --- a/weed/mq/sub_coordinator/partition_consumer_mapping.go +++ b/weed/mq/sub_coordinator/partition_consumer_mapping.go @@ -2,8 +2,9 @@ package sub_coordinator import ( "fmt" - "github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer" "time" + + "github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer" ) type PartitionConsumerMapping struct { diff --git a/weed/mq/sub_coordinator/partition_consumer_mapping_test.go b/weed/mq/sub_coordinator/partition_consumer_mapping_test.go index 415eb27bd..ccc4e8601 100644 --- a/weed/mq/sub_coordinator/partition_consumer_mapping_test.go +++ b/weed/mq/sub_coordinator/partition_consumer_mapping_test.go @@ -1,9 +1,10 @@ package sub_coordinator import ( - "github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer" "reflect" "testing" + + "github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer" ) func Test_doBalanceSticky(t *testing.T) { diff --git a/weed/notification/gocdk_pub_sub/gocdk_pub_sub.go b/weed/notification/gocdk_pub_sub/gocdk_pub_sub.go index 131345f9c..1e7537918 100644 --- a/weed/notification/gocdk_pub_sub/gocdk_pub_sub.go +++ b/weed/notification/gocdk_pub_sub/gocdk_pub_sub.go @@ -20,24 +20,25 @@ package gocdk_pub_sub import ( "context" "fmt" - amqp "github.com/rabbitmq/amqp091-go" - "gocloud.dev/pubsub" - _ "gocloud.dev/pubsub/awssnssqs" - "gocloud.dev/pubsub/rabbitpubsub" - "google.golang.org/protobuf/proto" "net/url" + "os" "path" "sync" "time" + amqp "github.com/rabbitmq/amqp091-go" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/notification" "github.com/seaweedfs/seaweedfs/weed/util" + "gocloud.dev/pubsub" + _ "gocloud.dev/pubsub/awssnssqs" + "gocloud.dev/pubsub/rabbitpubsub" + "google.golang.org/protobuf/proto" + // _ "gocloud.dev/pubsub/azuresb" _ "gocloud.dev/pubsub/gcppubsub" _ "gocloud.dev/pubsub/natspubsub" _ "gocloud.dev/pubsub/rabbitpubsub" - "os" ) func init() { diff --git a/weed/operation/assign_file_id.go b/weed/operation/assign_file_id.go index 61fd2de48..2e429a8a1 100644 --- a/weed/operation/assign_file_id.go +++ b/weed/operation/assign_file_id.go @@ -3,13 +3,14 @@ package operation import ( "context" "fmt" + "sync" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "github.com/seaweedfs/seaweedfs/weed/security" "github.com/seaweedfs/seaweedfs/weed/stats" "github.com/seaweedfs/seaweedfs/weed/storage/needle" "google.golang.org/grpc" - "sync" ) type VolumeAssignRequest struct { diff --git a/weed/operation/assign_file_id_test.go b/weed/operation/assign_file_id_test.go index b2ec7d92a..ecfa7d6d0 100644 --- a/weed/operation/assign_file_id_test.go +++ b/weed/operation/assign_file_id_test.go @@ -3,10 +3,11 @@ package operation import ( "context" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb" - "google.golang.org/grpc" "testing" "time" + + "github.com/seaweedfs/seaweedfs/weed/pb" + "google.golang.org/grpc" ) func BenchmarkWithConcurrency(b *testing.B) { diff --git a/weed/operation/buffer_pool.go b/weed/operation/buffer_pool.go index 9cbe4787f..316ba4995 100644 --- a/weed/operation/buffer_pool.go +++ b/weed/operation/buffer_pool.go @@ -1,8 +1,9 @@ package operation import ( - "github.com/valyala/bytebufferpool" "sync/atomic" + + "github.com/valyala/bytebufferpool" ) var bufferCounter int64 diff --git a/weed/operation/submit.go b/weed/operation/submit.go index 1efa42b2f..4526a2c3a 100644 --- a/weed/operation/submit.go +++ b/weed/operation/submit.go @@ -2,7 +2,6 @@ package operation import ( "context" - "github.com/seaweedfs/seaweedfs/weed/pb" "io" "math/rand/v2" "mime" @@ -12,6 +11,8 @@ import ( "strconv" "strings" + "github.com/seaweedfs/seaweedfs/weed/pb" + "google.golang.org/grpc" "github.com/seaweedfs/seaweedfs/weed/glog" diff --git a/weed/operation/sync_volume.go b/weed/operation/sync_volume.go index cb091aed8..f1dde1b5a 100644 --- a/weed/operation/sync_volume.go +++ b/weed/operation/sync_volume.go @@ -2,6 +2,7 @@ package operation import ( "context" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" "google.golang.org/grpc" diff --git a/weed/pb/filer_pb/filer.pb.go b/weed/pb/filer_pb/filer.pb.go index 7e2cdedf3..279bd6d5d 100644 --- a/weed/pb/filer_pb/filer.pb.go +++ b/weed/pb/filer_pb/filer.pb.go @@ -7,11 +7,12 @@ package filer_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/weed/pb/filer_pb/filer_client_bfs.go b/weed/pb/filer_pb/filer_client_bfs.go index eb2e9ccee..a3b4e98c9 100644 --- a/weed/pb/filer_pb/filer_client_bfs.go +++ b/weed/pb/filer_pb/filer_client_bfs.go @@ -3,11 +3,12 @@ package filer_pb import ( "context" "fmt" - "github.com/seaweedfs/seaweedfs/weed/glog" "io" "sync" "time" + "github.com/seaweedfs/seaweedfs/weed/glog" + "github.com/seaweedfs/seaweedfs/weed/util" ) diff --git a/weed/pb/filer_pb/filer_grpc.pb.go b/weed/pb/filer_pb/filer_grpc.pb.go index e74a4c712..b34996773 100644 --- a/weed/pb/filer_pb/filer_grpc.pb.go +++ b/weed/pb/filer_pb/filer_grpc.pb.go @@ -8,6 +8,7 @@ package filer_pb import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/weed/pb/filer_pb_tail.go b/weed/pb/filer_pb_tail.go index d4e1e137e..d61f0abb8 100644 --- a/weed/pb/filer_pb_tail.go +++ b/weed/pb/filer_pb_tail.go @@ -3,12 +3,13 @@ package pb import ( "context" "fmt" + "io" + "time" + "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/util" "google.golang.org/grpc" - "io" - "time" ) type EventErrorType int diff --git a/weed/pb/iam_pb/iam.pb.go b/weed/pb/iam_pb/iam.pb.go index 4b0976410..367afc5ef 100644 --- a/weed/pb/iam_pb/iam.pb.go +++ b/weed/pb/iam_pb/iam.pb.go @@ -7,11 +7,12 @@ package iam_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/weed/pb/master_pb/master.pb.go b/weed/pb/master_pb/master.pb.go index fc2ceec4c..e8376011e 100644 --- a/weed/pb/master_pb/master.pb.go +++ b/weed/pb/master_pb/master.pb.go @@ -7,11 +7,12 @@ package master_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/weed/pb/master_pb/master_grpc.pb.go b/weed/pb/master_pb/master_grpc.pb.go index 441c2ffb1..719e8bb38 100644 --- a/weed/pb/master_pb/master_grpc.pb.go +++ b/weed/pb/master_pb/master_grpc.pb.go @@ -8,6 +8,7 @@ package master_pb import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/weed/pb/mount_pb/mount.pb.go b/weed/pb/mount_pb/mount.pb.go index 1299f6bec..f5420f567 100644 --- a/weed/pb/mount_pb/mount.pb.go +++ b/weed/pb/mount_pb/mount.pb.go @@ -7,11 +7,12 @@ package mount_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/weed/pb/mount_pb/mount_grpc.pb.go b/weed/pb/mount_pb/mount_grpc.pb.go index 6a1281326..b4a9d7e29 100644 --- a/weed/pb/mount_pb/mount_grpc.pb.go +++ b/weed/pb/mount_pb/mount_grpc.pb.go @@ -8,6 +8,7 @@ package mount_pb import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/weed/pb/mq_agent_pb/mq_agent.pb.go b/weed/pb/mq_agent_pb/mq_agent.pb.go index 155819280..3a89495cb 100644 --- a/weed/pb/mq_agent_pb/mq_agent.pb.go +++ b/weed/pb/mq_agent_pb/mq_agent.pb.go @@ -7,12 +7,13 @@ package mq_agent_pb import ( - schema_pb "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + schema_pb "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/weed/pb/mq_agent_pb/mq_agent_grpc.pb.go b/weed/pb/mq_agent_pb/mq_agent_grpc.pb.go index 62e323d13..7135ced0c 100644 --- a/weed/pb/mq_agent_pb/mq_agent_grpc.pb.go +++ b/weed/pb/mq_agent_pb/mq_agent_grpc.pb.go @@ -8,6 +8,7 @@ package mq_agent_pb import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/weed/pb/mq_agent_pb/publish_response_test.go b/weed/pb/mq_agent_pb/publish_response_test.go index 0c7b0ee3a..0a6827fc9 100644 --- a/weed/pb/mq_agent_pb/publish_response_test.go +++ b/weed/pb/mq_agent_pb/publish_response_test.go @@ -1,8 +1,9 @@ package mq_agent_pb import ( - "google.golang.org/protobuf/proto" "testing" + + "google.golang.org/protobuf/proto" ) func TestPublishRecordResponseSerialization(t *testing.T) { diff --git a/weed/pb/mq_pb/mq_broker.pb.go b/weed/pb/mq_pb/mq_broker.pb.go index 88affa163..58672cb98 100644 --- a/weed/pb/mq_pb/mq_broker.pb.go +++ b/weed/pb/mq_pb/mq_broker.pb.go @@ -7,13 +7,14 @@ package mq_pb import ( + reflect "reflect" + sync "sync" + unsafe "unsafe" + filer_pb "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" schema_pb "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" ) const ( diff --git a/weed/pb/mq_pb/mq_broker_grpc.pb.go b/weed/pb/mq_pb/mq_broker_grpc.pb.go index 1abefb75b..ea972974e 100644 --- a/weed/pb/mq_pb/mq_broker_grpc.pb.go +++ b/weed/pb/mq_pb/mq_broker_grpc.pb.go @@ -8,6 +8,7 @@ package mq_pb import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/weed/pb/remote_pb/remote.pb.go b/weed/pb/remote_pb/remote.pb.go index f7b3866c5..2c9e2389b 100644 --- a/weed/pb/remote_pb/remote.pb.go +++ b/weed/pb/remote_pb/remote.pb.go @@ -7,11 +7,12 @@ package remote_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/weed/pb/s3_pb/s3.pb.go b/weed/pb/s3_pb/s3.pb.go index 67d6ef11d..c44071594 100644 --- a/weed/pb/s3_pb/s3.pb.go +++ b/weed/pb/s3_pb/s3.pb.go @@ -7,11 +7,12 @@ package s3_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/weed/pb/s3_pb/s3_grpc.pb.go b/weed/pb/s3_pb/s3_grpc.pb.go index f5f43f54f..daef9cf30 100644 --- a/weed/pb/s3_pb/s3_grpc.pb.go +++ b/weed/pb/s3_pb/s3_grpc.pb.go @@ -8,6 +8,7 @@ package s3_pb import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/weed/pb/schema_pb/mq_schema.pb.go b/weed/pb/schema_pb/mq_schema.pb.go index 45d04c7bd..246615daf 100644 --- a/weed/pb/schema_pb/mq_schema.pb.go +++ b/weed/pb/schema_pb/mq_schema.pb.go @@ -7,11 +7,12 @@ package schema_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/weed/pb/schema_pb/offset_test.go b/weed/pb/schema_pb/offset_test.go index 273d2d5d1..69aeb812c 100644 --- a/weed/pb/schema_pb/offset_test.go +++ b/weed/pb/schema_pb/offset_test.go @@ -1,8 +1,9 @@ package schema_pb import ( - "google.golang.org/protobuf/proto" "testing" + + "google.golang.org/protobuf/proto" ) func TestOffsetTypeEnums(t *testing.T) { diff --git a/weed/pb/server_discovery.go b/weed/pb/server_discovery.go index 25c0360c5..59a333f0a 100644 --- a/weed/pb/server_discovery.go +++ b/weed/pb/server_discovery.go @@ -1,8 +1,9 @@ package pb import ( - "github.com/seaweedfs/seaweedfs/weed/glog" "reflect" + + "github.com/seaweedfs/seaweedfs/weed/glog" ) // ServerDiscovery encodes a way to find at least 1 instance of a service, diff --git a/weed/pb/volume_server_pb/volume_server.pb.go b/weed/pb/volume_server_pb/volume_server.pb.go index 7b174f8dd..cf0ad3ffb 100644 --- a/weed/pb/volume_server_pb/volume_server.pb.go +++ b/weed/pb/volume_server_pb/volume_server.pb.go @@ -7,12 +7,13 @@ package volume_server_pb import ( - remote_pb "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + remote_pb "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/weed/pb/volume_server_pb/volume_server_grpc.pb.go b/weed/pb/volume_server_pb/volume_server_grpc.pb.go index 02818ab38..690ee99fc 100644 --- a/weed/pb/volume_server_pb/volume_server_grpc.pb.go +++ b/weed/pb/volume_server_pb/volume_server_grpc.pb.go @@ -8,6 +8,7 @@ package volume_server_pb import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/weed/pb/worker_pb/worker.pb.go b/weed/pb/worker_pb/worker.pb.go index f0bd661c1..a24dd92b0 100644 --- a/weed/pb/worker_pb/worker.pb.go +++ b/weed/pb/worker_pb/worker.pb.go @@ -7,11 +7,12 @@ package worker_pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/weed/pb/worker_pb/worker_grpc.pb.go b/weed/pb/worker_pb/worker_grpc.pb.go index 0b0a9ad09..4894e7d25 100644 --- a/weed/pb/worker_pb/worker_grpc.pb.go +++ b/weed/pb/worker_pb/worker_grpc.pb.go @@ -8,6 +8,7 @@ package worker_pb import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/weed/remote_storage/remote_storage.go b/weed/remote_storage/remote_storage.go index 93b0b9d84..04d9520e6 100644 --- a/weed/remote_storage/remote_storage.go +++ b/weed/remote_storage/remote_storage.go @@ -2,14 +2,15 @@ package remote_storage import ( "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" - "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" - "google.golang.org/protobuf/proto" "io" "sort" "strings" "sync" "time" + + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" + "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" + "google.golang.org/protobuf/proto" ) const slash = "/" diff --git a/weed/remote_storage/s3/aliyun.go b/weed/remote_storage/s3/aliyun.go index 19a0ef4ae..667ef72a5 100644 --- a/weed/remote_storage/s3/aliyun.go +++ b/weed/remote_storage/s3/aliyun.go @@ -2,6 +2,8 @@ package s3 import ( "fmt" + "os" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" @@ -9,7 +11,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" - "os" ) func init() { diff --git a/weed/remote_storage/s3/backblaze.go b/weed/remote_storage/s3/backblaze.go index 0f42730c9..487826838 100644 --- a/weed/remote_storage/s3/backblaze.go +++ b/weed/remote_storage/s3/backblaze.go @@ -2,6 +2,7 @@ package s3 import ( "fmt" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" diff --git a/weed/remote_storage/s3/filebase.go b/weed/remote_storage/s3/filebase.go index ed8cfb409..6640e2a14 100644 --- a/weed/remote_storage/s3/filebase.go +++ b/weed/remote_storage/s3/filebase.go @@ -2,6 +2,8 @@ package s3 import ( "fmt" + "os" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" @@ -10,7 +12,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" - "os" ) func init() { diff --git a/weed/remote_storage/s3/s3_storage_client.go b/weed/remote_storage/s3/s3_storage_client.go index 280a856b0..9bf114b11 100644 --- a/weed/remote_storage/s3/s3_storage_client.go +++ b/weed/remote_storage/s3/s3_storage_client.go @@ -2,7 +2,6 @@ package s3 import ( "fmt" - "github.com/seaweedfs/seaweedfs/weed/util/version" "io" "reflect" @@ -19,6 +18,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" + "github.com/seaweedfs/seaweedfs/weed/util/version" ) func init() { diff --git a/weed/remote_storage/s3/storj.go b/weed/remote_storage/s3/storj.go index dd2fead56..c58ebf7c6 100644 --- a/weed/remote_storage/s3/storj.go +++ b/weed/remote_storage/s3/storj.go @@ -2,6 +2,8 @@ package s3 import ( "fmt" + "os" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" @@ -9,7 +11,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" - "os" ) func init() { diff --git a/weed/remote_storage/s3/tencent.go b/weed/remote_storage/s3/tencent.go index d010b03b9..c0da1fa05 100644 --- a/weed/remote_storage/s3/tencent.go +++ b/weed/remote_storage/s3/tencent.go @@ -2,6 +2,8 @@ package s3 import ( "fmt" + "os" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" @@ -9,7 +11,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" - "os" ) func init() { diff --git a/weed/remote_storage/s3/wasabi.go b/weed/remote_storage/s3/wasabi.go index 8d330a29f..08e5c951b 100644 --- a/weed/remote_storage/s3/wasabi.go +++ b/weed/remote_storage/s3/wasabi.go @@ -2,6 +2,7 @@ package s3 import ( "fmt" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/request" diff --git a/weed/remote_storage/track_sync_offset.go b/weed/remote_storage/track_sync_offset.go index 38cb7bd24..f5de002d0 100644 --- a/weed/remote_storage/track_sync_offset.go +++ b/weed/remote_storage/track_sync_offset.go @@ -3,6 +3,7 @@ package remote_storage import ( "context" "errors" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/util" diff --git a/weed/replication/replicator.go b/weed/replication/replicator.go index 654725725..5ea7c3a2c 100644 --- a/weed/replication/replicator.go +++ b/weed/replication/replicator.go @@ -3,16 +3,16 @@ package replication import ( "context" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb" - "google.golang.org/grpc" "strings" "time" "github.com/seaweedfs/seaweedfs/weed/glog" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/replication/sink" "github.com/seaweedfs/seaweedfs/weed/replication/source" "github.com/seaweedfs/seaweedfs/weed/util" + "google.golang.org/grpc" ) type Replicator struct { diff --git a/weed/replication/sink/b2sink/b2_sink.go b/weed/replication/sink/b2sink/b2_sink.go index 90f77f441..910465ead 100644 --- a/weed/replication/sink/b2sink/b2_sink.go +++ b/weed/replication/sink/b2sink/b2_sink.go @@ -2,12 +2,12 @@ package B2Sink import ( "context" - "github.com/seaweedfs/seaweedfs/weed/replication/repl_util" "strings" "github.com/kurin/blazer/b2" "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" + "github.com/seaweedfs/seaweedfs/weed/replication/repl_util" "github.com/seaweedfs/seaweedfs/weed/replication/sink" "github.com/seaweedfs/seaweedfs/weed/replication/source" "github.com/seaweedfs/seaweedfs/weed/util" diff --git a/weed/replication/sink/filersink/filer_sink.go b/weed/replication/sink/filersink/filer_sink.go index 8b4b0e513..74e2b3a5a 100644 --- a/weed/replication/sink/filersink/filer_sink.go +++ b/weed/replication/sink/filersink/filer_sink.go @@ -3,9 +3,10 @@ package filersink import ( "context" "fmt" + "math" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/wdclient" - "math" "google.golang.org/grpc" diff --git a/weed/replication/sink/localsink/local_sink.go b/weed/replication/sink/localsink/local_sink.go index 2e962d1d0..1bb3f2660 100644 --- a/weed/replication/sink/localsink/local_sink.go +++ b/weed/replication/sink/localsink/local_sink.go @@ -2,6 +2,10 @@ package localsink import ( "context" + "os" + "path/filepath" + "strings" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" @@ -10,9 +14,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/replication/source" "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "github.com/seaweedfs/seaweedfs/weed/util" - "os" - "path/filepath" - "strings" ) type LocalSink struct { diff --git a/weed/replication/sink/s3sink/s3_sink.go b/weed/replication/sink/s3sink/s3_sink.go index 28428545b..9b5b78fd9 100644 --- a/weed/replication/sink/s3sink/s3_sink.go +++ b/weed/replication/sink/s3sink/s3_sink.go @@ -3,6 +3,9 @@ package S3Sink import ( "encoding/base64" "fmt" + "strconv" + "strings" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" @@ -10,8 +13,6 @@ import ( "github.com/aws/aws-sdk-go/service/s3/s3iface" "github.com/aws/aws-sdk-go/service/s3/s3manager" "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" - "strconv" - "strings" "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/glog" diff --git a/weed/replication/sub/notification_gocdk_pub_sub.go b/weed/replication/sub/notification_gocdk_pub_sub.go index 2e7640af4..0632c6bf0 100644 --- a/weed/replication/sub/notification_gocdk_pub_sub.go +++ b/weed/replication/sub/notification_gocdk_pub_sub.go @@ -5,6 +5,12 @@ package sub import ( "context" + "net/url" + "os" + "path" + "strings" + "time" + amqp "github.com/rabbitmq/amqp091-go" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" @@ -13,11 +19,6 @@ import ( _ "gocloud.dev/pubsub/awssnssqs" "gocloud.dev/pubsub/rabbitpubsub" "google.golang.org/protobuf/proto" - "net/url" - "os" - "path" - "strings" - "time" // _ "gocloud.dev/pubsub/azuresb" _ "gocloud.dev/pubsub/gcppubsub" diff --git a/weed/s3api/bucket_metadata_test.go b/weed/s3api/bucket_metadata_test.go index 16d20b8fe..6d9468c32 100644 --- a/weed/s3api/bucket_metadata_test.go +++ b/weed/s3api/bucket_metadata_test.go @@ -3,15 +3,16 @@ package s3api import ( "encoding/json" "fmt" + "reflect" + "sync" + "testing" + "time" + "github.com/aws/aws-sdk-go/service/s3" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/iam_pb" "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" - "reflect" - "sync" - "testing" - "time" ) type BucketMetadataTestCase struct { diff --git a/weed/s3api/filer_multipart_test.go b/weed/s3api/filer_multipart_test.go index bf4fa3ca2..f407e268e 100644 --- a/weed/s3api/filer_multipart_test.go +++ b/weed/s3api/filer_multipart_test.go @@ -84,11 +84,11 @@ func TestGetEntryNameAndDir(t *testing.T) { } tests := []struct { - name string - bucket string - key string - expectedName string - expectedDirEnd string // We check the suffix since dir includes BucketsPath + name string + bucket string + key string + expectedName string + expectedDirEnd string // We check the suffix since dir includes BucketsPath }{ { name: "simple file at root", diff --git a/weed/s3api/filer_util_tags.go b/weed/s3api/filer_util_tags.go index d33e46c2e..ee2f5da33 100644 --- a/weed/s3api/filer_util_tags.go +++ b/weed/s3api/filer_util_tags.go @@ -2,10 +2,10 @@ package s3api import ( "context" - "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "strings" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" ) const ( diff --git a/weed/s3api/policy/post-policy.go b/weed/s3api/policy/post-policy.go index ad3cfc401..3250cdf49 100644 --- a/weed/s3api/policy/post-policy.go +++ b/weed/s3api/policy/post-policy.go @@ -20,10 +20,11 @@ package policy import ( "encoding/base64" "fmt" - "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" "net/http" "strings" "time" + + "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" ) // expirationDateFormat date format for expiration key in json policy. diff --git a/weed/s3api/s3_constants/buckets.go b/weed/s3api/s3_constants/buckets.go index 97f86d569..a10cf0f50 100644 --- a/weed/s3api/s3_constants/buckets.go +++ b/weed/s3api/s3_constants/buckets.go @@ -4,4 +4,3 @@ const ( // DefaultBucketsPath is the default path for S3 buckets in the filer DefaultBucketsPath = "/buckets" ) - diff --git a/weed/s3api/s3_constants/extend_key.go b/weed/s3api/s3_constants/extend_key.go index 985160b52..56f2ac1ea 100644 --- a/weed/s3api/s3_constants/extend_key.go +++ b/weed/s3api/s3_constants/extend_key.go @@ -12,12 +12,12 @@ const ( ExtLatestVersionIdKey = "Seaweed-X-Amz-Latest-Version-Id" ExtLatestVersionFileNameKey = "Seaweed-X-Amz-Latest-Version-File-Name" // Cached list metadata in .versions directory for single-scan efficiency - ExtLatestVersionSizeKey = "Seaweed-X-Amz-Latest-Version-Size" - ExtLatestVersionETagKey = "Seaweed-X-Amz-Latest-Version-ETag" - ExtLatestVersionMtimeKey = "Seaweed-X-Amz-Latest-Version-Mtime" - ExtLatestVersionOwnerKey = "Seaweed-X-Amz-Latest-Version-Owner" - ExtLatestVersionIsDeleteMarker = "Seaweed-X-Amz-Latest-Version-Is-Delete-Marker" - ExtMultipartObjectKey = "key" + ExtLatestVersionSizeKey = "Seaweed-X-Amz-Latest-Version-Size" + ExtLatestVersionETagKey = "Seaweed-X-Amz-Latest-Version-ETag" + ExtLatestVersionMtimeKey = "Seaweed-X-Amz-Latest-Version-Mtime" + ExtLatestVersionOwnerKey = "Seaweed-X-Amz-Latest-Version-Owner" + ExtLatestVersionIsDeleteMarker = "Seaweed-X-Amz-Latest-Version-Is-Delete-Marker" + ExtMultipartObjectKey = "key" // Bucket Policy ExtBucketPolicyKey = "Seaweed-X-Amz-Bucket-Policy" diff --git a/weed/s3api/s3_existing_object_tag_test.go b/weed/s3api/s3_existing_object_tag_test.go index 65cca9f1a..0adea6976 100644 --- a/weed/s3api/s3_existing_object_tag_test.go +++ b/weed/s3api/s3_existing_object_tag_test.go @@ -257,4 +257,3 @@ func TestHasPolicyForBucket(t *testing.T) { // No longer has policy assert.False(t, engine.HasPolicyForBucket("test-bucket")) } - diff --git a/weed/s3api/s3api_acl_helper_test.go b/weed/s3api/s3api_acl_helper_test.go index 81ce25575..d3a625ce2 100644 --- a/weed/s3api/s3api_acl_helper_test.go +++ b/weed/s3api/s3api_acl_helper_test.go @@ -3,15 +3,16 @@ package s3api import ( "bytes" "encoding/json" + "io" + "net/http" + "testing" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/s3" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/iam_pb" "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" - "io" - "net/http" - "testing" ) var accountManager *IdentityAccessManagement diff --git a/weed/s3api/s3api_acp.go b/weed/s3api/s3api_acp.go index 0a79990f5..a3ac2ebb1 100644 --- a/weed/s3api/s3api_acp.go +++ b/weed/s3api/s3api_acp.go @@ -1,9 +1,10 @@ package s3api import ( + "net/http" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" - "net/http" ) func getAccountId(r *http.Request) string { diff --git a/weed/s3api/s3api_bucket_handlers_object_lock_config.go b/weed/s3api/s3api_bucket_handlers_object_lock_config.go index 23b52648e..a6b422617 100644 --- a/weed/s3api/s3api_bucket_handlers_object_lock_config.go +++ b/weed/s3api/s3api_bucket_handlers_object_lock_config.go @@ -88,7 +88,7 @@ func (s3a *S3ApiServer) GetObjectLockConfigurationHandler(w http.ResponseWriter, if bucketConfig.ObjectLockConfig != nil { // Set namespace for S3 compatibility bucketConfig.ObjectLockConfig.XMLNS = s3_constants.S3Namespace - + // Use cached configuration and marshal it to XML for response marshaledXML, err := xml.Marshal(bucketConfig.ObjectLockConfig) if err != nil { diff --git a/weed/s3api/s3api_circuit_breaker.go b/weed/s3api/s3api_circuit_breaker.go index e19caf91b..0b6dc160e 100644 --- a/weed/s3api/s3api_circuit_breaker.go +++ b/weed/s3api/s3api_circuit_breaker.go @@ -93,9 +93,9 @@ func (cb *CircuitBreaker) loadCircuitBreakerConfig(cfg *s3_pb.S3CircuitBreakerCo func (cb *CircuitBreaker) Limit(f func(w http.ResponseWriter, r *http.Request), action string) (http.HandlerFunc, Action) { return func(w http.ResponseWriter, r *http.Request) { // Apply upload limiting for write actions if configured - if cb.s3a != nil && (action == s3_constants.ACTION_WRITE) && + if cb.s3a != nil && (action == s3_constants.ACTION_WRITE) && (cb.s3a.option.ConcurrentUploadLimit != 0 || cb.s3a.option.ConcurrentFileUploadLimit != 0) { - + // Get content length, default to 0 if not provided contentLength := r.ContentLength if contentLength < 0 { @@ -108,12 +108,12 @@ func (cb *CircuitBreaker) Limit(f func(w http.ResponseWriter, r *http.Request), inFlightUploads := atomic.LoadInt64(&cb.s3a.inFlightUploads) // Wait if either data size limit or file count limit is exceeded - for (cb.s3a.option.ConcurrentUploadLimit != 0 && inFlightDataSize > cb.s3a.option.ConcurrentUploadLimit) || + for (cb.s3a.option.ConcurrentUploadLimit != 0 && inFlightDataSize > cb.s3a.option.ConcurrentUploadLimit) || (cb.s3a.option.ConcurrentFileUploadLimit != 0 && inFlightUploads >= cb.s3a.option.ConcurrentFileUploadLimit) { - if (cb.s3a.option.ConcurrentUploadLimit != 0 && inFlightDataSize > cb.s3a.option.ConcurrentUploadLimit) { + if cb.s3a.option.ConcurrentUploadLimit != 0 && inFlightDataSize > cb.s3a.option.ConcurrentUploadLimit { glog.V(4).Infof("wait because inflight data %d > %d", inFlightDataSize, cb.s3a.option.ConcurrentUploadLimit) } - if (cb.s3a.option.ConcurrentFileUploadLimit != 0 && inFlightUploads >= cb.s3a.option.ConcurrentFileUploadLimit) { + if cb.s3a.option.ConcurrentFileUploadLimit != 0 && inFlightUploads >= cb.s3a.option.ConcurrentFileUploadLimit { glog.V(4).Infof("wait because inflight uploads %d >= %d", inFlightUploads, cb.s3a.option.ConcurrentFileUploadLimit) } cb.s3a.inFlightDataLimitCond.Wait() diff --git a/weed/s3api/s3api_circuit_breaker_test.go b/weed/s3api/s3api_circuit_breaker_test.go index aa8167544..72e166558 100644 --- a/weed/s3api/s3api_circuit_breaker_test.go +++ b/weed/s3api/s3api_circuit_breaker_test.go @@ -1,13 +1,14 @@ package s3api import ( - "github.com/seaweedfs/seaweedfs/weed/pb/s3_pb" - "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" - "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" "net/http" "sync" "sync/atomic" "testing" + + "github.com/seaweedfs/seaweedfs/weed/pb/s3_pb" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" ) type TestLimitCase struct { diff --git a/weed/s3api/s3api_encrypted_volume_copy_test.go b/weed/s3api/s3api_encrypted_volume_copy_test.go index 7e84384fb..169a0f616 100644 --- a/weed/s3api/s3api_encrypted_volume_copy_test.go +++ b/weed/s3api/s3api_encrypted_volume_copy_test.go @@ -173,4 +173,3 @@ func TestEncryptedVolumeCopyScenario(t *testing.T) { t.Log("✓ All chunk metadata properly preserved for encrypted volume copy scenario") }) } - diff --git a/weed/s3api/s3api_handlers.go b/weed/s3api/s3api_handlers.go index 6c47e8256..00c8834b0 100644 --- a/weed/s3api/s3api_handlers.go +++ b/weed/s3api/s3api_handlers.go @@ -20,7 +20,7 @@ func (s3a *S3ApiServer) WithFilerClient(streamingMode bool, fn func(filer_pb.Sea if s3a.filerClient != nil { return s3a.withFilerClientFailover(streamingMode, fn) } - + // Fallback to direct connection if filerClient not initialized // This should only happen during initialization or testing return pb.WithGrpcClient(streamingMode, s3a.randomClientId, func(grpcConnection *grpc.ClientConn) error { @@ -34,41 +34,41 @@ func (s3a *S3ApiServer) WithFilerClient(streamingMode bool, fn func(filer_pb.Sea func (s3a *S3ApiServer) withFilerClientFailover(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) error { // Get current filer as starting point currentFiler := s3a.filerClient.GetCurrentFiler() - + // Try current filer first (fast path) err := pb.WithGrpcClient(streamingMode, s3a.randomClientId, func(grpcConnection *grpc.ClientConn) error { client := filer_pb.NewSeaweedFilerClient(grpcConnection) return fn(client) }, currentFiler.ToGrpcAddress(), false, s3a.option.GrpcDialOption) - + if err == nil { s3a.filerClient.RecordFilerSuccess(currentFiler) return nil } - + // Record failure for current filer s3a.filerClient.RecordFilerFailure(currentFiler) - + // Current filer failed - try all other filers with health-aware selection filers := s3a.filerClient.GetAllFilers() var lastErr error = err - + for _, filer := range filers { if filer == currentFiler { continue // Already tried this one } - + // Skip filers known to be unhealthy (circuit breaker pattern) if s3a.filerClient.ShouldSkipUnhealthyFiler(filer) { glog.V(2).Infof("WithFilerClient: skipping unhealthy filer %s", filer) continue } - + err = pb.WithGrpcClient(streamingMode, s3a.randomClientId, func(grpcConnection *grpc.ClientConn) error { client := filer_pb.NewSeaweedFilerClient(grpcConnection) return fn(client) }, filer.ToGrpcAddress(), false, s3a.option.GrpcDialOption) - + if err == nil { // Success! Record success and update current filer for future requests s3a.filerClient.RecordFilerSuccess(filer) @@ -76,13 +76,13 @@ func (s3a *S3ApiServer) withFilerClientFailover(streamingMode bool, fn func(file glog.V(1).Infof("WithFilerClient: failover from %s to %s succeeded", currentFiler, filer) return nil } - + // Record failure for health tracking s3a.filerClient.RecordFilerFailure(filer) glog.V(2).Infof("WithFilerClient: failover to %s failed: %v", filer, err) lastErr = err } - + // All filers failed return fmt.Errorf("all filers failed, last error: %w", lastErr) } diff --git a/weed/s3api/s3api_list_normalization_test.go b/weed/s3api/s3api_list_normalization_test.go index 128457b8f..8f4d91cde 100644 --- a/weed/s3api/s3api_list_normalization_test.go +++ b/weed/s3api/s3api_list_normalization_test.go @@ -44,7 +44,7 @@ func TestPrefixNormalizationInList(t *testing.T) { t.Run(tt.name, func(t *testing.T) { // Normalize using NormalizeObjectKey (same as object keys) normalizedPrefix := s3_constants.NormalizeObjectKey(tt.inputPrefix) - + if normalizedPrefix != tt.expectedPrefix { t.Errorf("Prefix normalization mismatch:\n Input: %q\n Expected: %q\n Got: %q\n Desc: %s", tt.inputPrefix, tt.expectedPrefix, normalizedPrefix, tt.description) @@ -75,11 +75,11 @@ func TestListPrefixConsistency(t *testing.T) { func startsWithPrefix(objectKey, prefix string) bool { // Normalize the prefix using the same logic as NormalizeObjectKey normalizedPrefix := s3_constants.NormalizeObjectKey(prefix) - + // Check if the object starts with the normalized prefix if normalizedPrefix == "" { return true } - + return objectKey == normalizedPrefix || objectKey[:len(normalizedPrefix)] == normalizedPrefix } diff --git a/weed/s3api/s3api_server_grpc.go b/weed/s3api/s3api_server_grpc.go index 93da82c18..b421b0574 100644 --- a/weed/s3api/s3api_server_grpc.go +++ b/weed/s3api/s3api_server_grpc.go @@ -2,6 +2,7 @@ package s3api import ( "context" + "github.com/seaweedfs/seaweedfs/weed/pb/s3_pb" ) diff --git a/weed/s3api/s3api_status_handlers.go b/weed/s3api/s3api_status_handlers.go index e5d8b96b8..e868a135f 100644 --- a/weed/s3api/s3api_status_handlers.go +++ b/weed/s3api/s3api_status_handlers.go @@ -1,8 +1,9 @@ package s3api import ( - "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" "net/http" + + "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" ) func (s3a *S3ApiServer) StatusHandler(w http.ResponseWriter, r *http.Request) { diff --git a/weed/s3api/s3api_streaming_copy.go b/weed/s3api/s3api_streaming_copy.go index 94729c003..f50f715e3 100644 --- a/weed/s3api/s3api_streaming_copy.go +++ b/weed/s3api/s3api_streaming_copy.go @@ -459,8 +459,8 @@ func (scm *StreamingCopyManager) streamToChunks(ctx context.Context, reader io.R for { n, err := reader.Read(buffer) if n > 0 { - // Create chunk for this data, setting SSE type and per-chunk metadata (including chunk-specific IVs for SSE-S3) - chunk, chunkErr := scm.createChunkFromData(buffer[:n], offset, dstPath, spec.EncryptionSpec) + // Create chunk for this data, setting SSE type and per-chunk metadata (including chunk-specific IVs for SSE-S3) + chunk, chunkErr := scm.createChunkFromData(buffer[:n], offset, dstPath, spec.EncryptionSpec) if chunkErr != nil { return nil, fmt.Errorf("create chunk from data: %w", chunkErr) } diff --git a/weed/s3api/s3api_test.go b/weed/s3api/s3api_test.go index 80dced599..106c66798 100644 --- a/weed/s3api/s3api_test.go +++ b/weed/s3api/s3api_test.go @@ -1,9 +1,10 @@ package s3api import ( - "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" "testing" "time" + + "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" ) func TestCopyObjectResponse(t *testing.T) { diff --git a/weed/s3api/s3api_version_id_test.go b/weed/s3api/s3api_version_id_test.go index 5c612ac58..fd52fd773 100644 --- a/weed/s3api/s3api_version_id_test.go +++ b/weed/s3api/s3api_version_id_test.go @@ -372,4 +372,3 @@ func TestMixedFormatTransition(t *testing.T) { t.Errorf("compareVersionIds(newest_new_format, oldest_old_format) = %d, want negative", result) } } - diff --git a/weed/s3api/s3bucket/s3api_bucket_test.go b/weed/s3api/s3bucket/s3api_bucket_test.go index 9ada225ef..b81ace85e 100644 --- a/weed/s3api/s3bucket/s3api_bucket_test.go +++ b/weed/s3api/s3bucket/s3api_bucket_test.go @@ -1,8 +1,9 @@ package s3bucket import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func Test_verifyBucketName(t *testing.T) { diff --git a/weed/sequence/snowflake_sequencer_test.go b/weed/sequence/snowflake_sequencer_test.go index 7e8c1d046..dd2193188 100644 --- a/weed/sequence/snowflake_sequencer_test.go +++ b/weed/sequence/snowflake_sequencer_test.go @@ -2,9 +2,10 @@ package sequence import ( "encoding/hex" + "testing" + "github.com/seaweedfs/seaweedfs/weed/storage/types" "github.com/stretchr/testify/assert" - "testing" ) func TestSequencer(t *testing.T) { diff --git a/weed/server/filer_grpc_server_admin.go b/weed/server/filer_grpc_server_admin.go index 92a820f35..914fca56c 100644 --- a/weed/server/filer_grpc_server_admin.go +++ b/weed/server/filer_grpc_server_admin.go @@ -3,7 +3,6 @@ package weed_server import ( "context" "fmt" - "github.com/seaweedfs/seaweedfs/weed/util/version" "time" "github.com/seaweedfs/seaweedfs/weed/cluster" @@ -12,6 +11,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" + "github.com/seaweedfs/seaweedfs/weed/util/version" ) func (fs *FilerServer) Statistics(ctx context.Context, req *filer_pb.StatisticsRequest) (resp *filer_pb.StatisticsResponse, err error) { diff --git a/weed/server/filer_grpc_server_kv.go b/weed/server/filer_grpc_server_kv.go index be90b2014..267f408a5 100644 --- a/weed/server/filer_grpc_server_kv.go +++ b/weed/server/filer_grpc_server_kv.go @@ -2,6 +2,7 @@ package weed_server import ( "context" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" ) diff --git a/weed/server/filer_grpc_server_traverse_meta_test.go b/weed/server/filer_grpc_server_traverse_meta_test.go index 72f8a916e..31cd33064 100644 --- a/weed/server/filer_grpc_server_traverse_meta_test.go +++ b/weed/server/filer_grpc_server_traverse_meta_test.go @@ -1,9 +1,10 @@ package weed_server import ( + "testing" + "github.com/stretchr/testify/assert" "github.com/viant/ptrie" - "testing" ) func TestPtrie(t *testing.T) { diff --git a/weed/server/filer_server_handlers.go b/weed/server/filer_server_handlers.go index f068579ec..57d675740 100644 --- a/weed/server/filer_server_handlers.go +++ b/weed/server/filer_server_handlers.go @@ -3,7 +3,6 @@ package weed_server import ( "context" "errors" - "github.com/seaweedfs/seaweedfs/weed/util/version" "net/http" "os" "strconv" @@ -16,6 +15,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/security" "github.com/seaweedfs/seaweedfs/weed/stats" + "github.com/seaweedfs/seaweedfs/weed/util/version" ) func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { @@ -99,10 +99,10 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { // Wait if either data size limit or file count limit is exceeded for (fs.option.ConcurrentUploadLimit != 0 && inFlightDataSize > fs.option.ConcurrentUploadLimit) || (fs.option.ConcurrentFileUploadLimit != 0 && inFlightUploads >= fs.option.ConcurrentFileUploadLimit) { - if (fs.option.ConcurrentUploadLimit != 0 && inFlightDataSize > fs.option.ConcurrentUploadLimit) { + if fs.option.ConcurrentUploadLimit != 0 && inFlightDataSize > fs.option.ConcurrentUploadLimit { glog.V(4).Infof("wait because inflight data %d > %d", inFlightDataSize, fs.option.ConcurrentUploadLimit) } - if (fs.option.ConcurrentFileUploadLimit != 0 && inFlightUploads >= fs.option.ConcurrentFileUploadLimit) { + if fs.option.ConcurrentFileUploadLimit != 0 && inFlightUploads >= fs.option.ConcurrentFileUploadLimit { glog.V(4).Infof("wait because inflight uploads %d >= %d", inFlightUploads, fs.option.ConcurrentFileUploadLimit) } fs.inFlightDataLimitCond.Wait() diff --git a/weed/server/filer_server_handlers_read_dir.go b/weed/server/filer_server_handlers_read_dir.go index 9266cb536..380816a4d 100644 --- a/weed/server/filer_server_handlers_read_dir.go +++ b/weed/server/filer_server_handlers_read_dir.go @@ -2,7 +2,6 @@ package weed_server import ( "errors" - "github.com/seaweedfs/seaweedfs/weed/util/version" "net/http" "strconv" "strings" @@ -11,6 +10,7 @@ import ( ui "github.com/seaweedfs/seaweedfs/weed/server/filer_ui" "github.com/seaweedfs/seaweedfs/weed/stats" "github.com/seaweedfs/seaweedfs/weed/util" + "github.com/seaweedfs/seaweedfs/weed/util/version" ) // listDirectoryHandler lists directories and folders under a directory diff --git a/weed/server/filer_ui/templates.go b/weed/server/filer_ui/templates.go index f9ef064bc..7faf01007 100644 --- a/weed/server/filer_ui/templates.go +++ b/weed/server/filer_ui/templates.go @@ -2,10 +2,11 @@ package filer_ui import ( _ "embed" - "github.com/dustin/go-humanize" "html/template" "net/url" "strings" + + "github.com/dustin/go-humanize" ) func printpath(parts ...string) string { diff --git a/weed/server/master_grpc_server_admin.go b/weed/server/master_grpc_server_admin.go index d8b63b5da..eb6cb452b 100644 --- a/weed/server/master_grpc_server_admin.go +++ b/weed/server/master_grpc_server_admin.go @@ -3,7 +3,6 @@ package weed_server import ( "context" "fmt" - "github.com/seaweedfs/seaweedfs/weed/stats" "math/rand/v2" "sync" "time" @@ -13,9 +12,9 @@ import ( "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" - "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" - "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" + "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" + "github.com/seaweedfs/seaweedfs/weed/stats" ) /* diff --git a/weed/server/master_grpc_server_cluster.go b/weed/server/master_grpc_server_cluster.go index 5c99fd00d..036dd8971 100644 --- a/weed/server/master_grpc_server_cluster.go +++ b/weed/server/master_grpc_server_cluster.go @@ -2,10 +2,11 @@ package weed_server import ( "context" + "math/rand/v2" + "github.com/seaweedfs/seaweedfs/weed/cluster" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" - "math/rand/v2" ) func (ms *MasterServer) ListClusterNodes(ctx context.Context, req *master_pb.ListClusterNodesRequest) (*master_pb.ListClusterNodesResponse, error) { diff --git a/weed/server/raft_server_handlers.go b/weed/server/raft_server_handlers.go index eba61569e..45a63b9e4 100644 --- a/weed/server/raft_server_handlers.go +++ b/weed/server/raft_server_handlers.go @@ -1,12 +1,13 @@ package weed_server import ( + "net/http" + "time" + "github.com/cenkalti/backoff/v4" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/storage/needle" - "net/http" - "time" ) type ClusterStatusResult struct { diff --git a/weed/server/volume_grpc_copy.go b/weed/server/volume_grpc_copy.go index c48f3edf2..92f1edcb0 100644 --- a/weed/server/volume_grpc_copy.go +++ b/weed/server/volume_grpc_copy.go @@ -428,10 +428,10 @@ func (vs *VolumeServer) CopyFile(req *volume_server_pb.CopyFileRequest, stream v } -// If no data has been sent in the loop (e.g. for an empty file, or when stopOffset is 0), -// we still need to send the ModifiedTsNs so the client knows the source file exists. -// fileModTsNs is set to 0 after the first send, so if it's still non-zero, -// we haven't sent anything yet. + // If no data has been sent in the loop (e.g. for an empty file, or when stopOffset is 0), + // we still need to send the ModifiedTsNs so the client knows the source file exists. + // fileModTsNs is set to 0 after the first send, so if it's still non-zero, + // we haven't sent anything yet. if fileModTsNs != 0 { err = stream.Send(&volume_server_pb.CopyFileResponse{ ModifiedTsNs: fileModTsNs, diff --git a/weed/server/volume_grpc_read_all.go b/weed/server/volume_grpc_read_all.go index 68001ce9e..0b1aff2ff 100644 --- a/weed/server/volume_grpc_read_all.go +++ b/weed/server/volume_grpc_read_all.go @@ -2,6 +2,7 @@ package weed_server import ( "fmt" + "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" "github.com/seaweedfs/seaweedfs/weed/storage" "github.com/seaweedfs/seaweedfs/weed/storage/needle" diff --git a/weed/server/volume_grpc_read_write.go b/weed/server/volume_grpc_read_write.go index eadefc409..1c0ddf5dd 100644 --- a/weed/server/volume_grpc_read_write.go +++ b/weed/server/volume_grpc_read_write.go @@ -3,6 +3,7 @@ package weed_server import ( "context" "fmt" + "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" "github.com/seaweedfs/seaweedfs/weed/storage/needle" "github.com/seaweedfs/seaweedfs/weed/storage/types" diff --git a/weed/server/volume_grpc_remote.go b/weed/server/volume_grpc_remote.go index 669858b6a..0dffb49cf 100644 --- a/weed/server/volume_grpc_remote.go +++ b/weed/server/volume_grpc_remote.go @@ -3,14 +3,15 @@ package weed_server import ( "context" "fmt" + "sync" + "time" + "github.com/seaweedfs/seaweedfs/weed/operation" "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/security" "github.com/seaweedfs/seaweedfs/weed/storage/needle" "github.com/seaweedfs/seaweedfs/weed/storage/types" - "sync" - "time" ) func (vs *VolumeServer) FetchAndWriteNeedle(ctx context.Context, req *volume_server_pb.FetchAndWriteNeedleRequest) (resp *volume_server_pb.FetchAndWriteNeedleResponse, err error) { diff --git a/weed/server/wrapped_webdav_fs.go b/weed/server/wrapped_webdav_fs.go index f110d41a4..4ef8d4e68 100644 --- a/weed/server/wrapped_webdav_fs.go +++ b/weed/server/wrapped_webdav_fs.go @@ -2,10 +2,11 @@ package weed_server import ( "context" - "golang.org/x/net/webdav" "io/fs" "os" "strings" + + "golang.org/x/net/webdav" ) type wrappedFs struct { diff --git a/weed/shell/command_cluster_check.go b/weed/shell/command_cluster_check.go index 57b30e008..4a1460e27 100644 --- a/weed/shell/command_cluster_check.go +++ b/weed/shell/command_cluster_check.go @@ -4,7 +4,6 @@ import ( "context" "flag" "fmt" - "github.com/seaweedfs/seaweedfs/weed/storage/types" "io" "github.com/seaweedfs/seaweedfs/weed/cluster" @@ -12,6 +11,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" + "github.com/seaweedfs/seaweedfs/weed/storage/types" ) func init() { diff --git a/weed/shell/command_cluster_ps.go b/weed/shell/command_cluster_ps.go index 5a1503612..0f9e8e5ec 100644 --- a/weed/shell/command_cluster_ps.go +++ b/weed/shell/command_cluster_ps.go @@ -4,14 +4,15 @@ import ( "context" "flag" "fmt" + "io" + "time" + "github.com/seaweedfs/seaweedfs/weed/cluster" "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" "github.com/seaweedfs/seaweedfs/weed/util" - "io" - "time" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" ) diff --git a/weed/shell/command_cluster_raft_add.go b/weed/shell/command_cluster_raft_add.go index eb75f8b15..a957d7c44 100644 --- a/weed/shell/command_cluster_raft_add.go +++ b/weed/shell/command_cluster_raft_add.go @@ -4,8 +4,9 @@ import ( "context" "flag" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "io" + + "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" ) func init() { diff --git a/weed/shell/command_cluster_raft_leader_transfer.go b/weed/shell/command_cluster_raft_leader_transfer.go index a8bef4a2e..32dc83f51 100644 --- a/weed/shell/command_cluster_raft_leader_transfer.go +++ b/weed/shell/command_cluster_raft_leader_transfer.go @@ -141,4 +141,3 @@ func (c *commandRaftLeaderTransfer) Do(args []string, commandEnv *CommandEnv, wr return nil } - diff --git a/weed/shell/command_cluster_raft_leader_transfer_test.go b/weed/shell/command_cluster_raft_leader_transfer_test.go index 8280489f7..7858abb34 100644 --- a/weed/shell/command_cluster_raft_leader_transfer_test.go +++ b/weed/shell/command_cluster_raft_leader_transfer_test.go @@ -86,4 +86,3 @@ func TestRaftLeaderTransfer_UnknownFlag(t *testing.T) { t.Error("expected error for unknown flag") } } - diff --git a/weed/shell/command_cluster_raft_ps.go b/weed/shell/command_cluster_raft_ps.go index 73bfde8da..714e17649 100644 --- a/weed/shell/command_cluster_raft_ps.go +++ b/weed/shell/command_cluster_raft_ps.go @@ -4,8 +4,9 @@ import ( "context" "flag" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "io" + + "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" ) func init() { diff --git a/weed/shell/command_cluster_raft_remove.go b/weed/shell/command_cluster_raft_remove.go index c9ada8bcd..6f5324731 100644 --- a/weed/shell/command_cluster_raft_remove.go +++ b/weed/shell/command_cluster_raft_remove.go @@ -4,8 +4,9 @@ import ( "context" "flag" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "io" + + "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" ) func init() { diff --git a/weed/shell/command_collection_list.go b/weed/shell/command_collection_list.go index 32085f565..582ea54ca 100644 --- a/weed/shell/command_collection_list.go +++ b/weed/shell/command_collection_list.go @@ -3,9 +3,10 @@ package shell import ( "context" "fmt" + "io" + "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "github.com/seaweedfs/seaweedfs/weed/storage/super_block" - "io" ) func init() { diff --git a/weed/shell/command_fs_log.go b/weed/shell/command_fs_log.go index 66f143030..b93c2b9cd 100644 --- a/weed/shell/command_fs_log.go +++ b/weed/shell/command_fs_log.go @@ -4,10 +4,11 @@ import ( "context" "flag" "fmt" - "github.com/seaweedfs/seaweedfs/weed/filer" - "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "io" "time" + + "github.com/seaweedfs/seaweedfs/weed/filer" + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" ) func init() { diff --git a/weed/shell/command_fs_verify.go b/weed/shell/command_fs_verify.go index fd46bf591..78f154405 100644 --- a/weed/shell/command_fs_verify.go +++ b/weed/shell/command_fs_verify.go @@ -11,6 +11,8 @@ import ( "sync" "time" + "slices" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/operation" "github.com/seaweedfs/seaweedfs/weed/pb" @@ -20,7 +22,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/storage" "github.com/seaweedfs/seaweedfs/weed/util" "go.uber.org/atomic" - "slices" ) func init() { diff --git a/weed/shell/command_lock_unlock.go b/weed/shell/command_lock_unlock.go index 79f3c95b1..982bb9120 100644 --- a/weed/shell/command_lock_unlock.go +++ b/weed/shell/command_lock_unlock.go @@ -1,8 +1,9 @@ package shell import ( - "github.com/seaweedfs/seaweedfs/weed/util" "io" + + "github.com/seaweedfs/seaweedfs/weed/util" ) func init() { diff --git a/weed/shell/command_mq_balance.go b/weed/shell/command_mq_balance.go index 2e61e640c..a9576838e 100644 --- a/weed/shell/command_mq_balance.go +++ b/weed/shell/command_mq_balance.go @@ -3,9 +3,10 @@ package shell import ( "context" "fmt" + "io" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" - "io" ) func init() { diff --git a/weed/shell/command_mq_topic_configure.go b/weed/shell/command_mq_topic_configure.go index ab54ee554..ea58d5787 100644 --- a/weed/shell/command_mq_topic_configure.go +++ b/weed/shell/command_mq_topic_configure.go @@ -5,10 +5,11 @@ import ( "encoding/json" "flag" "fmt" + "io" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" - "io" ) func init() { diff --git a/weed/shell/command_mq_topic_desc.go b/weed/shell/command_mq_topic_desc.go index 9a0d61066..b1b976649 100644 --- a/weed/shell/command_mq_topic_desc.go +++ b/weed/shell/command_mq_topic_desc.go @@ -4,10 +4,11 @@ import ( "context" "flag" "fmt" + "io" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" "github.com/seaweedfs/seaweedfs/weed/pb/schema_pb" - "io" ) func init() { diff --git a/weed/shell/command_mq_topic_list.go b/weed/shell/command_mq_topic_list.go index d8d7a08cb..8bed7c560 100644 --- a/weed/shell/command_mq_topic_list.go +++ b/weed/shell/command_mq_topic_list.go @@ -3,11 +3,12 @@ package shell import ( "context" "fmt" + "io" + "github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" - "io" ) func init() { diff --git a/weed/shell/command_remote_meta_sync.go b/weed/shell/command_remote_meta_sync.go index d42aaef95..d71ba1608 100644 --- a/weed/shell/command_remote_meta_sync.go +++ b/weed/shell/command_remote_meta_sync.go @@ -4,12 +4,13 @@ import ( "context" "flag" "fmt" + "io" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" - "io" ) func init() { diff --git a/weed/shell/command_remote_mount.go b/weed/shell/command_remote_mount.go index 59ab75b4d..144aa079a 100644 --- a/weed/shell/command_remote_mount.go +++ b/weed/shell/command_remote_mount.go @@ -4,16 +4,17 @@ import ( "context" "flag" "fmt" + "io" + "os" + "strings" + "time" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" "google.golang.org/protobuf/proto" - "io" - "os" - "strings" - "time" ) func init() { diff --git a/weed/shell/command_remote_mount_buckets.go b/weed/shell/command_remote_mount_buckets.go index 6176aa3d7..77aa1ba30 100644 --- a/weed/shell/command_remote_mount_buckets.go +++ b/weed/shell/command_remote_mount_buckets.go @@ -3,13 +3,14 @@ package shell import ( "flag" "fmt" + "io" + "path/filepath" + "regexp" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" - "io" - "path/filepath" - "regexp" ) func init() { diff --git a/weed/shell/command_remote_unmount.go b/weed/shell/command_remote_unmount.go index 2e1ba393c..bb70744c6 100644 --- a/weed/shell/command_remote_unmount.go +++ b/weed/shell/command_remote_unmount.go @@ -4,12 +4,13 @@ import ( "context" "flag" "fmt" + "io" + "time" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" - "io" - "time" ) func init() { diff --git a/weed/shell/command_volume_copy.go b/weed/shell/command_volume_copy.go index 5c7cc33b0..3156be8b5 100644 --- a/weed/shell/command_volume_copy.go +++ b/weed/shell/command_volume_copy.go @@ -3,9 +3,9 @@ package shell import ( "flag" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb" "io" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/storage/needle" ) diff --git a/weed/shell/command_volume_delete.go b/weed/shell/command_volume_delete.go index 719420bcc..a7d52c011 100644 --- a/weed/shell/command_volume_delete.go +++ b/weed/shell/command_volume_delete.go @@ -2,9 +2,9 @@ package shell import ( "flag" - "github.com/seaweedfs/seaweedfs/weed/pb" "io" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/storage/needle" ) diff --git a/weed/shell/command_volume_grow.go b/weed/shell/command_volume_grow.go index 5b351e6ab..1a9a043d7 100644 --- a/weed/shell/command_volume_grow.go +++ b/weed/shell/command_volume_grow.go @@ -4,11 +4,12 @@ import ( "context" "flag" "fmt" + "io" + "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "github.com/seaweedfs/seaweedfs/weed/storage/needle" "github.com/seaweedfs/seaweedfs/weed/storage/super_block" "github.com/seaweedfs/seaweedfs/weed/storage/types" - "io" ) func init() { diff --git a/weed/shell/command_volume_mount.go b/weed/shell/command_volume_mount.go index 0b62905de..121d2bbdc 100644 --- a/weed/shell/command_volume_mount.go +++ b/weed/shell/command_volume_mount.go @@ -3,10 +3,10 @@ package shell import ( "context" "flag" - "github.com/seaweedfs/seaweedfs/weed/pb" "io" "github.com/seaweedfs/seaweedfs/weed/operation" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" "github.com/seaweedfs/seaweedfs/weed/storage/needle" "google.golang.org/grpc" diff --git a/weed/shell/command_volume_replica_check_test.go b/weed/shell/command_volume_replica_check_test.go index 7629ea862..fde9d22f7 100644 --- a/weed/shell/command_volume_replica_check_test.go +++ b/weed/shell/command_volume_replica_check_test.go @@ -270,4 +270,3 @@ func TestAvoidDuplicateCopies(t *testing.T) { t.Errorf("Expected 5 entries in union, got %d", count) } } - diff --git a/weed/shell/command_volume_unmount.go b/weed/shell/command_volume_unmount.go index ccb83bbae..ee273ed08 100644 --- a/weed/shell/command_volume_unmount.go +++ b/weed/shell/command_volume_unmount.go @@ -4,10 +4,10 @@ import ( "context" "flag" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb" "io" "github.com/seaweedfs/seaweedfs/weed/operation" + "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" "github.com/seaweedfs/seaweedfs/weed/storage/needle" "google.golang.org/grpc" diff --git a/weed/stats/disk_windows.go b/weed/stats/disk_windows.go index 93c703134..c3bf04eab 100644 --- a/weed/stats/disk_windows.go +++ b/weed/stats/disk_windows.go @@ -1,10 +1,11 @@ package stats import ( - "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" - "golang.org/x/sys/windows" "syscall" "unsafe" + + "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" + "golang.org/x/sys/windows" ) var ( diff --git a/weed/stats/metrics_buildinfo_test.go b/weed/stats/metrics_buildinfo_test.go index 1fc4a2b52..43c6439d3 100644 --- a/weed/stats/metrics_buildinfo_test.go +++ b/weed/stats/metrics_buildinfo_test.go @@ -29,7 +29,7 @@ func TestBuildInfo(t *testing.T) { if mf.GetName() == "SeaweedFS_build_info" { found = true metric := mf.GetMetric()[0] - + // Verify the metric value is 1 if metric.GetGauge().GetValue() != 1 { t.Errorf("Expected BuildInfo value to be 1, got %f", metric.GetGauge().GetValue()) @@ -79,4 +79,3 @@ func TestBuildInfo(t *testing.T) { t.Error("BuildInfo metric not found in gathered metrics") } } - diff --git a/weed/storage/backend/backend.go b/weed/storage/backend/backend.go index c17bec822..539867f8f 100644 --- a/weed/storage/backend/backend.go +++ b/weed/storage/backend/backend.go @@ -1,7 +1,6 @@ package backend import ( - "github.com/seaweedfs/seaweedfs/weed/util" "io" "os" "strings" @@ -10,6 +9,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" + "github.com/seaweedfs/seaweedfs/weed/util" ) type BackendStorageFile interface { diff --git a/weed/storage/backend/disk_file.go b/weed/storage/backend/disk_file.go index 070f79865..1573f8467 100644 --- a/weed/storage/backend/disk_file.go +++ b/weed/storage/backend/disk_file.go @@ -1,12 +1,13 @@ package backend import ( - "github.com/seaweedfs/seaweedfs/weed/glog" - . "github.com/seaweedfs/seaweedfs/weed/storage/types" "io" "os" "runtime" "time" + + "github.com/seaweedfs/seaweedfs/weed/glog" + . "github.com/seaweedfs/seaweedfs/weed/storage/types" ) var ( diff --git a/weed/storage/backend/memory_map/os_overloads/file_windows.go b/weed/storage/backend/memory_map/os_overloads/file_windows.go index 05aa384e2..93467303d 100644 --- a/weed/storage/backend/memory_map/os_overloads/file_windows.go +++ b/weed/storage/backend/memory_map/os_overloads/file_windows.go @@ -157,7 +157,7 @@ func syscallMode(i os.FileMode) (o uint32) { return } -//If the bool is set to true then the file is opened with the parameters FILE_ATTRIBUTE_TEMPORARY and +// If the bool is set to true then the file is opened with the parameters FILE_ATTRIBUTE_TEMPORARY and // FILE_FLAG_DELETE_ON_CLOSE func OpenFile(name string, flag int, perm os.FileMode, setToTempAndDelete bool) (file *os.File, err error) { r, e := Open(fixLongPath(name), flag|windows.O_CLOEXEC, syscallMode(perm), setToTempAndDelete) diff --git a/weed/storage/backend/rclone_backend/rclone_backend.go b/weed/storage/backend/rclone_backend/rclone_backend.go index e47c2f908..c954c0b73 100644 --- a/weed/storage/backend/rclone_backend/rclone_backend.go +++ b/weed/storage/backend/rclone_backend/rclone_backend.go @@ -7,23 +7,21 @@ import ( "bytes" "context" "fmt" - "github.com/rclone/rclone/fs/config/configfile" - "github.com/seaweedfs/seaweedfs/weed/util" "io" "os" "text/template" "time" "github.com/google/uuid" - _ "github.com/rclone/rclone/backend/all" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/accounting" + "github.com/rclone/rclone/fs/config/configfile" "github.com/rclone/rclone/fs/object" - "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" "github.com/seaweedfs/seaweedfs/weed/storage/backend" + "github.com/seaweedfs/seaweedfs/weed/util" ) func init() { diff --git a/weed/storage/backend/s3_backend/s3_sessions.go b/weed/storage/backend/s3_backend/s3_sessions.go index dfb0aa564..b5ae48971 100644 --- a/weed/storage/backend/s3_backend/s3_sessions.go +++ b/weed/storage/backend/s3_backend/s3_sessions.go @@ -2,7 +2,6 @@ package s3_backend import ( "fmt" - "github.com/seaweedfs/seaweedfs/weed/util/version" "sync" "github.com/aws/aws-sdk-go/aws" @@ -11,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" "github.com/aws/aws-sdk-go/service/s3/s3iface" + "github.com/seaweedfs/seaweedfs/weed/util/version" ) var ( diff --git a/weed/storage/backend/s3_backend/s3_upload.go b/weed/storage/backend/s3_backend/s3_upload.go index 537e6bd1d..1392ad23a 100644 --- a/weed/storage/backend/s3_backend/s3_upload.go +++ b/weed/storage/backend/s3_backend/s3_upload.go @@ -2,11 +2,12 @@ package s3_backend import ( "fmt" + "os" + "sync" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/s3/s3iface" "github.com/aws/aws-sdk-go/service/s3/s3manager" - "os" - "sync" "github.com/seaweedfs/seaweedfs/weed/glog" ) diff --git a/weed/storage/disk_location_test.go b/weed/storage/disk_location_test.go index d2823588f..f60a61475 100644 --- a/weed/storage/disk_location_test.go +++ b/weed/storage/disk_location_test.go @@ -1,12 +1,12 @@ package storage import ( - "github.com/seaweedfs/seaweedfs/weed/storage/types" "testing" "time" "github.com/seaweedfs/seaweedfs/weed/storage/backend" "github.com/seaweedfs/seaweedfs/weed/storage/needle" + "github.com/seaweedfs/seaweedfs/weed/storage/types" "github.com/seaweedfs/seaweedfs/weed/util" ) diff --git a/weed/storage/erasure_coding/distribution/analysis.go b/weed/storage/erasure_coding/distribution/analysis.go index 6b1f80053..22923e671 100644 --- a/weed/storage/erasure_coding/distribution/analysis.go +++ b/weed/storage/erasure_coding/distribution/analysis.go @@ -15,12 +15,12 @@ type ShardLocation struct { // TopologyNode represents a node in the topology that can hold EC shards type TopologyNode struct { - NodeID string - DataCenter string - Rack string - FreeSlots int // Available slots for new shards - ShardIDs []int // Shard IDs currently on this node for a specific volume - TotalShards int // Total shards on this node (for all volumes) + NodeID string + DataCenter string + Rack string + FreeSlots int // Available slots for new shards + ShardIDs []int // Shard IDs currently on this node for a specific volume + TotalShards int // Total shards on this node (for all volumes) } // TopologyAnalysis holds the current shard distribution analysis for a volume @@ -36,9 +36,9 @@ type TopologyAnalysis struct { NodeToShards map[string][]int // NodeID -> list of shard IDs // Topology structure - DCToRacks map[string][]string // DC -> list of rack IDs - RackToNodes map[string][]*TopologyNode // Rack -> list of nodes - AllNodes map[string]*TopologyNode // NodeID -> node info + DCToRacks map[string][]string // DC -> list of rack IDs + RackToNodes map[string][]*TopologyNode // Rack -> list of nodes + AllNodes map[string]*TopologyNode // NodeID -> node info // Statistics TotalShards int @@ -144,11 +144,11 @@ func (a *TopologyAnalysis) DetailedString() string { // TopologyExcess represents a topology level (DC/rack/node) with excess shards type TopologyExcess struct { - ID string // DC/rack/node ID - Level string // "dc", "rack", or "node" - Excess int // Number of excess shards (above target) - Shards []int // Shard IDs at this level - Nodes []*TopologyNode // Nodes at this level (for finding sources) + ID string // DC/rack/node ID + Level string // "dc", "rack", or "node" + Excess int // Number of excess shards (above target) + Shards []int // Shard IDs at this level + Nodes []*TopologyNode // Nodes at this level (for finding sources) } // CalculateDCExcess returns DCs with more shards than the target @@ -238,4 +238,3 @@ func CalculateUnderservedRacks(analysis *TopologyAnalysis, dc string, targetPerR return underserved } - diff --git a/weed/storage/erasure_coding/distribution/distribution.go b/weed/storage/erasure_coding/distribution/distribution.go index a49f10a1e..03deea710 100644 --- a/weed/storage/erasure_coding/distribution/distribution.go +++ b/weed/storage/erasure_coding/distribution/distribution.go @@ -158,4 +158,3 @@ func ceilDivide(a, b int) int { } return (a + b - 1) / b } - diff --git a/weed/storage/erasure_coding/distribution/rebalancer.go b/weed/storage/erasure_coding/distribution/rebalancer.go index 17fc41b23..cd8b87de6 100644 --- a/weed/storage/erasure_coding/distribution/rebalancer.go +++ b/weed/storage/erasure_coding/distribution/rebalancer.go @@ -26,8 +26,8 @@ type RebalancePlan struct { Analysis *TopologyAnalysis // Statistics - TotalMoves int - MovesAcrossDC int + TotalMoves int + MovesAcrossDC int MovesAcrossRack int MovesWithinRack int } @@ -54,8 +54,8 @@ func (p *RebalancePlan) DetailedString() string { // Rebalancer plans shard moves to achieve proportional distribution type Rebalancer struct { - ecConfig ECConfig - repConfig ReplicationConfig + ecConfig ECConfig + repConfig ReplicationConfig } // NewRebalancer creates a new rebalancer with the given configuration @@ -375,4 +375,3 @@ func (r *Rebalancer) applyMovesToAnalysis(analysis *TopologyAnalysis, moves []Sh // Counts are already updated by the individual planners. // This function is kept for API compatibility and potential future use. } - diff --git a/weed/storage/erasure_coding/ec_test.go b/weed/storage/erasure_coding/ec_test.go index cbb20832c..0930d1b01 100644 --- a/weed/storage/erasure_coding/ec_test.go +++ b/weed/storage/erasure_coding/ec_test.go @@ -3,11 +3,12 @@ package erasure_coding import ( "bytes" "fmt" - "github.com/stretchr/testify/assert" "math/rand" "os" "testing" + "github.com/stretchr/testify/assert" + "github.com/klauspost/reedsolomon" "github.com/seaweedfs/seaweedfs/weed/storage/needle_map" diff --git a/weed/storage/erasure_coding/placement/placement_test.go b/weed/storage/erasure_coding/placement/placement_test.go index 6cb94a4da..7501dfa9e 100644 --- a/weed/storage/erasure_coding/placement/placement_test.go +++ b/weed/storage/erasure_coding/placement/placement_test.go @@ -1,7 +1,7 @@ package placement import ( -"testing" + "testing" ) // Helper function to create disk candidates for testing @@ -402,19 +402,19 @@ func TestCalculateIdealDistribution(t *testing.T) { expectedMin int expectedMax int }{ - {14, 7, 2, 2}, // Even distribution - {14, 4, 3, 4}, // Uneven: 14/4 = 3 remainder 2 - {6, 3, 2, 2}, // Even distribution - {7, 3, 2, 3}, // Uneven: 7/3 = 2 remainder 1 - {10, 0, 0, 10}, // Edge case: no servers - {0, 5, 0, 0}, // Edge case: no shards + {14, 7, 2, 2}, // Even distribution + {14, 4, 3, 4}, // Uneven: 14/4 = 3 remainder 2 + {6, 3, 2, 2}, // Even distribution + {7, 3, 2, 3}, // Uneven: 7/3 = 2 remainder 1 + {10, 0, 0, 10}, // Edge case: no servers + {0, 5, 0, 0}, // Edge case: no shards } for _, tt := range tests { min, max := CalculateIdealDistribution(tt.totalShards, tt.numServers) if min != tt.expectedMin || max != tt.expectedMax { t.Errorf("CalculateIdealDistribution(%d, %d) = (%d, %d), want (%d, %d)", -tt.totalShards, tt.numServers, min, max, tt.expectedMin, tt.expectedMax) + tt.totalShards, tt.numServers, min, max, tt.expectedMin, tt.expectedMax) } } } diff --git a/weed/storage/needle/file_id_test.go b/weed/storage/needle/file_id_test.go index 2796470aa..191c4aa96 100644 --- a/weed/storage/needle/file_id_test.go +++ b/weed/storage/needle/file_id_test.go @@ -1,8 +1,9 @@ package needle import ( - "github.com/seaweedfs/seaweedfs/weed/storage/types" "testing" + + "github.com/seaweedfs/seaweedfs/weed/storage/types" ) func TestParseFileIdFromString(t *testing.T) { diff --git a/weed/storage/types/needle_id_type.go b/weed/storage/types/needle_id_type.go index 1ea9b0a1a..a927b6e3c 100644 --- a/weed/storage/types/needle_id_type.go +++ b/weed/storage/types/needle_id_type.go @@ -2,8 +2,9 @@ package types import ( "fmt" - "github.com/seaweedfs/seaweedfs/weed/util" "strconv" + + "github.com/seaweedfs/seaweedfs/weed/util" ) type NeedleId uint64 diff --git a/weed/storage/volume_checking.go b/weed/storage/volume_checking.go index 6f21c7dcd..7ac63d6f0 100644 --- a/weed/storage/volume_checking.go +++ b/weed/storage/volume_checking.go @@ -2,7 +2,6 @@ package storage import ( "fmt" - "github.com/seaweedfs/seaweedfs/weed/storage/super_block" "io" "os" @@ -10,6 +9,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/storage/backend" "github.com/seaweedfs/seaweedfs/weed/storage/idx" "github.com/seaweedfs/seaweedfs/weed/storage/needle" + "github.com/seaweedfs/seaweedfs/weed/storage/super_block" . "github.com/seaweedfs/seaweedfs/weed/storage/types" "github.com/seaweedfs/seaweedfs/weed/util" ) diff --git a/weed/storage/volume_info/volume_info.go b/weed/storage/volume_info/volume_info.go index 75cbc1472..19b1d336e 100644 --- a/weed/storage/volume_info/volume_info.go +++ b/weed/storage/volume_info/volume_info.go @@ -2,7 +2,6 @@ package volume_info import ( "fmt" - jsonpb "google.golang.org/protobuf/encoding/protojson" "os" "github.com/seaweedfs/seaweedfs/weed/glog" @@ -10,6 +9,7 @@ import ( _ "github.com/seaweedfs/seaweedfs/weed/storage/backend/rclone_backend" _ "github.com/seaweedfs/seaweedfs/weed/storage/backend/s3_backend" "github.com/seaweedfs/seaweedfs/weed/util" + jsonpb "google.golang.org/protobuf/encoding/protojson" ) // MaybeLoadVolumeInfo load the file data as *volume_server_pb.VolumeInfo, the returned volumeInfo will not be nil diff --git a/weed/topology/cluster_commands.go b/weed/topology/cluster_commands.go index 2546702e5..3e4b44648 100644 --- a/weed/topology/cluster_commands.go +++ b/weed/topology/cluster_commands.go @@ -3,6 +3,7 @@ package topology import ( "encoding/json" "fmt" + hashicorpRaft "github.com/hashicorp/raft" "github.com/seaweedfs/raft" "github.com/seaweedfs/seaweedfs/weed/glog" diff --git a/weed/topology/collection.go b/weed/topology/collection.go index e197ce1a2..69538a495 100644 --- a/weed/topology/collection.go +++ b/weed/topology/collection.go @@ -2,6 +2,7 @@ package topology import ( "fmt" + "github.com/seaweedfs/seaweedfs/weed/storage/types" "github.com/seaweedfs/seaweedfs/weed/storage/needle" diff --git a/weed/topology/store_replicate.go b/weed/topology/store_replicate.go index c6386eeb7..d6c774d31 100644 --- a/weed/topology/store_replicate.go +++ b/weed/topology/store_replicate.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "google.golang.org/grpc" "net/http" "net/url" "strconv" @@ -22,6 +21,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/util" "github.com/seaweedfs/seaweedfs/weed/util/buffer_pool" util_http "github.com/seaweedfs/seaweedfs/weed/util/http" + "google.golang.org/grpc" ) func ReplicatedWrite(ctx context.Context, masterFn operation.GetMasterFn, grpcDialOption grpc.DialOption, s *storage.Store, volumeId needle.VolumeId, n *needle.Needle, r *http.Request, contentMd5 string) (isUnchanged bool, err error) { diff --git a/weed/topology/topology_info.go b/weed/topology/topology_info.go index 9c0a14991..5749f8669 100644 --- a/weed/topology/topology_info.go +++ b/weed/topology/topology_info.go @@ -1,9 +1,10 @@ package topology import ( - "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "slices" "strings" + + "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" ) type TopologyInfo struct { diff --git a/weed/util/chunk_cache/chunk_cache_in_memory.go b/weed/util/chunk_cache/chunk_cache_in_memory.go index dd101996e..0f35225f5 100644 --- a/weed/util/chunk_cache/chunk_cache_in_memory.go +++ b/weed/util/chunk_cache/chunk_cache_in_memory.go @@ -1,8 +1,9 @@ package chunk_cache import ( - "github.com/karlseguin/ccache/v2" "time" + + "github.com/karlseguin/ccache/v2" ) var ( diff --git a/weed/util/chunk_cache/on_disk_cache_layer.go b/weed/util/chunk_cache/on_disk_cache_layer.go index fdbaef7c2..3258428e1 100644 --- a/weed/util/chunk_cache/on_disk_cache_layer.go +++ b/weed/util/chunk_cache/on_disk_cache_layer.go @@ -2,11 +2,12 @@ package chunk_cache import ( "fmt" + "path" + "slices" + "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/storage" "github.com/seaweedfs/seaweedfs/weed/storage/types" - "path" - "slices" ) type OnDiskCacheLayer struct { diff --git a/weed/util/file_util.go b/weed/util/file_util.go index 430b6bc86..6c5f33a24 100644 --- a/weed/util/file_util.go +++ b/weed/util/file_util.go @@ -5,12 +5,13 @@ import ( "crypto/sha256" "errors" "fmt" - "github.com/seaweedfs/seaweedfs/weed/glog" "os" "os/user" "path/filepath" "strings" "time" + + "github.com/seaweedfs/seaweedfs/weed/glog" ) const maxFilenameLength = 255 diff --git a/weed/util/grace/signal_handling.go b/weed/util/grace/signal_handling.go index 0fc0f43e1..a661f939c 100644 --- a/weed/util/grace/signal_handling.go +++ b/weed/util/grace/signal_handling.go @@ -4,13 +4,14 @@ package grace import ( - "github.com/seaweedfs/seaweedfs/weed/glog" "os" "os/signal" "reflect" "runtime" "sync" "syscall" + + "github.com/seaweedfs/seaweedfs/weed/glog" ) var signalChan chan os.Signal diff --git a/weed/util/http/client/http_client.go b/weed/util/http/client/http_client.go index d1d2f5c56..661df582e 100644 --- a/weed/util/http/client/http_client.go +++ b/weed/util/http/client/http_client.go @@ -4,14 +4,15 @@ import ( "crypto/tls" "crypto/x509" "fmt" - util "github.com/seaweedfs/seaweedfs/weed/util" - "github.com/spf13/viper" "io" "net/http" "net/url" "os" "strings" "sync" + + util "github.com/seaweedfs/seaweedfs/weed/util" + "github.com/spf13/viper" ) var ( diff --git a/weed/util/inits_test.go b/weed/util/inits_test.go index f2c9b701f..3334d012a 100644 --- a/weed/util/inits_test.go +++ b/weed/util/inits_test.go @@ -1,8 +1,9 @@ package util import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestHumanReadableIntsMax(t *testing.T) { diff --git a/weed/util/limited_async_pool_test.go b/weed/util/limited_async_pool_test.go index 090ce5375..1289f4f33 100644 --- a/weed/util/limited_async_pool_test.go +++ b/weed/util/limited_async_pool_test.go @@ -2,10 +2,11 @@ package util import ( "fmt" - "github.com/stretchr/testify/assert" "sort" "testing" "time" + + "github.com/stretchr/testify/assert" ) func TestAsyncPool(t *testing.T) { diff --git a/weed/util/log_buffer/log_read.go b/weed/util/log_buffer/log_read.go index e47034d87..dfc91cb25 100644 --- a/weed/util/log_buffer/log_read.go +++ b/weed/util/log_buffer/log_read.go @@ -75,9 +75,9 @@ func (logBuffer *LogBuffer) LoopProcessLogData(readerName string, startPosition } bytesBuf, batchIndex, err = logBuffer.ReadFromBuffer(lastReadPosition) if err == ResumeFromDiskError { - // Try to read from disk if readFromDiskFn is available - if logBuffer.ReadFromDiskFn != nil { - lastReadPosition, isDone, err = logBuffer.ReadFromDiskFn(lastReadPosition, stopTsNs, eachLogDataFn) + // Try to read from disk if readFromDiskFn is available + if logBuffer.ReadFromDiskFn != nil { + lastReadPosition, isDone, err = logBuffer.ReadFromDiskFn(lastReadPosition, stopTsNs, eachLogDataFn) if err != nil { return lastReadPosition, isDone, err } diff --git a/weed/util/mem/slot_pool_test.go b/weed/util/mem/slot_pool_test.go index 44f9ec004..d457a7490 100644 --- a/weed/util/mem/slot_pool_test.go +++ b/weed/util/mem/slot_pool_test.go @@ -1,8 +1,9 @@ package mem import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestAllocateFree(t *testing.T) { diff --git a/weed/util/minfreespace.go b/weed/util/minfreespace.go index 0c4461ff1..9fd041ddc 100644 --- a/weed/util/minfreespace.go +++ b/weed/util/minfreespace.go @@ -3,9 +3,10 @@ package util import ( "errors" "fmt" - "github.com/seaweedfs/seaweedfs/weed/glog" "strconv" "strings" + + "github.com/seaweedfs/seaweedfs/weed/glog" ) // MinFreeSpaceType is the type of MinFreeSpace. diff --git a/weed/util/queue_test.go b/weed/util/queue_test.go index a79552893..39fa7410f 100644 --- a/weed/util/queue_test.go +++ b/weed/util/queue_test.go @@ -1,8 +1,9 @@ package util import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestNewQueue(t *testing.T) { diff --git a/weed/util/skiplist/name_batch.go b/weed/util/skiplist/name_batch.go index 1ab2a6b1f..c0a759f3a 100644 --- a/weed/util/skiplist/name_batch.go +++ b/weed/util/skiplist/name_batch.go @@ -1,10 +1,11 @@ package skiplist import ( - "github.com/seaweedfs/seaweedfs/weed/glog" - "google.golang.org/protobuf/proto" "slices" "strings" + + "github.com/seaweedfs/seaweedfs/weed/glog" + "google.golang.org/protobuf/proto" ) type NameBatch struct { diff --git a/weed/util/skiplist/skiplist.pb.go b/weed/util/skiplist/skiplist.pb.go index de3efa513..09a9dab9a 100644 --- a/weed/util/skiplist/skiplist.pb.go +++ b/weed/util/skiplist/skiplist.pb.go @@ -7,10 +7,11 @@ package skiplist import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/weed/wdclient/masterclient_test.go b/weed/wdclient/masterclient_test.go index bf992e884..e19ce9e80 100644 --- a/weed/wdclient/masterclient_test.go +++ b/weed/wdclient/masterclient_test.go @@ -101,5 +101,3 @@ func TestMasterClientFilerGroupLogging(t *testing.T) { t.Errorf("Expected clientType %s, got %s", clientType, mc.clientType) } } - - diff --git a/weed/wdclient/net2/managed_connection.go b/weed/wdclient/net2/managed_connection.go index a0cc4f358..d4696739e 100644 --- a/weed/wdclient/net2/managed_connection.go +++ b/weed/wdclient/net2/managed_connection.go @@ -6,6 +6,7 @@ import ( "time" "errors" + "github.com/seaweedfs/seaweedfs/weed/wdclient/resource_pool" ) diff --git a/weed/wdclient/vid_map_test.go b/weed/wdclient/vid_map_test.go index a734c6b0c..7a828fdad 100644 --- a/weed/wdclient/vid_map_test.go +++ b/weed/wdclient/vid_map_test.go @@ -3,12 +3,13 @@ package wdclient import ( "context" "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb" - "google.golang.org/grpc" "strconv" "sync" "testing" "time" + + "github.com/seaweedfs/seaweedfs/weed/pb" + "google.golang.org/grpc" ) func TestLocationIndex(t *testing.T) {