abra app deploy seems to delete pending commits #566

Closed
opened 2025-05-28 02:17:18 +00:00 by mac-chaffee · 2 comments

Filing this "bug" just for documentation purposes. It's not actually a bug, I found out while recreating this that you can use git reflog to find the previous commit SHA, then git checkout to recover it.


When working on a new recipe, if you commit (but don't push) changes to the recipe and then run abra app deploy, abra will perform some git operations that seems to delete pending commits.

Steps to reproduce:

Start working on a new recipe, git repo initialized at commit 8f318943

$ abra recipe new test
INFO new recipe 'test' created: /root/.abra/recipes/test
INFO happy hacking 🎉

$ abra app new test
INFO single server detected, choosing default automatically
? Specify app domain test.default
INFO test.default created (version: 8f318943)

Start hacking on the recipe by committing a change but not pushing it yet:

$ cd ~/.abra/recipes/test
$ echo "hi" >> README.md 

# git commit -am "wip"
[detached HEAD 83a55a2] wip
 1 file changed, 1 insertion(+)

# git log
commit 83a55a2b89da4ace52a658ec45ab5d3f0d9fbd61 (HEAD)
Author: Your Name <you@example.com>
Date:   Wed May 28 02:10:38 2025 +0000

    wip

commit 8f3189430ad5c949f73bccd9866e568db3e35d40
Author: Your Name <you@example.com>
Date:   Wed May 28 02:08:10 2025 +0000

    init

Deploy the recipe:

root@debian-8gb-ash-1:~/.abra/recipes/test# abra app deploy test.default --debug
DEBU <cli/run.go:65> abra version 0.10.1-beta, commit 2fbef41a3a000b78b8c3a68d1aa0604f50bad715
DEBU <app/app.go:293> collecting metadata from 1 servers: default
DEBU <git/read.go:130> no /root/.gitignore exists, skipping reading gitignore paths
DEBU <git/read.go:52> git status: /root/.abra/recipes/test: clean
DEBU <app/app.go:39> loaded app test.default: {name: test.default, recipe: {name: test, version : 8f318943, dirty: false, dir: /root/.abra/recipes/test, git url: https://git.coopcloud.tech/coop-cloud/test.git, ssh url: ssh://git@git.coopcloud.tech:2222/coop-cloud/test.git, compose: /root/.abra/recipes/test/compose.yml, readme: /root/.abra/recipes/test/README.md, sample env: /root/.abra/recipes/test/.env.sample, abra.sh: /root/.abra/recipes/test/abra.sh}, domain: test.default, env map[DOMAIN:test.default LETS_ENCRYPT_ENV:production TYPE:test:8f318943], server default, path /root/.abra/servers/default/test.default.env}
DEBU <internal/validate.go:99> validated test.default as app argument
DEBU <git/read.go:130> no /root/.gitignore exists, skipping reading gitignore paths
DEBU <git/read.go:52> git status: /root/.abra/recipes/test: clean
DEBU <recipe/git.go:243> cannot ensure test is up-to-date, no git remotes configured
DEBU <recipe/git.go:48> ensuring env version 8f318943
DEBU <recipe/git.go:154> attempting to checkout '8f318943' as chaos commit
DEBU <recipe/git.go:176> successfully checked test out to  in /root/.abra/recipes/test
DEBU <client/client.go:88> created client for default
DEBU <app/deploy.go:87> checking whether test_default is already deployed
DEBU <stack/stack.go:171> test_default has been detected as not deployed
DEBU <app/deploy.go:300> version: taking version from .env file: 8f318943
DEBU <recipe/git.go:154> attempting to checkout '8f318943' as chaos commit            <--------
DEBU <recipe/git.go:176> successfully checked test out to  in /root/.abra/recipes/test
DEBU <lint/recipe.go:185> linting for critical errors in test configs
DEBU <lint/recipe.go:207> linting successful, test is well configured
DEBU <recipe/compose.go:27> no COMPOSE_FILE detected, loading default: /root/.abra/recipes/test/compose.yml
DEBU <envfile/envfile.go:46> read map[DOMAIN:test.default LETS_ENCRYPT_ENV:production TYPE:test:8f318943] from /root/.abra/servers/default/test.default.env
DEBU <secret/secret.go:116> not generating app secrets, none enabled in recipe config
DEBU <recipe/compose.go:27> no COMPOSE_FILE detected, loading default: /root/.abra/recipes/test/compose.yml
DEBU <app/app.go:497> retrieved /root/.abra/recipes/test/compose.yml for test.default
DEBU <app/app.go:506> adding env vars to test_default service config
DEBU <app/app.go:512> test_default: STACK_NAME: test_default
DEBU <app/app.go:512> test_default: TYPE: test:8f318943
DEBU <app/app.go:512> test_default: DOMAIN: test.default
DEBU <app/app.go:512> test_default: LETS_ENCRYPT_ENV: production
DEBU <app/compose.go:17> set recipe label 'coop-cloud.test_default.recipe' to test for test_default
DEBU <app/compose.go:29> set label 'coop-cloud.test_default.chaos' to false for test_default
DEBU <app/compose.go:67> set label 'coop-cloud.test_default.autoupdate' to false for test_default
DEBU <app/compose.go:50> set label 'coop-cloud.test_default.version' to 8f318943 for test_default
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃         NEW DEPLOY OVERVIEW        ┃
┃                                    ┃
┃ DOMAIN                test.default ┃
┃ RECIPE                test         ┃
┃ SERVER                local        ┃
┃ CONFIG                compose.yml  ┃
┃                                    ┃
┃ CURRENT DEPLOYMENT    N/A          ┃
┃ ENV VERSION           8f318943     ┃
┃ NEW DEPLOYMENT        8f318943     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
? proceed? Yes
DEBU <app/compose.go:79> get label 'coop-cloud.test_default.timeout'
DEBU <app/compose.go:85> no timeout label found for test_default
DEBU <app/deploy.go:198> set waiting timeout to 50 second(s)
DEBU <app/app.go:293> collecting metadata from 1 servers: default
DEBU <git/read.go:130> no /root/.gitignore exists, skipping reading gitignore paths
DEBU <git/read.go:52> git status: /root/.abra/recipes/test: clean
DEBU <recipe/compose.go:27> no COMPOSE_FILE detected, loading default: /root/.abra/recipes/test/compose.yml
DEBU <app/app.go:497> retrieved /root/.abra/recipes/test/compose.yml for test
INFO <stack/stack.go:203> initialising deployment
DEBU <stack/stack.go:497> creating test_default_app
INFO <stack/stack.go:553> polling deployment status
app: starting  (retries: 0, healthcheck: starting)

Notice the commit is gone from the commit log:

# git log
commit 8f3189430ad5c949f73bccd9866e568db3e35d40 (HEAD)
Author: Your Name <you@example.com>
Date:   Wed May 28 02:08:10 2025 +0000

    init
_Filing this "bug" just for documentation purposes. It's not actually a bug, I found out while recreating this that you can use `git reflog` to find the previous commit SHA, then `git checkout` to recover it._ --- When working on a new recipe, if you commit (but don't push) changes to the recipe and then run `abra app deploy`, abra will perform some git operations that seems to delete pending commits. **Steps to reproduce:** Start working on a new recipe, git repo initialized at commit `8f318943` ``` $ abra recipe new test INFO new recipe 'test' created: /root/.abra/recipes/test INFO happy hacking 🎉 $ abra app new test INFO single server detected, choosing default automatically ? Specify app domain test.default INFO test.default created (version: 8f318943) ``` Start hacking on the recipe by committing a change but not pushing it yet: ``` $ cd ~/.abra/recipes/test $ echo "hi" >> README.md # git commit -am "wip" [detached HEAD 83a55a2] wip 1 file changed, 1 insertion(+) # git log commit 83a55a2b89da4ace52a658ec45ab5d3f0d9fbd61 (HEAD) Author: Your Name <you@example.com> Date: Wed May 28 02:10:38 2025 +0000 wip commit 8f3189430ad5c949f73bccd9866e568db3e35d40 Author: Your Name <you@example.com> Date: Wed May 28 02:08:10 2025 +0000 init ``` Deploy the recipe: ``` root@debian-8gb-ash-1:~/.abra/recipes/test# abra app deploy test.default --debug DEBU <cli/run.go:65> abra version 0.10.1-beta, commit 2fbef41a3a000b78b8c3a68d1aa0604f50bad715 DEBU <app/app.go:293> collecting metadata from 1 servers: default DEBU <git/read.go:130> no /root/.gitignore exists, skipping reading gitignore paths DEBU <git/read.go:52> git status: /root/.abra/recipes/test: clean DEBU <app/app.go:39> loaded app test.default: {name: test.default, recipe: {name: test, version : 8f318943, dirty: false, dir: /root/.abra/recipes/test, git url: https://git.coopcloud.tech/coop-cloud/test.git, ssh url: ssh://git@git.coopcloud.tech:2222/coop-cloud/test.git, compose: /root/.abra/recipes/test/compose.yml, readme: /root/.abra/recipes/test/README.md, sample env: /root/.abra/recipes/test/.env.sample, abra.sh: /root/.abra/recipes/test/abra.sh}, domain: test.default, env map[DOMAIN:test.default LETS_ENCRYPT_ENV:production TYPE:test:8f318943], server default, path /root/.abra/servers/default/test.default.env} DEBU <internal/validate.go:99> validated test.default as app argument DEBU <git/read.go:130> no /root/.gitignore exists, skipping reading gitignore paths DEBU <git/read.go:52> git status: /root/.abra/recipes/test: clean DEBU <recipe/git.go:243> cannot ensure test is up-to-date, no git remotes configured DEBU <recipe/git.go:48> ensuring env version 8f318943 DEBU <recipe/git.go:154> attempting to checkout '8f318943' as chaos commit DEBU <recipe/git.go:176> successfully checked test out to in /root/.abra/recipes/test DEBU <client/client.go:88> created client for default DEBU <app/deploy.go:87> checking whether test_default is already deployed DEBU <stack/stack.go:171> test_default has been detected as not deployed DEBU <app/deploy.go:300> version: taking version from .env file: 8f318943 DEBU <recipe/git.go:154> attempting to checkout '8f318943' as chaos commit <-------- DEBU <recipe/git.go:176> successfully checked test out to in /root/.abra/recipes/test DEBU <lint/recipe.go:185> linting for critical errors in test configs DEBU <lint/recipe.go:207> linting successful, test is well configured DEBU <recipe/compose.go:27> no COMPOSE_FILE detected, loading default: /root/.abra/recipes/test/compose.yml DEBU <envfile/envfile.go:46> read map[DOMAIN:test.default LETS_ENCRYPT_ENV:production TYPE:test:8f318943] from /root/.abra/servers/default/test.default.env DEBU <secret/secret.go:116> not generating app secrets, none enabled in recipe config DEBU <recipe/compose.go:27> no COMPOSE_FILE detected, loading default: /root/.abra/recipes/test/compose.yml DEBU <app/app.go:497> retrieved /root/.abra/recipes/test/compose.yml for test.default DEBU <app/app.go:506> adding env vars to test_default service config DEBU <app/app.go:512> test_default: STACK_NAME: test_default DEBU <app/app.go:512> test_default: TYPE: test:8f318943 DEBU <app/app.go:512> test_default: DOMAIN: test.default DEBU <app/app.go:512> test_default: LETS_ENCRYPT_ENV: production DEBU <app/compose.go:17> set recipe label 'coop-cloud.test_default.recipe' to test for test_default DEBU <app/compose.go:29> set label 'coop-cloud.test_default.chaos' to false for test_default DEBU <app/compose.go:67> set label 'coop-cloud.test_default.autoupdate' to false for test_default DEBU <app/compose.go:50> set label 'coop-cloud.test_default.version' to 8f318943 for test_default ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ NEW DEPLOY OVERVIEW ┃ ┃ ┃ ┃ DOMAIN test.default ┃ ┃ RECIPE test ┃ ┃ SERVER local ┃ ┃ CONFIG compose.yml ┃ ┃ ┃ ┃ CURRENT DEPLOYMENT N/A ┃ ┃ ENV VERSION 8f318943 ┃ ┃ NEW DEPLOYMENT 8f318943 ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ? proceed? Yes DEBU <app/compose.go:79> get label 'coop-cloud.test_default.timeout' DEBU <app/compose.go:85> no timeout label found for test_default DEBU <app/deploy.go:198> set waiting timeout to 50 second(s) DEBU <app/app.go:293> collecting metadata from 1 servers: default DEBU <git/read.go:130> no /root/.gitignore exists, skipping reading gitignore paths DEBU <git/read.go:52> git status: /root/.abra/recipes/test: clean DEBU <recipe/compose.go:27> no COMPOSE_FILE detected, loading default: /root/.abra/recipes/test/compose.yml DEBU <app/app.go:497> retrieved /root/.abra/recipes/test/compose.yml for test INFO <stack/stack.go:203> initialising deployment DEBU <stack/stack.go:497> creating test_default_app INFO <stack/stack.go:553> polling deployment status app: starting (retries: 0, healthcheck: starting) ``` Notice the commit is gone from the commit log: ``` # git log commit 8f3189430ad5c949f73bccd9866e568db3e35d40 (HEAD) Author: Your Name <you@example.com> Date: Wed May 28 02:08:10 2025 +0000 init ```
Author

The solution is to use git reflog to find the previous commit SHA, then git chekout to recover it:

# git reflog
83a55a2 HEAD@{0}: commit: wip
f80d901 (main) HEAD@{1}: commit: wip


# git checkout 83a55a2
Previous HEAD position was 8f31894 init
HEAD is now at 83a55a2 wip

# git log
commit 83a55a2b89da4ace52a658ec45ab5d3f0d9fbd61 (HEAD)
Author: Your Name <you@example.com>
Date:   Wed May 28 02:10:38 2025 +0000

    wip

commit 8f3189430ad5c949f73bccd9866e568db3e35d40
Author: Your Name <you@example.com>
Date:   Wed May 28 02:08:10 2025 +0000

    init
The solution is to use `git reflog` to find the previous commit SHA, then `git chekout` to recover it: ``` # git reflog 83a55a2 HEAD@{0}: commit: wip f80d901 (main) HEAD@{1}: commit: wip # git checkout 83a55a2 Previous HEAD position was 8f31894 init HEAD is now at 83a55a2 wip # git log commit 83a55a2b89da4ace52a658ec45ab5d3f0d9fbd61 (HEAD) Author: Your Name <you@example.com> Date: Wed May 28 02:10:38 2025 +0000 wip commit 8f3189430ad5c949f73bccd9866e568db3e35d40 Author: Your Name <you@example.com> Date: Wed May 28 02:08:10 2025 +0000 init ```
Owner

@mac-chaffee thanks for opening!

yeh this is not ideal. the key lines from the logs are:

DEBU <recipe/git.go:48> ensuring env version 8f318943
DEBU <recipe/git.go:154> attempting to checkout '8f318943' as chaos commit

where the abra app new test dropped (version: 8f318943) into the app .env.

then abra app deploy checks that out, causing the commits to be "lost".

this seems like kind of an edge case but maybe we could improve the general situation with letting people know what version is pinned and that there are other commits? this is a general problem atm i think, as we just introduced the .env version pinning stuff. see #554 for more learning "on the job". we're getting into tricky UI/UX gymnastics then but maybe it's worth it. if you have ideas, i'm all ears.

@mac-chaffee thanks for opening! yeh this is not ideal. the key lines from the logs are: ``` DEBU <recipe/git.go:48> ensuring env version 8f318943 DEBU <recipe/git.go:154> attempting to checkout '8f318943' as chaos commit ``` where the `abra app new test` dropped `(version: 8f318943)` into the app `.env`. then `abra app deploy` checks that out, causing the commits to be "lost". this seems like kind of an edge case but maybe we could improve the general situation with letting people know what version is pinned and that there are other commits? this is a general problem atm i think, as we just introduced the `.env` version pinning stuff. see https://git.coopcloud.tech/toolshed/abra/issues/554 for more learning "on the job". we're getting into tricky UI/UX gymnastics then but maybe it's worth it. if you have ideas, i'm all ears.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: toolshed/abra#566
No description provided.