Cache doesn't track files in Git submodules folder
Summary
For a larger C++ project, we use the cache feature to reduce the compile time significantly by caching build products and let them propagate from pipeline to pipeline (and reset the Runner Caches if everything goes wrong). The problem is: the project uses some other libraries which are added as Git submodules and the build products of those projects are skipped by the cache. This means that a large part of the main C++ project has to be rebuilt every time.
Steps to reproduce
I created two projects on our GitLab installation to demonstrate the problem.
Example Project
One is called A Submodule
and contains a simple script which will produce a date.log
with the current date, or print "Nothing" if there is already a log.
https://git.km3net.de/examples/a-submodule
The other is called Cache Demo
and has A Submodule
configured as a Git submodule.
https://git.km3net.de/examples/cache-demo
What is the current bug behavior?
The file which is produces by the submodule inside the submodules folder (externals/a-submodule
) is found by the cache (it seems so, since it prints "untracked: found 1 files
"), as seen in the pipeline output here:
https://git.km3net.de/examples/cache-demo/-/jobs/11910
./externals
./externals/a-submodule
./externals/a-submodule/.git
./externals/a-submodule/do_something.sh
./.gitmodules
./.gitlab-ci.yml
$ cd externals/a-submodule
$ ./do_something.sh
Logging date
Creating cache master...
untracked: found 1 files
Archive is up to date!
Created cache
Job succeeded
When I run the pipeline again, it should extract the date.log
created by https://git.km3net.de/examples/a-submodule/blob/master/do_something.sh in the build
job https://git.km3net.de/examples/cache-demo/blob/master/.gitlab-ci.yml#L10:
https://git.km3net.de/examples/cache-demo/-/jobs/11911
Successfully extracted cache
$ find externals
externals
externals/a-submodule
externals/a-submodule/.git
externals/a-submodule/do_something.sh
$ cd externals/a-submodule
$ ./do_something.sh
Logging date
Creating cache master...
untracked: found 1 files
Archive is up to date!
Created cache
Job succeeded
However, it is not the case as you can see. It's also not listed by the find externals
command before.
What is the expected correct behavior?
The cache should catch untracked files in Git submodules folders and should print Nothing to do
in
https://git.km3net.de/examples/cache-demo/-/jobs/11911
It should also list date.log
after find externals
.
Output of checks
(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 2.5.3p105 Gem Version: 2.7.6 Bundler Version:1.16.6 Rake Version: 12.3.2 Redis Version: 3.2.12 Git Version: 2.18.1 Sidekiq Version:5.2.3 Go Version: unknown
GitLab information Version: 11.7.4-ee Revision: 3a39cd4 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql DB Version: 9.6.11 URL: https://git.km3net.de HTTP Clone URL: https://git.km3net.de/some-group/some-project.git SSH Clone URL: git@git.km3net.de:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: google_oauth2
GitLab Shell Version: 8.4.4 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 8.4.4 ? ... OK (8.4.4) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 4/1 ... yes 5/2 ... yes 6/3 ... yes 5/4 ... yes 5/5 ... yes 5/6 ... yes 5/7 ... yes 5/8 ... yes 5/9 ... yes 5/10 ... yes 5/11 ... yes 5/12 ... yes 5/13 ... yes 6/14 ... yes 7/15 ... yes 6/16 ... yes 6/17 ... yes 6/18 ... yes 6/19 ... yes 6/20 ... yes 77/21 ... yes 3/22 ... yes 3/23 ... yes 4/24 ... yes 3/25 ... yes 3/26 ... yes 3/27 ... yes 3/28 ... yes 3/29 ... yes 2/30 ... yes 3/31 ... yes 2/32 ... yes 2/33 ... yes 2/34 ... yes 15/36 ... yes 15/37 ... yes 15/38 ... yes 15/39 ... yes 2/41 ... yes 17/46 ... yes 17/47 ... yes 17/48 ... yes 15/49 ... yes 19/50 ... yes 19/51 ... yes 20/52 ... yes 20/54 ... yes 20/55 ... yes 20/56 ... yes 21/58 ... yes 15/59 ... yes 29/60 ... yes 34/61 ... yes 36/62 ... yes 22/63 ... yes 22/64 ... yes 32/66 ... yes 32/67 ... yes 41/68 ... yes 22/69 ... yes 22/70 ... yes 2/73 ... yes 11/75 ... yes 22/76 ... yes 36/77 ... yes 46/79 ... yes 46/80 ... yes 46/81 ... yes 46/82 ... yes 46/83 ... yes 46/84 ... yes 46/85 ... yes 41/86 ... yes 18/87 ... yes 18/88 ... yes 2/89 ... yes 43/90 ... yes 32/91 ... yes 6/92 ... yes 22/93 ... yes 6/95 ... yes 53/96 ... yes 6/98 ... yes 6/99 ... yes 53/100 ... yes 60/103 ... yes 22/104 ... yes 51/105 ... yes 6/106 ... yes 22/107 ... yes 3/108 ... yes 77/109 ... yes 56/114 ... yes 41/115 ... yes 65/116 ... yes 65/117 ... yes 65/118 ... yes 65/119 ... yes 65/120 ... yes 6/122 ... yes 35/123 ... yes 40/124 ... yes 6/125 ... yes 34/126 ... yes 6/127 ... yes 45/128 ... yes 67/129 ... yes 43/130 ... yes 22/131 ... yes 4/132 ... yes 69/133 ... yes 69/135 ... yes 46/136 ... yes 2/137 ... yes 29/138 ... yes 69/139 ... yes 28/140 ... yes 14/141 ... yes 6/142 ... yes 2/143 ... yes 10/144 ... yes 10/145 ... yes 34/146 ... yes 60/148 ... yes 6/149 ... yes 76/152 ... yes 3/154 ... yes 2/155 ... yes 73/157 ... yes 4/158 ... yes 2/159 ... yes 32/160 ... yes 74/161 ... yes 32/162 ... yes 81/163 ... yes 48/164 ... yes 75/165 ... yes 75/166 ... yes 76/167 ... yes 80/168 ... yes 2/169 ... yes 2/176 ... yes 2/177 ... yes 32/178 ... yes 89/180 ... yes 40/181 ... yes 75/182 ... yes 50/183 ... yes 75/184 ... yes 75/185 ... yes 75/186 ... yes 91/188 ... yes 92/189 ... yes 75/191 ... yes 22/192 ... yes 52/193 ... yes 34/194 ... yes 50/195 ... yes 2/196 ... yes 3/197 ... yes 2/198 ... yes 87/199 ... yes 46/200 ... yes 34/201 ... yes 88/203 ... yes 46/204 ... yes 2/205 ... yes 55/206 ... yes 46/207 ... yes 2/208 ... yes 51/209 ... yes 32/210 ... yes 34/211 ... yes 32/212 ... yes 22/214 ... yes 2/216 ... yes 98/217 ... yes 29/220 ... yes 65/221 ... yes 75/223 ... yes 75/224 ... yes 76/225 ... yes 76/227 ... yes 2/228 ... yes 76/234 ... yes 103/236 ... yes 75/237 ... yes 76/238 ... yes 76/239 ... yes 2/241 ... yes 76/242 ... yes 73/244 ... yes 103/246 ... yes 108/247 ... yes 104/248 ... yes 104/249 ... yes 104/250 ... yes 22/251 ... yes 103/253 ... yes 51/254 ... yes 2/255 ... yes 76/256 ... yes 2/257 ... yes 2/258 ... yes 46/259 ... yes 73/260 ... yes 73/261 ... yes 29/262 ... yes 29/263 ... yes 3/269 ... yes 2/271 ... yes 109/272 ... yes 106/273 ... yes 119/277 ... yes 92/278 ... yes 105/281 ... yes 51/283 ... yes 2/285 ... yes 2/286 ... yes 103/287 ... yes 2/289 ... yes 102/290 ... yes 22/291 ... yes 76/292 ... yes 75/293 ... yes 29/294 ... yes 87/295 ... yes 28/296 ... yes 28/297 ... yes 22/298 ... yes 43/299 ... yes 43/300 ... yes 2/301 ... yes 124/302 ... yes 102/303 ... yes 103/305 ... yes 103/306 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.5.3) Git version >= 2.18.0 ? ... yes (2.18.1) Git user has default SSH configuration? ... yes Active users: ... 107 Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
(If you can, link to the line of code that might be responsible for the problem)