Search code examples
google-cloud-platformgoogle-cloud-storageversioning

Understanding IsLive and Storage Class while writing Object Lifecycle rules in GCP


We need to enable below Object Lifecycle rules in GCP Cloud Storage bucket

  1. If a non current object version is not accessed for 100 days and its current storage class is either of STORAGE, MULTI_REGIONAL and DURABLE_REDUCED_AVAILABILITY , move that object to Nearline Storage

  2. If a object version is not accessed for 100 days and its current storage class is Nearline , move it to Coldline storage Class

  3. Delete from Coldline storage if objects are not accessed for 100 days from Coldline Storage.

  4. Keep 2 non current version of file

To implement the above rules , the following rules were applied to bucket

{
 "lifecycle": {
   "rule": [
   {
    "action": {
    "type": "SetStorageClass",
    "storageClass": "NEARLINE"
 },
 "condition": {
    "age": 100,
    "isLive": false,
    "matchesStorageClass": ["REGIONAL", "STANDARD", "DURABLE_REDUCED_AVAILABILITY"]
    }
   },
  {
    "action": {
    "type": "SetStorageClass",
    "storageClass": "COLDLINE"
    },
     "condition": {
       "age": 100,
       "matchesStorageClass": ["NEARLINE"]
      }
  },
 {
   "action": { "type": "Delete"},
    "condition": {
     "age": 100,
     "matchesStorageClass": ["COLDLINE"]
    }
   },
  {
    "action": { "type": "Delete"},
     "condition": {
     "numNewerVersions": 2
     }
    }
   ]
   }
   }

Need clarification on below

  1. It is showing the rules are applied successfully but will it work practically. Since we are moving non current versions from NEARLINE to COLDLINE which are not accessed for 100 days do I need to add "isLive": false in Rule 2 . Also does we need it for rule 3 too .

    {
     "action": {
     "type": "SetStorageClass",
     "storageClass": "COLDLINE"
     },
      "condition": {
        "age": 100,
        "isLive": false
        "matchesStorageClass": ["NEARLINE"]
       }
    

    },

    {
      "action": { "type": "Delete"},
      "condition": {
      "age": 100,
      "isLive": false
      "matchesStorageClass": ["COLDLINE"]
     }
    },
    
  2. Also does it makes sense to move directly to COLDLINE from STANDARD storage class as we are considering access above 100 days

Any suggestions ?


Solution

  • Your rules aren't correct.

    Firstly, the age is the number of days after the creation

    Age is measured from the object's creation time

    So, your condition "if it has not been accessed the last 100 days" is not possible. The correct expression is "100 days after its creation, do..."

    From there, your archiving policies aren't correct. You use the same age (100 days after the object creation) to

    • Go to Nearline
    • Go to Coldline
    • Delete from Cold line

    On the same AGE condition!!


    To answer to your questions

    1. No, you don't need to mention the isLive: false if you consider (and you are sure) that only non-current version are in nearline class
    2. Yes you can jump from standard to Coldline, especially for the non-current versions if you consider them as never (or very rarely) used, and then delete them after 100 days.