Page MenuHomePhabricator

Git submodules initialized with wrong URL
Closed, ResolvedPublic

Description

Jenkins git plugin has an issue that prevents us from using submodules in the two repositories. The plugin set the URL for the submodules to be /var/lib/zuul/git/... instead of the supplied url in .gitmodules.

Running "git submodule sync" does fix it though.

I had to disable two Analytics jobs because of that. https://gerrit.wikimedia.org/r/38097


Version: unspecified
Severity: major

Details

Reference
bz42953

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 1:03 AM
bzimport set Reference to bz42953.

This seems to come from https://github.com/jenkinsci/git-plugin/commit/8fcff2a227cbd8e01ac2b6164c1aee0ef8243613 which rewrite the submodules URL whenever the origin repository is not a bare repository :(

Created attachment 11498
output of failing build with git non bare repo

Example output for the failure:

https://integration.mediawiki.org/ci/view/All-disabled/job/analytics-webstatscollector/3/console

attachment file_42953.txt ignored as obsolete

Created attachment 11499
code for Jenkins Git Plugin fixSubmoduleUrls()

The code is in https://github.com/jenkinsci/git-plugin.git src/main/java/hudson/plugins/git/GitAPI.java function fixSubmoduleUrls().

attachment file_42953.txt ignored as obsolete

The workaround is to disable submodule processing in the Git plugin and process them manually using: git submodule sync && git submodule update --init.

I have done so for the webstatscollector and udp-filters project of the Analytics team: https://gerrit.wikimedia.org/r/38497

This is happening again and the workaround of comment #4 can not realistically be used nowadays.

An example of failure is https://integration.wikimedia.org/ci/job/operations-puppet-doc/2564/console

It clones operations/puppet.git from /srv/ssd/zuul/git/operations/puppet (that is the Zuul maintained repository.

The repository as several submodules declared as:

[submodule "modules/cdh4"]
    path = modules/cdh4
    url = https://gerrit.wikimedia.org/r/operations/puppet/cdh4

The Jenkins git plugin tries to be smart and dynamically rewrite the submodule URL supposing it is a subfolder:

FATAL: Command "git submodule update" returned status code 1:
fatal: repository '/srv/ssd/zuul/git/operations/puppet/modules/cdh4' does not exist
Clone of '/srv/ssd/zuul/git/operations/puppet/modules/cdh4' \

into submodule path 'modules/cdh4' failed

That is really dumb :-(

Created attachment 13375
Jenkins git plugin 1.5 documentation regarding submodule fetching (HTML)

HTML doc from Jenkins

Attached:

If the remote is /srv/ssd/zuul/git/$ZUUL_PROJECT , that translates to:

/srv/ssd/zuul/git/operations/puppet

Being a local URL, Jenkins use 'git rev-parse --is-bare-repository' which returns false (Zuul creates working repos since it merges submitted patches on top of master). Being a non-bar repository, Jenkins assume the submodules have been fetched there and will rewrite the submodules URLs:

<li>If the super-project is <b>not</b> bare, it is assumed that the

repository has each of its submodules cloned and checked out appropriately.
Thus, the submodules will be taken directly from a path like
<code>${SUPER_PROJECT_URL}/${SUBMODULE}</code>, rather than relying on
information from <i>.gitmodules</i>.</li>

The definitive fix is to never use /srv/ssd/zuul/git/ as a git URL whenever we have submodules. Instead we can use git://integration.wikimedia.org/... and use /srv/ssd/gerrit/git as a reference to speed up thing.

I have manually updated the operations-puppet-doc job to use the git:// URL, and that fixed the issue. Looking at the config files, the following jobs still reference /srv/ssd/zuul for a git repository and thus need to be updated in Jenkins job builder:

analytics-libanon
analytics-udp-filters
analytics-webstatscollector
analytics-wikistats
integration-jjb-config-test
mediawiki-core-doxygen-publish
mediawiki-core-install-sqlite
mediawiki-core-jsduck
mediawiki-core-jsduck-publish
mediawiki-core-lint
mediawiki-core-qunit
mediawiki-core-regression-master
mediawiki-core-regression-REL1_19
mediawiki-core-regression-REL1_20
mediawiki-core-regression-REL1_21
mwext-DonationInterface-runtests
mwext-Wikibase-server-tests
operations-puppet-doc
operations-puppet-spec
phpcomponent-Diff-phpunit
test-mediawiki-dumpenv
test-mediawiki-phpcs-HEAD
test-phpunit-on-slave

Whenever one of those job uses submodules, it will end up failing to clone the submodule due to the path rewriting :(

Change 85972 had a related patch set uploaded by Hashar:
point operations-puppet-doc to git:// url

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

The analytics job are not in JJB.

integration-jjb-config-test does not have submodules

mediawiki-core-* jobs have submodules disabled (the wmf branches containing submodules, that ends up being toooo slow).

mwext-DonationInterface-runtests mwext-Wikibase-server-tests are on repositories not having submodules.

The rest are experiments:
operations-puppet-spec
phpcomponent-Diff-phpunit
test-mediawiki-dumpenv
test-mediawiki-phpcs-HEAD
test-phpunit-on-slave

Change 85972 merged by jenkins-bot:
point operations-puppet-doc to git:// url

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

Change 88993 had a related patch set uploaded by Hashar:
point operations-puppet-rspec to git:// url

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

Change 88993 merged by jenkins-bot:
point operations-puppet-rspec to git:// url

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