Tuesday, January 7, 2014

Script to Fix Gerrit: LDAP floods log for gerrit-only users

We recently upgraded to Gerrit 2.7 and started to see lots of LDAP related errors in the logs. We tracked it down to this bug report: https://code.google.com/p/gerrit/issues/detail?id=1640.

I wrote a quick script to fix the issue and thought I'd share it.

read -s pwd

echo "SELECT external_id FROM account_external_ids WHERE external_id LIKE 'gerrit:%';" | mysql -h db.example.com -u gerrit -p${pwd} reviewdb | sed 's/^gerrit://' > usernames.txt

for u in $(< usernames.txt); do
if ! id $u > /dev/null 2>1; then
   echo "DELETE FROM account_external_ids WHERE external_id = 'gerrit:$u' LIMIT 1;" | mysql -h db.example.com -u gerrit -p${pwd} reviewdb

1 comment:

  1. This is a good site to spent time on. Must like to say that this is a great blog! Exceptional send with a fully designed jointly with beneficial making This unique excellent write-up shows the great comprehending you have used this style. I am sure this post has helped me save many hours of browsing other related posts just to find what I was looking for. Appreciate it this original perform the job. The style of your is very unique but easy to understand what you want to say in this discussion. I am totally pleased by your excellent work. Many thanks for sharing.

    Contact @ olympics best dissertation