Page MenuHomePhabricator

resolve gerrit.config disprepancy between managed config and gerrit init
Closed, ResolvedPublic

Description

When doing Gerrit deployment we extract bundled plugins with: java -jar bin/gerrit.war init --batch --install-all-plugins which actually runs the whole initialization process. One side effect is it normalizes the gerrit.config which is later overwritten by the Puppet one.

A capture of the differences:

gerrit2@gerrit2001:~/review_site/etc$ diff gerrit.config.before-gerrit-init gerrit.config
67c67
<     link = "/q/$1"
---
>     link = /q/$1
76c76
<     html = "$1<a href=\"/q/$2\">$2</a>"
---
>     html = $1<a href=\"/q/$2\">$2</a>
110,111c110,111
<     javaOptions = "-XX:+UseG1GC"
<     javaOptions = "-Xmx32g -Xms32g"
---
>     javaOptions = -XX:+UseG1GC
>     javaOptions = -Xmx32g -Xms32g
114,119c114,119
<     javaOptions = "-XX:+UnlockExperimentalVMOptions"
<     javaOptions = "-XX:G1NewSizePercent=15"
<     javaOptions = "-XX:+UseStringDeduplication"
<     javaOptions = "-XX:+HeapDumpOnOutOfMemoryError"
<     javaOptions = "-XX:+ExitOnOutOfMemoryError"
<     javaOptions = "-XX:HeapDumpPath=/srv/gerrit"
---
>     javaOptions = -XX:+UnlockExperimentalVMOptions
>     javaOptions = -XX:G1NewSizePercent=15
>     javaOptions = -XX:+UseStringDeduplication
>     javaOptions = -XX:+HeapDumpOnOutOfMemoryError
>     javaOptions = -XX:+ExitOnOutOfMemoryError
>     javaOptions = -XX:HeapDumpPath=/srv/gerrit
254d253
<     smtpEncryption = none
257c256
<     listenAddress = 208.80.153.107:29418
---
>     listenAddress = [2620:0:860:4:208:80:153:107]:29418

The last one is sshd.listenAddress. It used to be set to gerrit.wikimedia.org probably to workaround the faulty detection by gerrit init.

The configuration should not vary.

Event Timeline

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

[operations/puppet@production] gerrit: config values do not need double quotes

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

brennen renamed this task from resolve gerrit.config dispredancy between managed config and gerrit init to resolve gerrit.config disprepancy between managed config and gerrit init.Jul 21 2021, 9:10 PM

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

[operations/puppet@production] gerrit: remove SMTP encryption option

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

For sshd.listenAddress, I am afraid we have to dig into Gerrit core to find out what kind of logic it uses. @Dzahn suggested that we used a fqdn as the first listenAddress to work around gerrit init to insert a dupe ipv6. But that was a fragile/undocumented hack.

I think I might switch to have Gerrit to listen on all address then add some firewall rules to only allow connections from the service IPs.

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

[operations/puppet@production] gerrit: listen on all address with iptables rule

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

Change 706042 merged by Dzahn:

[operations/puppet@production] gerrit: config values do not need double quotes

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

Change 706043 merged by Dzahn:

[operations/puppet@production] gerrit: remove SMTP encryption option

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

After doing some grepping, it seems like the current on-disk config matches except for the listenAddress. Does gerrit init get rid of the ip4 listening address?

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

[operations/puppet@production] Revert \"gerrit: daemon option in gerrit.config\"

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

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

[operations/puppet@production] gerrit: remove unused settings from [container]

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

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

[operations/puppet@production] gerrit: remove unused container.javaOptions values

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

Change 708102 merged by Jbond:

[operations/puppet@production] Revert \"gerrit: daemon option in gerrit.config\"

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

Mentioned in SAL (#wikimedia-operations) [2021-07-26T15:29:18Z] <hashar> Restarted gerrit replica on gerrit2001.wikimedia.org # T287122

Change 708103 merged by Dzahn:

[operations/puppet@production] gerrit: remove unused settings from [container]

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

Change 708104 merged by Dzahn:

[operations/puppet@production] gerrit: remove unused container.javaOptions values

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

Change 706049 merged by Dzahn:

[operations/puppet@production] gerrit: listen on all address with iptables rule

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

After the last puppet change got deployed, on gerrit2001 I have:

  • stopped Gerrit
  • java -jar bin/gerrit.war init --batch
  • run puppet

There are still two differences:

Notice: /Stage[main]/Gerrit::Jetty/File[/var/lib/gerrit2/review_site/etc/gerrit.config]/mode: mode changed '0644' to '0444' (corrective)

@@ -251,7 +251,6 @@
     mac = -hmac-md5-96
     threads = 28
     batchThreads = 4
-	listenAddress = *:29418
 [theme]
     backgroundColor = fff
     topMenuColor = fff

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

[operations/puppet@production] gerrit: explicitly set `sshd.listenAddress`

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

Change 709469 merged by Dzahn:

[operations/puppet@production] gerrit: explicitly set `sshd.listenAddress`

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

hashar claimed this task.

Solved and verified with @Dzahn! Danke!