lakeFS icon indicating copy to clipboard operation
lakeFS copied to clipboard

Provide an easy command for "Rollback to commit"

Open itaiad200 opened this issue 3 years ago • 8 comments

Current Status We have 2 commands that can be used to achieve rollback to a last known good commit.

  1. Reset: Undo changes in staging (Can be filtered by all/prefix/object).
  2. Revert: Given a commit, record a new commit to reverse the effect of this commit.

If a user simply wants to move the HEAD of the branch to a specific commit, she needs to first revert uncommitted, then traverse the tree (in the right reversed order!) and apply revert on all commits along the way (and account for merges, which are trickier).

Desired Status lakectl branch rollback lakefs://example-repo/example-branch <commithash> will clear the staging area of example-branch and point the HEAD of it to <commithash>.

  • Concern: Some commits are now dangling and hard to find if the user mistakenly used this command. Possible solution: Use tags, tag the previous HEAD of example-branch with example-branch-rollback-<time>, so that it's easier to undo such operations. Commits are still dangling and could be picked up by retention (with garbage collection rules), but that is expected and the grace period for such actions is determined by the user.

itaiad200 avatar Aug 10 '21 07:08 itaiad200

Agree the functionality is important - having a way to force my branch state to a specific point in time. Regarding the terminology, it looks like reset hard or specific flag in rollback so the user will understand that this time commits can be "lost".

nopcoder avatar Aug 10 '21 08:08 nopcoder

I Agree, We must have this functionality. We should be careful with erasing staging though, It can't be restored. Maybe something like requiring some approval in case staging isn't empty or using a dedicated flag.

guy-har avatar Aug 10 '21 08:08 guy-har

I think we have the correct data model to structure this nicely.

Here's a suggestion:

  1. Add a reflog, so the action is reversible (#2321) - this is already something we agreed was a good idea anyway
  2. Add the ability to "stash" the set of staged changes - since they are already decoupled from the branch pointer using a staging token, this should be easy (famous last words, I know..)
  3. allow changing the branch pointer to any commit hash or ref the user desires, as long as they are no staged changes.. if stashing/unstashing is O(1), I think this makes sense.

The benefit is that with these 3 steps, it becomes reversible. I can stash my changes, rollback, and then undo both by rolling-forward (?) to the original newer commit, and then un-stashing the staged changes.

Edit: Since rollback doesn't fit the functionality (i.e. I can move the branch pointer either forward or sideways, to commits the branch was never at, perhaps we need a more descriptive name for this)

ozkatz avatar Aug 10 '21 09:08 ozkatz

Absolutely needed functionality.

I strongly suggest not introducing the term "rollback". I would add this to the reset command and require a --hard flag - similar to git.

johnnyaug avatar Aug 10 '21 09:08 johnnyaug

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.

github-actions[bot] avatar Nov 01 '23 14:11 github-actions[bot]

@N-o-Z notice this issue

itaiad200 avatar Nov 02 '23 09:11 itaiad200

@N-o-Z notice this issue

Lol, good catch of the new workflow 😂

N-o-Z avatar Nov 02 '23 10:11 N-o-Z

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.

github-actions[bot] avatar Feb 12 '24 01:02 github-actions[bot]