Skip to content

Object lifecycle #2365

Closed as not planned
Closed as not planned

Description

@guy-har

User Story

Users should be able to define a set of lifecycle rules for data stored in lakeFS. A lifecycle rule includes a path prefix and a time period after which all objects under the prefix expire. For every prefix, the user will be able to define a default period and a period per branch, with the latter taking precedence.

Example

Consider the following lifecycle configuration:

{
  rule1 : {
    prefix: "foo/bar"
    days: 10
    enabled: true
    branch_days: [
      b1: 5
    ]
  }
}

In this lifecycle configuration, rule1 defines that all objects under foo/bar/ should be removed 10 days after they are added, but 5 days in case they exist only in b1.

The following table describes objects by key, address, branches they exist on, and their age in days. The last column shows whether the file would be deleted considering the above lifecycle configuration.

Key Addr branches days ago added should delete
foo/bar/a 1 main, b1 11 yes
foo/bar/b 2 main, b1 9 no
foo/bar/b 3 b1 6 yes
foo/bar/c 4 b1 4 no
other/a 5 b1 20 no
  • address 1 exists in both branches and was added 11 days ago, the days configured for main is 10 so it should be removed
  • address 2 exists in both branches it was added 9 days ago, the days configured for main is 10, so it can't be removed (until tomorrow)
  • address 3 exists only in b1 and was added 6 days ago, the configuration for b1 is 5 days so it should be deleted
  • address 4 exists only in b1 but was added 4 days ago so it shouldn't be removed
  • address 5 is not under prefix therefore should not be removed

NOTE: Metadata is not removed. As opposed to Garbage collection, where the object was replaced or removed at some point of time, in lifecycle the object still exists and may even be referenced from a head of some branch. This may make it confusing to differ between existing objects and non-existing objects. For now, the only way to distinct will be by receiving a 410 response (gone) when getting the object. We should handle this issue in the future.

Proposal

Configuring the lifecycle policy

The user will be able to set and get the lifecycle policy using the following commands:
bash lakectl lifecycle get lakefs://repo-name
bash lakectl lifecycle set lakefs://repo-name --source /path/to/policy.json

The lifecycle policy will be represented as a JSON file.
The JSON file will contain rules, each rule will contain the following fields:

  • prefix: The prefix the rule is applied on
  • days: the default number of days object will be removed after creation
  • enabled: defines if the rule is currently enabled
  • branch_days: number of days object will be removed after creation by branch

Example for a JSON file

{
  "rule_ID" : {
    "prefix": "foo/bar",
    "days": 10,
    "enabled": true,
    "branch_days": {
      "example_branch": 5,
    }
  }
}

Spark Job proposal

The user can run a spark job that is in charge of enforcing the lifecycle policy.

The spark job will delete all the data (addresses) of objects matching the
lifecycle rules except for data that is referenced by other objects (objects not
matching the lifecycle rule). In order to find the matching objects efficiently
(without going over the history of all commits every time) the spark job will
get as a parameter the Date lifecycle job ran the last time and will
find only commits that might have objects matching the lifecycle policy and
didn’t match in the last run.

Activity

  1. arielshaqed commented on Aug 12, 2021

    @arielshaqed
    Contributor

    S3 object lifecycle includes transitioning between "storage classes". We already have minimal support for setting that storage class on upload. Ideally we will be able to extend whatever API we give for lifecycle to handle such a transition.

  2. guy-har commented on Aug 12, 2021

    @guy-har
    ContributorAuthor

    @arielshaqed, Good point and It is possible to handle. I suggest we start with lifecycle policy supporting only deletion. And add this later on in case it is requested. I do believe we should take it into consideration as part of the implementation so it will be added easily when needed.

  3. self-assigned this
    on Aug 18, 2021
  4. added
    new-feature
    roadmap/hard-delete
    on Aug 18, 2021
  5. added this to the Retention milestone on Aug 18, 2021
  6. talSofer commented on Aug 19, 2021

    @talSofer
    Contributor

    @guy-har is the UI you envision for this similar to the new Retention section?

    Given that the spark job that enforces objects lifecycle can receive the time of the previous run as a parameter, I think that it would be good to make it notify lakeFS that it happened and lakeFS can help users keep track of when they ran the lifecycle enforcement jobs. WDYT?

  7. guy-har commented on Aug 19, 2021

    @guy-har
    ContributorAuthor

    @talSofer, for a beginning the UI will be similar to garbage collection. Great idea, we don't really need to notify lakeFS. We would probably save information of each lifecycle run (same as in garbage collection, under _lakefs/retention). then we can show that data from lakeFS, or even get that data from the spark job (which will remove the need to pass the date). I will take this into consideration in the design. might be a good idea to write the data partitioned by run date.

  8. added
    team/ecosystem
    and removed
    team/ecosystem
    on Mar 16, 2022
  9. removed their assignment
    on Dec 28, 2022
  10. github-actions commented on Nov 1, 2023

    @github-actions

    This issue is now marked as stale after 90 days of inactivity, and will be closed soon. To keep it, mark it with the "no stale" label.

  11. github-actions commented on Nov 13, 2023

    @github-actions

    Closing this issue because it has been stale for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    new-featureproposalroadmap/hard-deletestaleteam/ecosystem

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions