aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2025-11-05 18:14:55 +0500
committerKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2025-11-05 18:14:55 +0500
commit20fb1ead7712fae8e91a434d93c21588a6645b72 (patch)
tree878b0c3fdb7ce7f9969e03fc09c8ef090c71edb7
parenta88eab0b9719540116fb0bca38900e7fe7d36fd9 (diff)
downloadseaweedfs-20fb1ead7712fae8e91a434d93c21588a6645b72.tar.xz
seaweedfs-20fb1ead7712fae8e91a434d93c21588a6645b72.zip
fix updateTTL
-rw-r--r--.github/workflows/s3tests.yml5
-rw-r--r--weed/filer/filer.go5
-rw-r--r--weed/s3api/filer_util.go4
-rw-r--r--weed/s3api/s3api_object_handlers_list.go2
4 files changed, 13 insertions, 3 deletions
diff --git a/.github/workflows/s3tests.yml b/.github/workflows/s3tests.yml
index 74c1d4610..77b70426f 100644
--- a/.github/workflows/s3tests.yml
+++ b/.github/workflows/s3tests.yml
@@ -1126,7 +1126,10 @@ jobs:
s3tests/functional/test_s3.py::test_copy_object_ifnonematch_good \
s3tests/functional/test_s3.py::test_lifecycle_set \
s3tests/functional/test_s3.py::test_lifecycle_get \
- s3tests/functional/test_s3.py::test_lifecycle_set_filter
+ s3tests/functional/test_s3.py::test_lifecycle_set_filter \
+ s3tests/functional/test_s3.py::test_lifecycle_expiration \
+ s3tests/functional/test_s3.py::test_lifecyclev2_expiration \
+ s3tests/functional/test_s3.py::test_lifecycle_expiration_versioning_enabled
kill -9 $pid || true
# Clean up data directory
rm -rf "$WEED_DATA_DIR" || true
diff --git a/weed/filer/filer.go b/weed/filer/filer.go
index e92c81bbe..5671c1970 100644
--- a/weed/filer/filer.go
+++ b/weed/filer/filer.go
@@ -380,10 +380,13 @@ func (f *Filer) doListDirectoryEntries(ctx context.Context, p util.FullPath, sta
if delErr := f.doDeleteEntryMetaAndData(ctx, entry, false, true, nil); delErr != nil {
glog.ErrorfCtx(ctx, "doListDirectoryEntries doDeleteEntryMetaAndData %s failed: %v", entry.FullPath, delErr)
}
+ expiredCount++
return true
}
} else if entry.Crtime.Add(time.Duration(entry.TtlSec) * time.Second).Before(time.Now()) {
- f.Store.DeleteOneEntry(ctx, entry)
+ if delErr := f.Store.DeleteOneEntry(ctx, entry); delErr != nil {
+ glog.ErrorfCtx(ctx, "doListDirectoryEntries DeleteOneEntry %s failed: %v", entry.FullPath, delErr)
+ }
expiredCount++
return true
}
diff --git a/weed/s3api/filer_util.go b/weed/s3api/filer_util.go
index e02b945cd..6cc40f25e 100644
--- a/weed/s3api/filer_util.go
+++ b/weed/s3api/filer_util.go
@@ -3,6 +3,7 @@ package s3api
import (
"context"
"fmt"
+ "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
"math"
"strings"
@@ -114,11 +115,12 @@ func (s3a *S3ApiServer) updateEntriesTTL(parentDirectoryPath string, ttlSec int3
ctx := context.Background()
err := filer_pb.SeaweedList(ctx, client, parentDirectoryPath, "", func(entry *filer_pb.Entry, isLast bool) error {
if entry.IsDirectory {
- return s3a.updateEntriesTTL(fmt.Sprintf("%s/%s", parentDirectoryPath, entry.Name), ttlSec)
+ return s3a.updateEntriesTTL(fmt.Sprintf("%s/%s", strings.TrimRight(parentDirectoryPath, "/"), entry.Name), ttlSec)
}
if entry.Attributes == nil {
entry.Attributes = &filer_pb.FuseAttributes{}
}
+ entry.Extended[s3_constants.SeaweedFSExpiresS3] = []byte("true")
if entry.Attributes.TtlSec == ttlSec {
return nil
}
diff --git a/weed/s3api/s3api_object_handlers_list.go b/weed/s3api/s3api_object_handlers_list.go
index 9e6376a0e..ac212272c 100644
--- a/weed/s3api/s3api_object_handlers_list.go
+++ b/weed/s3api/s3api_object_handlers_list.go
@@ -141,8 +141,10 @@ func (s3a *S3ApiServer) ListObjectsV1Handler(w http.ResponseWriter, r *http.Requ
// Adjust marker if it ends with delimiter to skip all entries with that prefix
marker = adjustMarkerForDelimiter(marker, delimiter)
+ glog.V(3).Infof("Start listFilerEntries %s", originalPrefix)
response, err := s3a.listFilerEntries(bucket, originalPrefix, uint16(maxKeys), marker, delimiter, encodingTypeUrl, true)
+ glog.V(3).Infof("End listFilerEntries %s", originalPrefix)
if err != nil {
s3err.WriteErrorResponse(w, r, s3err.ErrInternalError)