Page MenuHomePhabricator

Convert gerrit-theme to Polymer 3
Closed, ResolvedPublic

Description

Gerrit requires plugins to be converted from HTML to Javascript. A first attempt was made with https://gerrit.wikimedia.org/r/c/operations/puppet/+/678646 but got reverted. We have since upgraded to Gerrit 3.3 and the gerrit-theme.js shipped by that reverted commit is still on the server and takes precedence over the gerrit-theme.html. So essentially the conversion is done.

I independently gave it a try this morning on my local machine with https://gerrit.wikimedia.org/r/c/operations/software/gerrit/+/756109 . In the web ui it showed:

Plugin install error: Unrecognized plugin path /static/gerrit-theme.html from /static/gerrit-theme.html

The file that fails to load comes from Puppet: modules/gerrit/files/homedir/review_site/static/gerrit-theme.html which I guess is an HTML plugin for which support is removed in 3.4 https://www.gerritcodereview.com/3.4.html#html-plugin-support-is-removed. @Paladox you told me about it, have you ever made a patch to migrate or do you have any guidance as to what needs to be done? :]

HTML plugins should be migrated to JavaScript plugins. This also implies Polymer 2 plugins wouldn’t work any more. See also this announcement for more details.

From the javascript console:

initResin
TypeError: URL constructor: /static/gerrit-theme.html is not a valid URL.
    Na http://127.0.0.1:8080/elements/gr-app.js:1
    _getPluginKeyFromUrl http://127.0.0.1:8080/elements/gr-app.js:317
    _updatePluginState http://127.0.0.1:8080/elements/gr-app.js:317
    _failToLoad http://127.0.0.1:8080/elements/gr-app.js:317
    loadPlugins http://127.0.0.1:8080/elements/gr-app.js:317
    loadPlugins http://127.0.0.1:8080/elements/gr-app.js:317
...
Plugin loaded separately: /static/gerrit-theme.html
Runtime info
Gerrit UI (PolyGerrit)
Gerrit Server Version: f712a44

Plugin codemirror-editor installed. gr-app.js:317:14209
Plugin delete-project installed. gr-app.js:317:14209
Plugin lfs installed. gr-app.js:317:14209
Plugin reviewers installed. gr-app.js:317:14209
Plugin zuul installed.

Related Objects

Event Timeline

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

[operations/puppet@production] gerrit: port our theme to JavaScript

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

https://gerrit.wikimedia.org/r/c/operations/puppet/+/678646 got reverted however on the server the .js file is still present:

md5sum /var/lib/gerrit2/review_site/static/gerrit-theme*
a0b45d4f929a36b010f89b4755e95962  /var/lib/gerrit2/review_site/static/gerrit-theme.html
3f6f78618881137e26eb730d6e8fb050  /var/lib/gerrit2/review_site/static/gerrit-theme.js

Checking a web request, I have confirmed the .js file is used rather than the .html file. So essentially the conversion has already happened as part of upgrading from Gerrit 3.2 to 3.3. The upstream change is: https://gerrit-review.googlesource.com/c/gerrit/+/273355/5/java/com/google/gerrit/server/restapi/config/GetServerInfo.java which made the js file to take precedence and has been released with 3.3.0:

   private String getDefaultTheme() {
     if (config.getString("theme", null, "enableDefault") == null) {
       // If not explicitly enabled or disabled, check for the existence of the theme file.
-      return Files.exists(sitePaths.site_theme) ? DEFAULT_THEME : null;
+      return Files.exists(sitePaths.site_theme_js)
+          ? DEFAULT_THEME_JS
+          : Files.exists(sitePaths.site_theme) ? DEFAULT_THEME : null;
     }

The conversion has been done by @Paladox and is already deployed (albeit by mistake). The Puppet change I have send restore the patch by Paladox with an extra bit to ensure gerrit-theme.html is purged from the servers.

Change 756111 merged by Jbond:

[operations/puppet@production] gerrit: Convert gerrit-theme to Polymer 3

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

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

[operations/puppet@production] gerrit: gerrit-theme.html is long gone

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

Change 832343 merged by Dzahn:

[operations/puppet@production] gerrit: gerrit-theme.html is long gone

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