minio / mc

Unix like utilities for object store
https://min.io/download
GNU Affero General Public License v3.0
2.86k stars 548 forks source link

Enable --expire-all-object-versions #4840

Closed shtripat closed 8 months ago

shtripat commented 9 months ago

Community Contribution License

All community contributions in this pull request are licensed to the project maintainers under the terms of the Apache 2 license. By creating this pull request I represent that I have the right to license the contributions to the project maintainers under the Apache 2 license.

Description

This PR introduces a new flag --expire-all-object-versions to the command mc ilm rule add to enabled option to create ILM rule to remove all versions of expired objects.

Motivation and Context

Allow setting ILM rule for removing all versions of expired objects from command line.

How to test this PR?

Follow below steps to verify the changes

Step-1: Set your system date to few days older (~3days)

Step-2: Create a MinIO instance, create a bucket and enable versioning for the bucket

Step-3: Set the bucket public using mc anonymous set public ALIAS/BUCKET

Step-4: Set the MinIO scanner speed to fastest using mc admin config set ALIAS scanner speed=fastest

Step-5: Load say 100 objects to the bucket using curl command with older mtime value as below

curl -X PUT http://127.0.0.1:9000/BUCKET/OBJNAME -d @PATH-TO-OBJ-SRC-FILE -H "X-Minio-Source-Mtime: 2023-03-12T16:19:03.115209866-08:00"

Step-6: Now delete these objects using mc rm which would create DEL markers for all the objects. Eventually two versions for all objects

Step-7: Set the date back to current for the system

Step-8: Add bewlo ILM rules for bucket mc ilm rule add ALIAS/BUCKET --expire-all-object-versions --expire-days 1

Step-9: After few seconds all versions of all objects should be removed and mc ls ALIAS/BUCKET --versions should not return any values.

Step:10: Also verify prometheus metrics values minio_s3_requests_total{api="putobject",server="127.0.0.1:9000"} and minio_node_ilm_action_count_delete_all_versions_action{server="127.0.0.1:9000"}. They should return 100 and 200 respectively as count values.

Note: needs: https://github.com/minio/minio-go/pull/1927 and https://github.com/minio/minio/pull/18954/

Types of changes

Checklist: