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

[FIX] git-aggregator issues in Debian bookworm #582

Merged
merged 3 commits into from
Nov 30, 2023

Conversation

PabloEForgeFlow
Copy link
Contributor

Starting with git v2.27 pull no longer has a default strategy to reconcile divergent branches (see desktop/desktop#14423 (comment) and release notes) As a result, the following error is shown when no default strategy is configured and divergent branches are found:

hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint: 
hint:   git config pull.rebase false  # merge
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.

The change was addressed in git-aggregator version 3.0.0 by acsone/git-aggregator#64. Since both 16.0 and 17.0 Dockerfiles pin git-aggregator<3.0.0 and use Debian Bookworm (which has git>2.27), they are affected by the issue.

The proposed fix pins git-aggregator==4.0, which I've tested in 16.0 and seems to work just fine. If it is pinned to 3.0.0 for some reason I suppose we can find an alternative.

@ap-wtioit
Copy link
Contributor

Pin was introduced in #523 because of acsone/git-aggregator#66 which was fixed in acsone/git-aggregator#67

So the pin was originally reverted in #524

And then reintroduced in 7b25d25 because of acsone/git-aggregator#68

Are you sure it works now? The last issue is still open.

BTW: we are running git-aggregator<3.0.0 just fine with git 2.37.7 (see #535) on our systems.

@theangryangel
Copy link
Contributor

FWIW I'm also seeing issues with 16.0 and 17.0 builds under GitHub actions - it almost seems like git-aggregator is ignoring the ssh/config file completely. Locally it seems to be working fine. I'm only about 5 minutes into looking into this in any detail. Any builds over the weekend have also failed, so I'm assuming it's related to this somehow.

@ap-wtioit
Copy link
Contributor

ap-wtioit commented Nov 20, 2023

Ah yes, we have a few more patches in 100-repos-aggregate that make it work.

# make sure odoo has a user.name configured, as merges would not succeed otherwise
# (even if GIT_AUTHOR_NAME and EMAIL are set and should be used, it seems gitaggregate is not passing them to git)
su --shell="$SHELL" odoo -c 'git config user.name 1>/dev/null || git config --global user.name "'"$GIT_AUTHOR_NAME"'"'

# enable merges in git pull, this seems necessary for git-aggregator to work properly with our rebased feature branches
su --shell="$SHELL" odoo -c 'git config pull.rebase 1>/dev/null || git config --global pull.rebase false "'"$GIT_AUTHOR_NAME"'"'

# configure main as the default branch to suppress warnings in gitaggregate
su --shell="$SHELL" odoo -c 'git config init.defaultBranch 1>/dev/null || git config --global init.defaultBranch main'

I wonder where those got lost on the way to upstream (this repo).

Edit: i added those in our repo on 23.01.2023 after #535 was stopped for the official doodba. (I still think it's better to have one git version across multiple doodba versions as those patches are only for certain git versions)

@PabloEForgeFlow
Copy link
Contributor Author

@ap-wtioit I haven't been able to reproduce acsone/git-aggregator#68 in our 16.0 projects, maybe it was caused by the combination of git and git-aggregator versions?

I also considered using git config --global pull.rebase false, but if updating git-aggregator works we might just as well do that. This is our current workaround in 050-fix-git-reconcile:

#!/bin/bash
pip uninstall -y git-aggregator
pip install git-aggregator

@theangryangel We are having Host key verification failed errors on private repositories, but I assumed it was another unrelated issue. It is worth noting that aggregating locally does not trigger the error, so maybe it has to do with some build arguments?

@ap-wtioit
Copy link
Contributor

@PabloEForgeFlow to me it looks like acsone/git-aggregator#68 only happens in git version < 2.25.1 so Debian bookworm should not be affected by it and git-aggregator 4.0.0 should be fine for 16.0 and 17.0

@theangryangel
Copy link
Contributor

theangryangel commented Nov 20, 2023

@theangryangel We are having Host key verification failed errors on private repositories, but I assumed it was another unrelated issue. It is worth noting that aggregating locally does not trigger the error, so maybe it has to do with some build arguments?

Auto aggregate as the root user for me is failing because when these lines run https://github.com/Tecnativa/doodba/blob/master/16.0.Dockerfile#L227

The ~root/.ssh folder looks like this:

#9 0.449 doodba WARNING: ~/.ssh/
#9 0.454 total 20K
#9 0.454 drwxr-xr-x 2 root root 4.0K Nov 20 12:19 .
#9 0.454 drwx------ 1 root root 4.0K Nov 20 12:19 ..
#9 0.454 drwx------ 1 root odoo 4.0K Nov 20 09:10 ssh

Instead of this:

#9 0.412 drwx------ 1 root odoo 4.0K Nov 20 09:10 .
#9 0.412 drwxr-xr-x 1 root root 4.0K Nov 14 14:23 ..
#9 0.412 -rw------- 1 root odoo 1022 Nov 20 09:10 config
#9 0.412 -rw------- 1 root odoo 3.3K May 17  2023 glodouk_enterprise_id_rsa
#9 0.412 -rw------- 1 root odoo  734 May 17  2023 glodouk_enterprise_id_rsa.pub
#9 0.412 -rw------- 1 root odoo    0 Jul 24 13:43 id_rsa
#9 0.412 -rw------- 1 root odoo    0 Jul 24 13:43 id_rsa.pub
#9 0.412 -rw------- 1 root odoo 1.6K Nov 14 14:26 known_hosts

I've been trying to track down what in coreutils/bookworm seems to have changed, but as a temporary workaround I've set up this odoo/custom/build.d/099-fix-aggregate script to fix it up

#!/bin/bash
set -e

if [ -e ~root/.ssh/ssh/ ]; then
    log WARNING "Found nested SSH directory. Performing workaround for temporary fix for #582"

    unlink ~root/.ssh/ssh
    rm -rf ~root/.ssh/
    ln -sf /opt/odoo/custom/ssh ~root/.ssh

    sync
fi

I'll raise a fix for the Dockerfile's, but I'd really like to find some documentation, or something, somewhere about the change in ln behaviour :(

Edit: for visibility I've raised #585

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this for now for avoiding the problem with git version. Other patches may come later.

@pedrobaeza
Copy link
Member

Uhm, there's an error in the CI. Can you check it?

@PabloEForgeFlow
Copy link
Contributor Author

PabloEForgeFlow commented Nov 21, 2023

git-aggregator is not creating a merge commit for the repos.yaml in repos_merge despite 099-git_merge_no_ff. It appears the default pull behavior was changed to fast-forward in acsone/git-aggregator#70 (4.0.0) and is overriding the .gitconfig setting.

I guess we need to either change the tests to ensure that an actual merge is performed or downgrade git-aggregator to 3.0.1.

@JordiBForgeFlow
Copy link

@PabloEForgeFlow Looks like it's better to fix the tests, right? Would you know how to do that?

@ap-wtioit
Copy link
Contributor

@PabloEForgeFlow @JordiBForgeFlow the test was added by me to ensure merges are possible in doodba. (merge commits were not working at some time because the git user config was no longer taken from the environment variables).

we probably would need a repo with a reachable url and 2 always mergable branches that create a merge commit when merged. then we could get remove scaffoldings/repo_merge/custom/build.d/099-git_merge_no_ff. i'm thinking of a bare repo in custom/src prepared for this test.

what do you think about that? should i fix the test this way?

@PabloEForgeFlow
Copy link
Contributor Author

PabloEForgeFlow commented Nov 23, 2023

Sounds good to me. However, if we only need to ensure merge commits are created perhaps using a local repository is simpler. The following produces a merge commit using git-aggregator 4.0:

#!/bin/bash
rm -rf /tmp/test-repo
mkdir /tmp/test-repo
cd /tmp/test-repo

git init
touch a.txt
git add a.txt
git commit -m a.txt
touch b.txt
git add b.txt
git commit -m b.txt

git checkout HEAD~1
git checkout -b divergent
touch c.txt
git add c.txt
git commit -m c.txt

cd -
cat <<- EOF > repos.yaml
./test-merge:
  remotes:
    local: /tmp/test-repo
  merges:
    - local master
    - local divergent
EOF
gitaggregate -c repos.yaml aggregate
git -C test-merge --no-pager log

@JordiBForgeFlow
Copy link

@ap-wtioit Can we do the changes suggested by @PabloEForgeFlow , or you do?

@ap-wtioit
Copy link
Contributor

@JordiBForgeFlow your can do it, i would most likely only be able to do it next week, as the wkhtmltopdf issue took the priority 1 for us today.

@PabloEForgeFlow
Copy link
Contributor Author

Not a pretty fix, but tests should be working now.

git-aggregator 4.0 default fast-forward behavior overrides the git
configuration in 099-git_merge_no_ff.
Replace it with 099-create-fake-odo to create a fake odoo repo with two
branches.
@PabloEForgeFlow
Copy link
Contributor Author

@pedrobaeza Could you approve the workflow for the new commit? Thanks

@@ -6,6 +6,7 @@ services:
args:
COMPILE: "false"
ODOO_VERSION: $ODOO_MINOR
PIP_INSTALL_ODOO: "false" # ensure build.d/700-odoo-install does not fail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

Copy link
Contributor

@ap-wtioit ap-wtioit Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to me it looks like the pip install odoo is disabled for this because /tmp/fake-odoo is not installable as an odoo package but merely acts as a test for merging in container with git-aggregate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's like @ap-wtioit said. Perhaps I should have made the comment more explicit.

@pedrobaeza
Copy link
Member

It seems CI is broken with this change.

@PabloEForgeFlow
Copy link
Contributor Author

My bad, I only tested test_repo_merge and forgot about test_repo_merge_aggregate_permissions. They both run fine locally now.

@pedrobaeza pedrobaeza merged commit 3187eff into Tecnativa:master Nov 30, 2023
6 checks passed
@LoisRForgeFlow LoisRForgeFlow deleted the fix-bookworm-aggregate branch December 5, 2023 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants