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

recovering from auto save should check the commit-sha #187

Closed
rokroskar opened this issue Jun 24, 2019 · 17 comments
Closed

recovering from auto save should check the commit-sha #187

rokroskar opened this issue Jun 24, 2019 · 17 comments
Labels
bug Something isn't working
Milestone

Comments

@rokroskar
Copy link
Member

The autosave branch should only be restored if the commit-sha of the autosave equals the requested commit-sha.

See errors reported in SwissDataScienceCenter/renku-ui#472.

@rokroskar rokroskar added the bug Something isn't working label Jun 24, 2019
@rokroskar rokroskar added this to the 0.4.0 milestone Jun 24, 2019
@m-alisafaee
Copy link
Contributor

In addition to commit-sha, branch must also match.

@m-alisafaee
Copy link
Contributor

m-alisafaee commented Jul 3, 2019

There is yet another bug here: If we have un-pushed commit, they are autosaved by using the commit-sha of the local un-pushed commit. Since, there is not corresponding commit-sha in the remote repo, there is not way to recover the autosaved branch because its commit-sha does not exist in the remote repo.
Before, this was not an issue because we weren't checking the commit-sha of the autosaved branch. But, with this new change this is an issue.

Possible solution would be to use the commit-sha of the remote repo when creating autosaved branches.

@m-alisafaee
Copy link
Contributor

There is another potential bug: if the user creates a branch but doesn't push it, there is no way to recover from an autosave for that branch.

@rokroskar
Copy link
Member Author

I thought it is using the commit-sha that the server was started from?

@m-alisafaee
Copy link
Contributor

No, it uses the commit-sha of the current local branch. From renku-notebooks/helm-chart/renku-notebooks/templates/configmap.yaml::pre-stop.sh:

...
    CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
    CURRENT_SHA=`git rev-parse --short HEAD`
    AUTOSAVE_BRANCH="renku/autosave/$JUPYTERHUB_USER/${CURRENT_BRANCH}/${CURRENT_SHA}"
...

@rokroskar
Copy link
Member Author

right, @jachro and I had some discussions about this - we need to think carefully what the expected behavior would be. My impression is that we should be saving/restoring based on the branch/commit that the server was started from.

@jachro
Copy link
Contributor

jachro commented Jul 3, 2019

@rokroskar why do you think it's better? I'd care that much about what the user did after starting the session. I think it could be quite confusing if a user is currently working on branch B but the autosave branch would be pointing to branch A (I know it's just a name).
In general, the start branch is for me just a starting point for a user but when the user goes during his/her work it's up to them. It could be that the start branch is effectively only for doing git checkout -b new-branch.

@m-alisafaee
Copy link
Contributor

To me also it does not make sense to use the initial branch/commit. They might be stale at the time of autosave. The user has to start from that branch/commit to have the autosaved branch restored.

@m-alisafaee
Copy link
Contributor

Actually, we need both local and remote commit-shas here. This is needed to restore an autosaved branch for un-pushed commits. The remote commit-sha is needed to check for autosave and local remote-sha is needed to restore the un-pushed commits.
At the moment, if we only use remote commit-sha, all un-pushed commits are reset and if we only use local remote-sha we cannot match the autosaved branch.

@m-alisafaee
Copy link
Contributor

m-alisafaee commented Jul 3, 2019

There is one side-effect here: assume that commit xyz is un-pushed and remote's HEAD points at abc. If the pod is deleted, the autosave branch will be .../autosave/user/master/abc/xyz. The user can only resume from abc branch. If s/he does it the current script will match the autosave and will resume it, BUT the HEAD points to xyz. So, notebook were asked to resume abc but it resumed xyz. This is what started this whole thing.
If this behavior is not acceptable, then we can resume abc but any commit after it will be reset (i.e. xyz is lost).

@rokroskar
Copy link
Member Author

Right, unless we push the unpushed commits to remote, we can't resume from there. So maybe the autosave should be from whatever the latest commit that both local and remote branch have in common? In any case, it would be nice if the UI could show that an autosave exists for a particular branch/commit combo.

@lorenzo-cavazzi
Copy link
Member

I agree, and it shouldn't be that difficult considering we use the branch name to identify the project, branch and commit.

Screenshot from 2019-07-04 08-37-33

Should we only inform the user about this or give him the possibility to choose between starting from the autosaved branch or throwing it away? I personally prefer the first option, since the user may want to check what is in the autosave first

@lorenzo-cavazzi
Copy link
Member

P.S. we generally use the 8 chars commit, is there a reason why the autosave branch uses 7 chars instead?

@rokroskar
Copy link
Member Author

Oh at some point we were using 7 characters in the notebook service...

@m-alisafaee
Copy link
Contributor

Let's discuss this issue tomorrow and make a final decision about it.

@m-alisafaee
Copy link
Contributor

We agreed that:

  • To keep both local and remote commit-sha in autosaved branch name
  • Check commit-sha of the spawned server against the remote commit-sha of the autosaved branch and recover only when they match (these two are the same except when there were some un-pushed commits).
  • The resumed notebook will be on the requested commit (spawned commit-sha) except when there were some un-pushed local commits. In this case, it will be on the last local un-pushed commit.

@m-alisafaee
Copy link
Contributor

Closed by #190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants