Page MenuHomePhabricator

Rename gerrit2 unix user to gerrit and assign a fixed uid
Closed, ResolvedPublic

Description

When switching over Gerrit (ex: T326368 ) we have to rsync the LFS data, search indices and cache which requires a follow up chown -R gerrit2 on each affected base paths. Using a central fixed uid for the user would save us from having to do the chown.

While changing the uid, I'd like to also rename the user from the confusing gerrit2 to gerrit.

Instances

Details

Related Changes in Gerrit:
SubjectAuthorRepoBranchLines +/-
Dzahnoperations/puppetproduction+6 -7
Dzahnoperations/puppetproduction+1 -1
Dzahnoperations/puppetproduction+1 -1
Dzahnoperations/puppetproduction+5 -15
Arnaudboperations/puppetproduction+4 -4
Arnaudboperations/puppetproduction+9 -0
Arnaudboperations/puppetproduction+134 -65
Arnaudboperations/puppetproduction+79 -40
Arnaudboperations/puppetproduction+79 -40
Arnaudboperations/puppetproduction+70 -33
Arnaudboperations/puppetproduction+46 -30
Arnaudboperations/puppetproduction+1 -6
Arnaudboperations/dnsmaster+8 -3
Dzahnoperations/puppetproduction+16 -8
Dzahnoperations/puppetproduction+3 -2
Hasharoperations/puppetproduction+8 -16
Dzahnoperations/puppetproduction+3 -0
Dzahnoperations/puppetproduction+1 -0
Dzahnoperations/puppetproduction+3 -3
Dzahnoperations/puppetproduction+1 -1
Dzahnoperations/puppetproduction+26 -11
Hasharoperations/puppetproduction+19 -2
Show related patches Customize query in gerrit

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Mentioned in SAL (#wikimedia-operations) [2024-10-24T00:44:28Z] <dzahn@cumin2002> START - Cookbook sre.hosts.downtime for 14 days, 0:00:00 on gerrit2003.wikimedia.org with reason: in setup and T338470

Mentioned in SAL (#wikimedia-operations) [2024-10-24T00:44:43Z] <dzahn@cumin2002> END (PASS) - Cookbook sre.hosts.downtime (exit_code=0) for 14 days, 0:00:00 on gerrit2003.wikimedia.org with reason: in setup and T338470

This also needs to be fixed. It's the parameters of the rsync command for LFS syncing.

Notice: /Stage[main]/Gerrit/File[/srv/gerrit/data/lfs]/owner: owner changed 498 to 'gerrit' (corrective)
Notice: /Stage[main]/Gerrit/File[/srv/gerrit/data/lfs]/group: group changed 1001 to 'gerrit' (corrective)

Change #1087950 had a related patch set uploaded (by Dzahn; author: Dzahn):

[operations/puppet@production] backup: add /var/lib/gerrit to gerrit repodata backup filesets

https://gerrit.wikimedia.org/r/1087950

Change #1087950 merged by Dzahn:

[operations/puppet@production] backup: add /var/lib/gerrit to gerrit repodata backup filesets

https://gerrit.wikimedia.org/r/1087950

Change #1087963 had a related patch set uploaded (by Dzahn; author: Dzahn):

[operations/puppet@production] devtools: update gerrit user from gerrit2 to gerrit

https://gerrit.wikimedia.org/r/1087963

Change #1087967 had a related patch set uploaded (by Dzahn; author: Dzahn):

[operations/puppet@production] gerrit: add chown parameter to lfs data rsync, ensure daemon_user is used

https://gerrit.wikimedia.org/r/1087967

Change #1087963 merged by Dzahn:

[operations/puppet@production] devtools: update gerrit user from gerrit2 to gerrit

https://gerrit.wikimedia.org/r/1087963

Change #1087967 merged by Dzahn:

[operations/puppet@production] gerrit: add chown parameter to lfs data rsync, ensure daemon_user is used

https://gerrit.wikimedia.org/r/1087967

Change #1088613 had a related patch set uploaded (by Dzahn; author: Dzahn):

[operations/puppet@production] gerrit: set gerrit site dir Hiera value for new machine gerrit2003

https://gerrit.wikimedia.org/r/1088613

Change #1088613 merged by Dzahn:

[operations/puppet@production] gerrit: set gerrit site dir Hiera value for new machine gerrit2003

https://gerrit.wikimedia.org/r/1088613

Dzahn changed the task status from Open to Stalled.Jan 29 2025, 8:47 PM

This is fixed for NEW gerrit machines but we are not changing it for the existing gerrit server. So now this is about getting gerrit2003 (T372804) into production and shutting down the old hardware.

Dzahn removed Dzahn as the assignee of this task.May 22 2025, 8:04 PM

Change #1152810 had a related patch set uploaded (by Dzahn; author: Dzahn):

[operations/puppet@production] gerrit: introduce second daemon_user name

https://gerrit.wikimedia.org/r/1152810

Change #1153159 had a related patch set uploaded (by Hashar; author: Hashar):

[operations/puppet@production] Revert "gerrit: add a second replica, start replicating to gerrit2003"

https://gerrit.wikimedia.org/r/1153159

Change #1153159 merged by AOkoth:

[operations/puppet@production] Revert "gerrit: add a second replica, start replicating to gerrit2003"

https://gerrit.wikimedia.org/r/1153159

Change #1152810 abandoned by Dzahn:

[operations/puppet@production] gerrit: introduce second daemon_user name

Reason:

will make a new simpler patch rebased on top of a re-revert of the replication config change

https://gerrit.wikimedia.org/r/1152810

Change #1153265 had a related patch set uploaded (by Dzahn; author: Dzahn):

[operations/puppet@production] Revert^2 "gerrit: add a second replica, start replicating to gerrit2003"

https://gerrit.wikimedia.org/r/1153265

Change #1153265 merged by Dzahn:

[operations/puppet@production] Revert^2 "gerrit: add a second replica, start replicating to gerrit2003"

https://gerrit.wikimedia.org/r/1153265

Change #1172625 had a related patch set uploaded (by Arnaudb; author: Arnaudb):

[operations/puppet@production] gerrit: Switchover gerrit1003 → gerrit2003

https://gerrit.wikimedia.org/r/1172625

Change #1173376 had a related patch set uploaded (by Arnaudb; author: Arnaudb):

[operations/dns@master] Gerrit: Add service ip for gerrit2003

https://gerrit.wikimedia.org/r/1173376

Change #1173376 merged by Dzahn:

[operations/dns@master] Gerrit: Add service ip for gerrit2003

https://gerrit.wikimedia.org/r/1173376

Change #1174671 had a related patch set uploaded (by Arnaudb; author: Arnaudb):

[operations/puppet@production] gerrit: site.pp cleanup

https://gerrit.wikimedia.org/r/1174671

Change #1174671 merged by Dzahn:

[operations/puppet@production] gerrit: site.pp cleanup

https://gerrit.wikimedia.org/r/1174671

Change #1188351 had a related patch set uploaded (by Arnaudb; author: Arnaudb):

[operations/puppet@production] gerrit: Switchover gerrit1003 → gerrit2003

https://gerrit.wikimedia.org/r/1188351

Change #1172625 abandoned by Arnaudb:

[operations/puppet@production] gerrit: Switchover gerrit1003 → gerrit2003

Reason:

replaced by 1188351

https://gerrit.wikimedia.org/r/1172625

Shouldn't the status of this task be changed from stalled?

ABran-WMF changed the task status from Stalled to In Progress.Oct 2 2025, 12:05 PM

good catch, indeed!

Change #1188351 merged by Arnaudb:

[operations/puppet@production] gerrit: Switchover gerrit1003 → gerrit2003

https://gerrit.wikimedia.org/r/1188351

Change #1211548 had a related patch set uploaded (by Arnaudb; author: Arnaudb):

[operations/puppet@production] gerrit: Switchover gerrit1003 → gerrit2003

https://gerrit.wikimedia.org/r/1211548

Change #1211548 abandoned by Arnaudb:

[operations/puppet@production] gerrit: Switchover gerrit1003 → gerrit2003

Reason:

forgot a step

https://gerrit.wikimedia.org/r/1211548

Change #1211549 had a related patch set uploaded (by Arnaudb; author: Arnaudb):

[operations/puppet@production] gerrit: Switchover gerrit1003 → gerrit2003

https://gerrit.wikimedia.org/r/1211549

Change #1217133 had a related patch set uploaded (by Arnaudb; author: Arnaudb):

[operations/puppet@production] gerrit: Switchover gerrit1003 → gerrit2003

https://gerrit.wikimedia.org/r/1217133

Change #1211549 abandoned by Arnaudb:

[operations/puppet@production] gerrit: Switchover gerrit1003 → gerrit2003

Reason:

1217133

https://gerrit.wikimedia.org/r/1211549

Change #1217133 merged by Arnaudb:

[operations/puppet@production] gerrit: Switchover gerrit1003 → gerrit2003

https://gerrit.wikimedia.org/r/1217133

For the sake of naming harmonization, we should probably also rename the gerrit2 administrator account which will become more and more confusing after we finish changing the system user

image.png (814×414 px, 35 KB)

This is not possible via web UI.

It would involve roughly:

  • git clone the special "All-Users" repo
  • fetch/checkout the "refs/meta/external-ids" branch
  • find the line like "[externalId "username:gerrit2"]"
  • edit the file and rename it to a SHA1 hash of itself. (echo -n "username:NewName" | sha1sum ?)
  • git commit and push to origin
  • re-index the accounts (ssh -p 29418 <host> gerrit index start accounts <account-id> ?)

Not sure if that's worth it.

For the sake of naming harmonization, we should probably also rename the gerrit2 administrator account which will become more and more confusing after we finish changing the system user

image.png (814×414 px, 35 KB)

I have filed this task for renaming the Unix user.

For the Gerrit user, we do not rename users ever, that is asking for too many issues. But please file another task for this and we can investigate.

Change #1240219 had a related patch set uploaded (by Arnaudb; author: Arnaudb):

[operations/puppet@production] gerrit: change daemon user for gerrit1003

https://gerrit.wikimedia.org/r/1240219

Change #1240219 merged by Arnaudb:

[operations/puppet@production] gerrit: change daemon user for gerrit1003

https://gerrit.wikimedia.org/r/1240219

ABran-WMF updated the task description. (Show Details)

Change #1242275 had a related patch set uploaded (by Arnaudb; author: Arnaudb):

[operations/puppet@production] gerrit: prepare replication resume for gerrit2002

https://gerrit.wikimedia.org/r/1242275

Change #1242467 had a related patch set uploaded (by Dzahn; author: Dzahn):

[operations/puppet@production] gerrit: remove code for having multiple daemon users

https://gerrit.wikimedia.org/r/1242467

Change #1242275 merged by Arnaudb:

[operations/puppet@production] gerrit: migrate gerrit2 system user to gerrit

https://gerrit.wikimedia.org/r/1242275

ABran-WMF updated the task description. (Show Details)

There are still a bunch of occurences for gerrit2 in Puppet, notably the backup had a hardcoded /var/lib/gerrit2 but it is fine because it already has /var/lib/gerrit.

The whole $daemon_user can be removed from the profile and the gerrit module in favor of hardcoding it to gerrit. I made it a variable https://gerrit.wikimedia.org/r/c/operations/puppet/+/832345 but it is no more necessary.

I don't know about:

modules/admin/data/system_users.txt
gerrit2

Maybe it has to be kept.

$ git grep '\bgerrit2\b'
hieradata/common/profile/gerrit/migration.yaml:profile::gerrit::migration::daemon_user: 'gerrit2'
hieradata/hosts/gerrit1003.yaml:# different system user gerrit2 -> gerrit (T338470)
hieradata/hosts/gerrit2003.yaml:# different system user gerrit2 -> gerrit (T338470)
modules/admin/data/system_users.txt:gerrit2
modules/gerrit/spec/classes/gerrit_spec.rb:          daemon_user:   'gerrit2',
modules/gerrit/spec/classes/gerrit_spec.rb:          gerrit_site:   '/var/lib/gerrit2/review_site',
modules/gerrit/spec/classes/gerrit_spec.rb:            'ssh://gerrit2@gerrit1002.example.org:29418',
modules/gerrit/templates/gerrit.config.erb:    # The `gerrit2` user is in the Administators group on Gerrit
modules/profile/manifests/backup/filesets.pp:        includes => [ '/srv/gerrit', '/var/lib/gerrit2', '/var/lib/gerrit' ]
modules/profile/manifests/gerrit.pp:    String                            $service_account              = lookup('profile::gerrit::service_account', { 'default_value' => 'gerrit2' }),
modules/profile/manifests/gerrit.pp:    # given the volume of moving parts in the gerrit → gerrit2 migration, lets be explicit
modules/profile/manifests/gerrit.pp:    $local_daemon_user          = pick($daemon_users[$fqdn],                $daemon_user, 'gerrit2')
modules/profile/manifests/gerrit.pp:    $ssh_account_replica        = pick($daemon_users[$replica_host],        $daemon_user, 'gerrit2')
modules/profile/manifests/gerrit.pp:    $ssh_account_spare          = pick($daemon_users[$spare_host],          $daemon_user, 'gerrit2')
modules/profile/spec/classes/profile_gerrit_proxy_spec.rb:        gerrit_site = '/var/lib/gerrit2/review_site'
modules/profile/spec/classes/profile_gerrit_spec.rb:          daemon_user: 'gerrit2',

Change #1242467 merged by Dzahn:

[operations/puppet@production] gerrit: remove code for having multiple daemon users

https://gerrit.wikimedia.org/r/1242467

Change #1243183 had a related patch set uploaded (by Dzahn; author: Dzahn):

[operations/puppet@production] backup: adjust gerrit file set after renaming of gerrit2

https://gerrit.wikimedia.org/r/1243183

Change #1243187 had a related patch set uploaded (by Dzahn; author: Dzahn):

[operations/puppet@production] gerrit: cleanup Hiera and tests after gerrit2 renaming

https://gerrit.wikimedia.org/r/1243187

Change #1243188 had a related patch set uploaded (by Dzahn; author: Dzahn):

[operations/puppet@production] admin: rename gerrit system user

https://gerrit.wikimedia.org/r/1243188

Change #1243187 merged by Dzahn:

[operations/puppet@production] gerrit: cleanup Hiera and tests after gerrit2 renaming

https://gerrit.wikimedia.org/r/1243187

Change #1243183 merged by Dzahn:

[operations/puppet@production] backup: adjust gerrit file set after renaming of gerrit2

https://gerrit.wikimedia.org/r/1243183

Change #1243188 merged by Dzahn:

[operations/puppet@production] admin: rename gerrit system user

https://gerrit.wikimedia.org/r/1243188

marking this as resolved, thanks @Dzahn for the patches!

$ git grep '\bgerrit2\b'
hieradata/common/profile/gerrit.yaml:profile::gerrit::service_account: 'gerrit2'
hieradata/hosts/gerrit2003.yaml:# different system user gerrit2 -> gerrit (T338470)
modules/gerrit/templates/gerrit.config.erb:    # The `gerrit2` user is in the Administators group on Gerrit
modules/profile/manifests/gerrit.pp:    String                            $service_account              = lookup('profile::gerrit::service_account', { 'default_value' => 'gerrit2' }),