Some checks failed
go: build dev binaries / cleanup (push) Successful in 4s
Codespell / Check for spelling errors (push) Failing after 3s
docker: build dev containers / build-rust-binaries (amd64, x86_64-unknown-linux-musl) (push) Failing after 3s
docker: build dev containers / build-dev-containers (push) Has been skipped
docker: build dev containers / build-rust-binaries (arm64, true, aarch64-unknown-linux-musl) (push) Failing after 3s
End to End / FUSE Mount (push) Failing after 2s
EC Integration Tests / EC Integration Tests (push) Failing after 30s
FUSE DLM Integration Tests / FUSE DLM Integration Tests (push) Failing after 3s
FUSE Volume Server Failover Tests / FUSE Volume Server Failover (push) Failing after 3s
FUSE Integration Tests / FUSE Integration Testing (push) Failing after 2s
FUSE P2P Peer Chunk Sharing Integration Tests / FUSE P2P Peer Chunk Sharing (push) Failing after 3s
go: build binary / Go Vet (push) Failing after 2s
go: build binary / Go Vet 32-bit (push) Failing after 3s
go: build binary / Build (push) Failing after 4s
go: build binary / Build cross-platform (freebsd/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (darwin/arm64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/arm64) (push) Failing after 3s
go: build binary / Test (push) Failing after 2s
go: build binary / Test 32-bit (push) Failing after 3s
helm: lint and test charts / lint-test (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (11) (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (17) (push) Failing after 3s
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Failing after 2s
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Failing after 3s
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Has been skipped
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Has been skipped
Java Client Unit Tests / Java Unit Tests (11) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (17) (push) Failing after 2s
Java Client Unit Tests / Java Unit Tests (21) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (8) (push) Failing after 3s
Kafka Quick Test (Load Test with Schema Registry) / Kafka Client Load Test (Quick) (push) Failing after 3s
Kafka Gateway Tests / Kafka Unit Tests (unit-tests-1) (push) Failing after 11s
Kafka Gateway Tests / Kafka Integration Tests (Critical) (integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka End-to-End Tests (with SMQ) (e2e-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Consumer Group Tests (Highly Isolated) (consumer-group-1) (push) Failing after 2s
Kafka Gateway Tests / Kafka Client Compatibility (with SMQ) (client-compat-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka SMQ Integration Tests (Full Stack) (smq-integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Protocol Tests (Isolated) (protocol-1) (push) Failing after 3s
KMS Tests / KMS Provider Integration Tests (push) Failing after 2s
KMS Tests / S3 KMS End-to-End Tests (push) Failing after 3s
Master Cold Start Tests / Master Cold Start Tests (push) Failing after 4s
Metadata Subscribe Integration Tests / Metadata Subscribe Integration Tests (push) Failing after 3s
Multi-Master Tests / Multi-Master Failover Tests (push) Failing after 3s
Performance / CPU and Heap Profile (push) Failing after 2s
Performance / S3 Read/Write Benchmark (rust volume) (push) Failing after 3s
pjdfstest POSIX Compliance / pjdfstest (push) Failing after 2s
Plugin Worker Integration Tests / Plugin Worker: erasure_coding (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: vacuum (push) Failing after 3s
Rust Volume Server Tests / Rust Integration Tests (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 1) (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 1) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 3) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Distributed Tests (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Performance Tests (push) Failing after 3s
Performance / Throughput Benchmark (go volume) (push) Failing after 3s
Performance / Throughput Benchmark (rust volume) (push) Failing after 2s
Performance / S3 Read/Write Benchmark (go volume) (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: volume_balance (push) Failing after 3s
PostgreSQL Gateway Tests / PostgreSQL Basic Tests (push) Failing after 3s
Rust Volume Server Tests / Rust Unit Tests (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 3) (push) Failing after 3s
Rust Plugin Worker Tests / Rust Plugin Worker Build and Unit Tests (push) Failing after 3s
rust: build dev volume server binaries / cleanup (push) Successful in 3s
S3 ETag and ACL Tests / S3 ETag + ACL Integration Tests (push) Failing after 3s
S3 IAM Integration Tests / IAM Unit Tests (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (advanced) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (basic) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (group) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (policy-enforcement) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (sts) (push) Failing after 4s
S3 Keycloak Integration Tests / S3 Keycloak Integration Tests (push) Failing after 3s
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.11) (push) Failing after 3s
S3 PyArrow Parquet Tests / Go Unit Tests (Implicit Directory) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.12) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-amd64, x86_64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-arm64, aarch64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-linux (linux-amd64, x86_64-unknown-linux-gnu) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.9) (push) Has been cancelled
S3 Proxy Signature Tests / S3 Proxy Signature Verification Tests (push) Has been cancelled
S3 SDK V2 Route Disambiguation Tests / S3 SDK V2 Routing Tests (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (quick) (push) Has been cancelled
S3 SSE Tests / S3 SSE Compatibility Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Metadata Persistence Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Copy Operations Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Multipart Upload Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Performance Test (push) Has been cancelled
S3 SSE Tests / S3 Volume Encryption Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (comprehensive) (push) Has been cancelled
Spark Integration Tests / Spark Integration Tests (push) Failing after 2s
Telemetry Integration Tests / telemetry-integration-test (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 1) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 1) (push) Failing after 3s
Ceph S3 tests / Basic S3 tests (KV store) (push) Has been cancelled
Ceph S3 tests / S3 Versioning & Object Lock tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Unit Tests (push) Failing after 3s
Ceph S3 tests / S3 CORS tests (push) Has been cancelled
Ceph S3 tests / SeaweedFS Custom S3 Copy tests (push) Has been cancelled
Ceph S3 tests / Basic S3 tests (SQL store) (push) Has been cancelled
test s3 over https using aws-cli / awscli-tests (push) Has been cancelled
TLS Rotation Integration Tests / TLS Rotation Integration Tests (push) Has been cancelled
Vacuum Integration Tests / Vacuum Integration Tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Variables Integration Tests (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (advanced-policy) (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (basic-policy) (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (contextual-policy) (push) Failing after 4s
S3 Policy Integration Tests / Trusted Proxy Detection Tests (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Shell Integration Tests (push) Failing after 3s
Samba on FUSE Integration / samba-integration (push) Failing after 2s
SFTP Integration Tests / SFTP Integration Testing (push) Failing after 3s
terraform: validate and test modules / fmt, validate, plan-level tests (push) Failing after 3s
terraform: validate and test modules / local cluster smoke test (real weed) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 3) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 2) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 2) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 3) (push) Failing after 5s
mount: windows conformance / WinFsp conformance (push) Has been cancelled
mount: windows / Mount on Windows (push) Has been cancelled
233 lines
5.4 KiB
Go
233 lines
5.4 KiB
Go
package filer
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
|
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
|
)
|
|
|
|
type Attr struct {
|
|
Mtime time.Time // time of last modification
|
|
Crtime time.Time // time of creation (OS X only)
|
|
Ctime time.Time // time of last inode change
|
|
Atime time.Time // time of last access
|
|
Mode os.FileMode // file mode
|
|
Uid uint32 // owner uid
|
|
Gid uint32 // group gid
|
|
Mime string // mime type
|
|
TtlSec int32 // ttl in seconds
|
|
UserName string
|
|
GroupNames []string
|
|
SymlinkTarget string
|
|
Md5 []byte
|
|
FileSize uint64
|
|
Rdev uint32
|
|
Inode uint64
|
|
}
|
|
|
|
func (attr Attr) IsDirectory() bool {
|
|
return attr.Mode&os.ModeDir > 0
|
|
}
|
|
|
|
type Entry struct {
|
|
util.FullPath
|
|
|
|
Attr
|
|
Extended map[string][]byte
|
|
|
|
// the following is for files
|
|
Chunks []*filer_pb.FileChunk `json:"chunks,omitempty"`
|
|
|
|
HardLinkId HardLinkId
|
|
HardLinkCounter int32
|
|
Content []byte
|
|
Remote *filer_pb.RemoteEntry
|
|
Quota int64
|
|
WORMEnforcedAtTsNs int64
|
|
}
|
|
|
|
func (entry *Entry) Size() uint64 {
|
|
return maxUint64(maxUint64(TotalSize(entry.GetChunks()), entry.FileSize), uint64(len(entry.Content)))
|
|
}
|
|
|
|
func (entry *Entry) Timestamp() time.Time {
|
|
if entry.IsDirectory() {
|
|
return entry.Crtime
|
|
} else {
|
|
return entry.Mtime
|
|
}
|
|
}
|
|
|
|
func (entry *Entry) ShallowClone() *Entry {
|
|
if entry == nil {
|
|
return nil
|
|
}
|
|
newEntry := &Entry{}
|
|
newEntry.FullPath = entry.FullPath
|
|
newEntry.Attr = entry.Attr
|
|
newEntry.Chunks = entry.Chunks
|
|
newEntry.Extended = entry.Extended
|
|
newEntry.HardLinkId = entry.HardLinkId
|
|
newEntry.HardLinkCounter = entry.HardLinkCounter
|
|
newEntry.Content = entry.Content
|
|
newEntry.Remote = entry.Remote
|
|
newEntry.Quota = entry.Quota
|
|
|
|
return newEntry
|
|
}
|
|
|
|
func (entry *Entry) ToProtoEntry() *filer_pb.Entry {
|
|
if entry == nil {
|
|
return nil
|
|
}
|
|
message := &filer_pb.Entry{}
|
|
message.Name = entry.FullPath.Name()
|
|
entry.ToExistingProtoEntry(message)
|
|
return message
|
|
}
|
|
|
|
func (entry *Entry) ToExistingProtoEntry(message *filer_pb.Entry) {
|
|
if entry == nil {
|
|
return
|
|
}
|
|
message.IsDirectory = entry.IsDirectory()
|
|
// Reuse pre-allocated attributes if available, otherwise allocate
|
|
if message.Attributes != nil {
|
|
EntryAttributeToExistingPb(entry, message.Attributes)
|
|
} else {
|
|
message.Attributes = EntryAttributeToPb(entry)
|
|
}
|
|
message.Chunks = entry.GetChunks()
|
|
message.Extended = entry.Extended
|
|
message.HardLinkId = entry.HardLinkId
|
|
message.HardLinkCounter = entry.HardLinkCounter
|
|
message.Content = entry.Content
|
|
message.RemoteEntry = entry.Remote
|
|
message.Quota = entry.Quota
|
|
message.WormEnforcedAtTsNs = entry.WORMEnforcedAtTsNs
|
|
}
|
|
|
|
func FromPbEntryToExistingEntry(message *filer_pb.Entry, fsEntry *Entry) {
|
|
fsEntry.Attr = PbToEntryAttribute(message.Attributes)
|
|
fsEntry.Chunks = message.Chunks
|
|
fsEntry.Extended = message.Extended
|
|
fsEntry.HardLinkId = HardLinkId(message.HardLinkId)
|
|
fsEntry.HardLinkCounter = message.HardLinkCounter
|
|
fsEntry.Content = message.Content
|
|
fsEntry.Remote = message.RemoteEntry
|
|
fsEntry.Quota = message.Quota
|
|
fsEntry.FileSize = FileSize(message)
|
|
fsEntry.WORMEnforcedAtTsNs = message.WormEnforcedAtTsNs
|
|
}
|
|
|
|
func (entry *Entry) ToProtoFullEntry() *filer_pb.FullEntry {
|
|
if entry == nil {
|
|
return nil
|
|
}
|
|
dir, _ := entry.FullPath.DirAndName()
|
|
return &filer_pb.FullEntry{
|
|
Dir: dir,
|
|
Entry: entry.ToProtoEntry(),
|
|
}
|
|
}
|
|
|
|
func (entry *Entry) GetChunks() []*filer_pb.FileChunk {
|
|
return entry.Chunks
|
|
}
|
|
|
|
func FromPbEntry(dir string, entry *filer_pb.Entry) *Entry {
|
|
t := &Entry{}
|
|
t.FullPath = util.NewFullPath(dir, entry.Name)
|
|
FromPbEntryToExistingEntry(entry, t)
|
|
return t
|
|
}
|
|
|
|
func maxUint64(x, y uint64) uint64 {
|
|
if x > y {
|
|
return x
|
|
}
|
|
return y
|
|
}
|
|
|
|
func (entry *Entry) IsExpireS3Enabled() (exist bool) {
|
|
if entry.Extended != nil {
|
|
_, exist = entry.Extended[s3_constants.SeaweedFSExpiresS3]
|
|
}
|
|
return exist
|
|
}
|
|
|
|
func (entry *Entry) isS3Entry() bool {
|
|
if entry.Extended == nil {
|
|
return false
|
|
}
|
|
|
|
if _, found := entry.Extended[s3_constants.ExtAmzOwnerKey]; found {
|
|
return true
|
|
}
|
|
|
|
if _, found := entry.Extended[s3_constants.ExtETagKey]; found {
|
|
return true
|
|
}
|
|
|
|
for key := range entry.Extended {
|
|
if strings.HasPrefix(key, s3_constants.ExtAmzPrefix) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// ApplyStorageTtl stamps the TTL the entry's data was placed with. Remote
|
|
// entries never expire locally; the remote storage owns their lifecycle.
|
|
func (entry *Entry) ApplyStorageTtl(ttlSec int32) {
|
|
if entry.Remote != nil {
|
|
ttlSec = 0
|
|
}
|
|
entry.TtlSec = ttlSec
|
|
entry.ApplyS3ExpiryMetadata()
|
|
}
|
|
|
|
func (entry *Entry) ApplyS3ExpiryMetadata() {
|
|
if entry.TtlSec == 0 {
|
|
return
|
|
}
|
|
|
|
if _, found := entry.Extended[s3_constants.SeaweedFSExpiresS3]; found {
|
|
return
|
|
}
|
|
|
|
// The s3 expiry path skips versioned entries, so stamping one would drop its
|
|
// expiry entirely instead of moving it onto mtime.
|
|
if entry.IsS3Versioning() {
|
|
return
|
|
}
|
|
|
|
if !entry.isS3Entry() {
|
|
return
|
|
}
|
|
|
|
entry.Extended[s3_constants.SeaweedFSExpiresS3] = []byte("true")
|
|
|
|
return
|
|
}
|
|
|
|
func (entry *Entry) IsS3Versioning() (exist bool) {
|
|
if entry.Extended != nil {
|
|
_, exist = entry.Extended[s3_constants.ExtVersionIdKey]
|
|
}
|
|
return exist
|
|
}
|
|
|
|
func (entry *Entry) GetS3ExpireTime() (expireTime time.Time) {
|
|
if entry.Mtime.IsZero() {
|
|
expireTime = entry.Crtime
|
|
} else {
|
|
expireTime = entry.Mtime
|
|
}
|
|
return expireTime.Add(time.Duration(entry.TtlSec) * time.Second)
|
|
}
|