system-config/tools/gerrit-account-inconsistencies/retire-user.sh
Clark Boylan 112cbc6cfe Add tools being used to make sense of gerrit account inconsistencies
The first tool has been used to "retire" accounts that have preferred
email addresses without a matching external id. The second is being used
to make sense of whether or not we can do a bulk retirement of accounts
with email conflicts in their external ids. The third is a script that
can be used to remove external ids from accounts in bulk based on their
email addresses.

Change-Id: Idf22cfc9f2bac7d3921e006c40faef4585c2d977
2021-03-05 11:06:12 -08:00

48 lines
1.6 KiB
Bash

# Script to "retire" a gerrit account given its All-Users ref, eg:
# refs/users/34/1234
# This script should be run within the root of an All-Users repo.
#
# This will remove the preferred email from the account to fix
# issues where the preferred email has no corresponding external id
# and set the account to inactive.
#
# The commit message heredoc should be edited appropriately before
# running this script.
set -ex
REF=$1
git fetch origin $REF
git checkout FETCH_HEAD
sed -i -e '/^\tpreferredEmail = .*/d' account.config
# Gerrit accounts are active by default and don't have active record
# entries when active.
if ! grep 'active = false' account.config ; then
echo -e "\tactive = false" >> account.config
fi
git add account.config
git commit -F - << EOF
Retire this account
Set the account to inactive and remove its preferred email address.
This account appears to be an old style third party CI account. One
which the Gerrit admins manually added it as a system account. For
a while now we've asked third party CI operators to transition to
openid based accounts to reduce our workload. These third party CI
systems don't appear currently active and retiring them will fix
Gerrit consistency errors. If necessary they can create more modern
openid based accounts for their CI systems.
We are doing this to fix these Gerrit consistency errors:
Account 'ABXY' has no external ID for its preferred email 'ABXY@example.com'
EOF
#echo '## Verify this commit is correct with git show HEAD'
#echo "## If things look good run git push origin HEAD:$REF"
git show HEAD
git push origin HEAD:$REF