Skip to content

Commit

Permalink
fix: use local and remote shortened commit-sha to recover from autosa…
Browse files Browse the repository at this point in the history
…ves (#190)

* fix: use shortened commit-sha to check for an autosave match

* fix: use commit-sha of remote branch to create autosave branch name

* fix: avoid a None dereferencing

* fix: use both local and remote commit-sha for autosave
  • Loading branch information
m-alisafaee authored Jul 9, 2019
1 parent 790f92c commit e1001b5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 4 additions & 4 deletions git-clone/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GIT_FETCH_OUT=`git fetch && git branch -a`
IFS=$'\n' ALL_BRANCHES=($GIT_FETCH_OUT)
for branch in "${ALL_BRANCHES[@]}"
do
if [[ $branch == *"${REMOTES_ORIGIN}${AUTOSAVE_BRANCH_PREFIX}/${BRANCH}/${COMMIT_SHA}"* ]] ; then
if [[ $branch == *"${REMOTES_ORIGIN}${AUTOSAVE_BRANCH_PREFIX}/${BRANCH}/${COMMIT_SHA:0:7}"* ]] ; then
AUTOSAVE_REMOTE_BRANCH=${branch// /}
fi
done
Expand All @@ -49,12 +49,12 @@ PRE_SAVE_BRANCH_NAME=${AUTOSAVE_REMOTE_BRANCH_ITEMS[5]}
(git checkout ${PRE_SAVE_BRANCH_NAME} || git checkout -b ${PRE_SAVE_BRANCH_NAME})
git submodule init && git submodule update

PRE_SAVE_COMMIT_ID=${AUTOSAVE_REMOTE_BRANCH_ITEMS[6]}
git reset --hard $PRE_SAVE_COMMIT_ID
PRE_SAVE_LOCAL_COMMIT_SHA=${AUTOSAVE_REMOTE_BRANCH_ITEMS[7]}
git reset --hard $PRE_SAVE_LOCAL_COMMIT_SHA

AUTOSAVE_BRANCH=${AUTOSAVE_REMOTE_BRANCH/$REMOTES_ORIGIN/''}
git pull --rebase origin $AUTOSAVE_BRANCH
git reset --soft $PRE_SAVE_COMMIT_ID
git reset --soft $PRE_SAVE_LOCAL_COMMIT_SHA
git reset HEAD .
git push origin :"$AUTOSAVE_BRANCH"

Expand Down
12 changes: 9 additions & 3 deletions helm-chart/renku-notebooks/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ data:
fi
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}"
LOCAL_SHA=`git rev-parse --short HEAD`
REMOTE_SHA=`git rev-parse --short @{upstream}`
if [ -z "$REMOTE_SHA" ]; then
REMOTE_SHA="${LOCAL_SHA}"
fi
AUTOSAVE_BRANCH="renku/autosave/$JUPYTERHUB_USER/${CURRENT_BRANCH}/${REMOTE_SHA}/${LOCAL_SHA}"
git checkout -b "$AUTOSAVE_BRANCH"
git add .
git commit -am "Auto-saving for $JUPYTERHUB_USER on branch $CURRENT_BRANCH and commit $CURRENT_SHA"
git commit -am "Auto-saving for $JUPYTERHUB_USER on branch $CURRENT_BRANCH and commit $LOCAL_SHA"
git push origin "$AUTOSAVE_BRANCH"
git checkout master
git branch -D "$AUTOSAVE_BRANCH"
3 changes: 3 additions & 0 deletions renku_notebooks/util/kubernetes_.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def sort_conditions(conditions):
}
return sorted(conditions, key=lambda c: CONDITIONS_ORDER[c.type])

if not conditions:
return {"step": None, "message": None, "reason": None}

for c in sort_conditions(conditions):
if (
(c.type == "Unschedulable" and c.status == "True")
Expand Down

0 comments on commit e1001b5

Please sign in to comment.