LifeCycle

This module use when data in a bucket from one storage class transfers to another storage class (usually slower HDDs) after a particular amount of time.

LifeCycle has 3 types of action: a) transition: transfer data from a storage class to another storage class (not pool) b) expiration: After a particular amount of time data is deleted. c) transition and expiration

To do this, we have 2 pools called S3.Hot and S3.Cold. S3.Hot is a replication pool with replica 3 but S3.Cold is an EC pool with 8-2 failover.

First should create a new storage class for zonegroup and zone:

radosgw-admin zonegroup placement add --rgw-zonegroup [ZONEGROUP] --rgw-zone [ZONE] --placement-id default-placement/newPLACEMENT --storage-class HOT --data-pool S3.Hot

radosgw-admin zone placement add --placement-id default-placement --storage-class HOT --data-pool S3.Fast

#Create new storage class for COLD
radosgw-admin zonegroup placement add --rgw-zonegroup [ZONEGROUP] --rgw-zone [ZONE] --placement-id default-placement/newPLACEMENT --storage-class COLD --data-pool S3.Cold

radosgw-admin zone placement add --placement-id default-placement --storage-class COLD --data-pool S3.Cold

Then check result with following commands:

#> radosgw-admin zonegroup get

#OUTPUT
{
    "id": "d46d8867-fab6-4b03-b198-470f40861053",
    "name": "ZONEGROUP",
    "api_name": "ZONEGROUP",
    "is_master": true,
    "endpoints": [],
    "hostnames": [],
    "hostnames_s3website": [],
    "master_zone": "a59fa1be-21d1-4d58-b0de-5aabc1739758",
    "zones": [
        {
            "id": "a59fa1be-21d1-4d58-b0de-5aabc1739758",
            "name": "ZONE",
            "endpoints": [
                "http://172.30.212.16:80"
            ],
            "log_meta": false,
            "log_data": false,
            "bucket_index_max_shards": 11,
            "read_only": false,
            "tier_type": "",
            "sync_from_all": true,
            "sync_from": [],
            "redirect_zone": "",
            "supported_features": [
                "compress-encrypted",
                "resharding"
            ]
        }
    ],
    "placement_targets": [
        {
            "name": "default-placement",
            "tags": [],
            "storage_classes": [
                "COLD",
                "HOT",
                "STANDARD"
            ]
        }
    ],
    "default_placement": "default-placement",
    "realm_id": "9efe536c-8282-4f79-86fa-778a0b5ad6ec",
    "sync_policy": {
        "groups": []
    },
    "enabled_features": [
        "resharding"
    ]
}


#####################################################################################
#> radosgw-admin zone get 

#OUTPUT
{
    "id": "a59fa1be-21d1-4d58-b0de-5aabc1739758",
    "name": "ZONE",
    "domain_root": "ZONE.rgw.meta:root",
    "control_pool": "ZONE.rgw.control",
    "gc_pool": "ZONE.rgw.log:gc",
    "lc_pool": "ZONE.rgw.log:lc",
    "log_pool": "ZONE.rgw.log",
    "intent_log_pool": "ZONE.rgw.log:intent",
    "usage_log_pool": "ZONE.rgw.log:usage",
    "roles_pool": "ZONE.rgw.meta:roles",
    "reshard_pool": "ZONE.rgw.log:reshard",
    "user_keys_pool": "ZONE.rgw.meta:users.keys",
    "user_email_pool": "ZONE.rgw.meta:users.email",
    "user_swift_pool": "ZONE.rgw.meta:users.swift",
    "user_uid_pool": "ZONE.rgw.meta:users.uid",
    "otp_pool": "ZONE.rgw.otp",
    "system_key": {
        "access_key": "cloud",
        "secret_key": "cloud"
    },
    "placement_pools": [
        {
            "key": "default-placement",
            "val": {
                "index_pool": "ZONE.rgw.buckets.index",
                "storage_classes": {
                    "COLD": {
                        "data_pool": "S3.Cold",
                        "compression_type": "lz4"
                    },
                    "HOT": {
                        "data_pool": "S3.Hot",
                        "compression_type": "lz4"
                    },
                    "STANDARD": {
                        "data_pool": "S3.Hot",
                        "compression_type": ""
                    }
                },
                "data_extra_pool": "ZONE.rgw.buckets.non-ec",
                "index_type": 0,
                "inline_data": true
            }
        }
    ],
    "realm_id": "9efe536c-8282-4f79-86fa-778a0b5ad6ec",
    "notif_pool": "ZONE.rgw.log:notif"
}

if any part has a problem, then direct output into the file (example zone.json), then after changes set the json file like bellow:

radosgw-admin zone set --infile=zone.json

To update the configuration:

radosgw-admin period update --commit

The next step create a XML file for the transition lifecycle:

<LifecycleConfiguration>

  <Rule>

    <ID>Transition objects to COLD storage class</ID>

    <Filter>

       <Prefix></Prefix>

    </Filter>

    <Status>Enabled</Status>

    <Transition>

      <Days>3</Days>

      <StorageClass>COLD</StorageClass>

    </Transition>

  </Rule>

</LifecycleConfiguration>

for transition and expiration:

<LifecycleConfiguration>

  <Rule>

    <ID>Transition then Expire Rule</ID>

    <Filter>

       <Prefix></Prefix>

    </Filter>

    <Status>Enabled</Status>

    <Transition>

      <Days>3</Days>

      <StorageClass>COLD</StorageClass>

    </Transition>

    <Expiration>

      <Days>1</Days>

    </Expiration>

  </Rule>
</LifecycleConfiguration>

and for just expiration:

<LifecycleConfiguration>

  <Rule>

    <ID>Transition then Expire Rule</ID>

    <Filter>

       <Prefix></Prefix>

    </Filter>

    <Status>Enabled</Status>

    <Expiration>

      <Days>1</Days>

    </Expiration>

  </Rule>
</LifecycleConfiguration>

For test, because of time limitations and multiple test scenarios, we can change a day duration to 1 minute with following command: ceph config set client.rgw.S3 rgw_lc_debug_interval 60 # set time of a day to 60 secs

set the policy for the bucket:

#> s3cmd setlifecycle lifecycle.xml s3://cloudtest

with the following command:

radosgw-admin lc list

#OUTPUT
[
    {
        "bucket": ":1255gosbench-5:a59fa1be-21d1-4d58-b0de-5aabc1739758.9194523.39",
        "shard": "lc.1",
        "started": "Mon, 29 Jan 2024 03:40:29 GMT",
        "status": "COMPLETE"
    }
]

and for process it manually:

radosgw-admin lc process

with command bellow it shows period time that lifecycle runs:

ceph config get client.rgw.S3 rgw_lifecycle_work_time

Last updated