Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MaxNoncurrentVersions to NoncurrentExpiration action #13580

Merged
merged 8 commits into from Nov 20, 2021

Conversation

krisis
Copy link
Member

@krisis krisis commented Nov 4, 2021

Description

This unit allows users to limit the maximum number of noncurrent versions of an
object.

Motivation and Context

To limit number of noncurrent versions of an object.

How to test this PR?

#!/bin/bash

ALIAS=$1

./mc mb $ALIAS/mybucket
./mc version enable $ALIAS/mybucket
for i in {1..10}
do
   ./mc cp /etc/issue $ALIAS/mybucket/obj-1
done
cat <<EOF | ./mc ilm import $ALIAS/mybucket
{
    "Rules": [
        {
            "ID": "test-max-noncurrent",
            "Status": "Enabled",
            "Filter": {},
            "NoncurrentVersionExpiration": {
                "MaxNoncurrentVersions": 5
            }
        }
    ]
}
EOF

bash -x <above-script.sh> myminio

Now, perform mc cp to upload a new version and trigger the removal of excess noncurrent versions as configured.

This requires mc compiled with minio/minio-go#1580

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Optimization (provides speedup with no functional changes)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Fixes a regression (If yes, please add commit-id or PR # here)
  • Documentation updated
  • Unit tests added/updated

Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments

internal/bucket/lifecycle/lifecycle.go Show resolved Hide resolved
cmd/object-handlers-common.go Outdated Show resolved Hide resolved
cmd/object-handlers-common.go Outdated Show resolved Hide resolved
internal/bucket/lifecycle/expiration.go Outdated Show resolved Hide resolved
cmd/object-handlers-common.go Outdated Show resolved Hide resolved
cmd/object-handlers-common.go Outdated Show resolved Hide resolved
cmd/object-handlers-common.go Outdated Show resolved Hide resolved
@harshavardhana
Copy link
Member

@klauspost the main idea here was to deliver this fix first and then subsequently take time to merge the format change and optimize this part further.

This is also an opt-in where Max value is only set this should tax the Put() with reasonable reasoning.

@krisis
Copy link
Member Author

krisis commented Nov 10, 2021

@klauspost To summarize the changes I have made in this PR since your last comment, I have implemented a scanner callback (as suggested) which removes noncurrent versions keeping only most recent MaxNoncurrentVersions configured.

I have retained the less performant codepath invoked by the upload handlers. This is not active by default. It can be enabled via an env var (MINIO_API_ILM_INLINE). This is for those workloads where the same object is updated many times over within a full namespace scan (16 cycles). This shall be used only when we observe such a workload.

Once #13573 is merged, we can improve performance of this codepath, or even remove it.

cmd/object-handlers-common.go Outdated Show resolved Hide resolved
cmd/object-handlers-common.go Outdated Show resolved Hide resolved
cmd/data-scanner.go Outdated Show resolved Hide resolved
cmd/object-handlers-common.go Outdated Show resolved Hide resolved
cmd/object-handlers-common.go Outdated Show resolved Hide resolved
@harshavardhana

This comment has been minimized.

@krisis krisis force-pushed the feat-noncurrent-expiry branch 3 times, most recently from b0c3e0d to 0cc60d9 Compare November 11, 2021 05:02
@harshavardhana
Copy link
Member

@krisis can you rebase this PR on top of the newer changes?

cmd/data-scanner.go Outdated Show resolved Hide resolved
cmd/storage-datatypes.go Show resolved Hide resolved
cmd/api-errors.go Outdated Show resolved Hide resolved
cmd/storage-rest-common.go Show resolved Hide resolved
cmd/xl-storage-format-utils.go Show resolved Hide resolved
Copy link
Member

@harshavardhana harshavardhana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment everything else LGTM and tested

krisis and others added 7 commits November 19, 2021 16:05
This unit allows users to limit the maximum number of noncurrent versions of an
object.

To enable this rule,
```
cat <<EOF | ./mc ilm import myminio/mybucket
{
    "Rules": [
        {
            "ID": "test-max-noncurrent",
            "Status": "Enabled",
            "Filter": {
                "Prefix": "user-uploads/"
            },
            "NoncurrentVersionExpiration": {
                "MaxNoncurrentVersions": 5
            }
        }
    ]
}
EOF
@minio-trusted
Copy link
Contributor

Mint Automation

Test Result
mint-large-bucket.sh ✔️
mint-fs.sh ✔️
mint-gateway-s3.sh ✔️
mint-erasure.sh ✔️
mint-dist-erasure.sh ✔️
mint-gateway-nas.sh ✔️
mint-compress-encrypt-dist-erasure.sh ✔️
mint-pools.sh ✔️
Deleting image on docker hub
Deleting image locally

@harshavardhana harshavardhana merged commit 3da9ee1 into minio:master Nov 20, 2021
rbuchnajzer pushed a commit to rbuchnajzer/minio that referenced this pull request Dec 7, 2021
This unit allows users to limit the maximum number of noncurrent 
versions of an object.

To enable this rule you need the following *ilm.json*
```
cat >> ilm.json <<EOF
{
    "Rules": [
        {
            "ID": "test-max-noncurrent",
            "Status": "Enabled",
            "Filter": {
                "Prefix": "user-uploads/"
            },
            "NoncurrentVersionExpiration": {
                "MaxNoncurrentVersions": 5
            }
        }
    ]
}
EOF
mc ilm import myminio/mybucket < ilm.json
```
tristanessquare pushed a commit to iternity-dotcom/minio that referenced this pull request Jan 27, 2022
This unit allows users to limit the maximum number of noncurrent
versions of an object.

To enable this rule you need the following *ilm.json*
```
cat >> ilm.json <<EOF
{
    "Rules": [
        {
            "ID": "test-max-noncurrent",
            "Status": "Enabled",
            "Filter": {
                "Prefix": "user-uploads/"
            },
            "NoncurrentVersionExpiration": {
                "MaxNoncurrentVersions": 5
            }
        }
    ]
}
EOF
mc ilm import myminio/mybucket < ilm.json
```
tristanessquare pushed a commit to iternity-dotcom/minio that referenced this pull request Feb 11, 2022
This unit allows users to limit the maximum number of noncurrent
versions of an object.

To enable this rule you need the following *ilm.json*
```
cat >> ilm.json <<EOF
{
    "Rules": [
        {
            "ID": "test-max-noncurrent",
            "Status": "Enabled",
            "Filter": {
                "Prefix": "user-uploads/"
            },
            "NoncurrentVersionExpiration": {
                "MaxNoncurrentVersions": 5
            }
        }
    ]
}
EOF
mc ilm import myminio/mybucket < ilm.json
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants