Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build patch to prevent rake task assets:compile to remove assets dir #2884

Conversation

kkimurak
Copy link
Contributor

Close #2866

GitLab does not launch after second run if relative url is used. This is caused by following upstream change to remove assets directory on assets compile. See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/103715

First contained in v15.6.0 release

$ git -C ../gitlab.git/ tag --contains e46d92c0 | sort --version-sort | head -n 1
v15.6.0-ee

Issue backtrace:

  1. sameersbn/gitlab create symbolic link /home/git/gitlab/public/assets/ to point /home/git/data/tmp/assets if relative url is used. This is to store assets in the docker volume to avoid unnecessary recompilations. These assets are removed and recompiled only when the gitlab version or relative url root is changed.
  2. By the change provided by gitlab.com/gitlab-org/gitlab!103715, rake task gitlab:assets:compile became to remove assets directory directly (by FileUtils.rm_rf()). It does not remove compiled assets itself, but remove symlink /home/git/gitlab/public/assets . Then it compiles assets as usual. These assets will be stored in newly-created normal directory /home/git/gitlab/public/assets/
  3. On container up, assets will be compiled if relative url root or version is changed.
  4. On container down, whole container statement (except volumes) will be reset. These compiled assets will be removed as well because they are not in docker volume.
  5. As we store version number and relative url root path to /home/git/data/tmp/, we cannot recognize we have to recompile assets (they are not modified, even assets themselves are removed).
    So we can say that it will launch successfully the first time, but will fail the next time.
  6. reports ENOENT of assets - of course this is really happen because they are removed

To avoid the issue, this PR add a build time patch to change the behavior of rake task gitlab:assets:compile to empty assets directory instead of removing itself.

GitLab does not launch after second run if relative url is used.
This is caused by following upstream change to remove assets directory on assets compile.
See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/103715

This is introduced on v15.6.0
````sh
$ git -C ../gitlab.git/ tag --contains e46d92c0 | sort --version-sort | head -n 1
v15.6.0-ee
````

1. `sameersbn/gitlab` create symbolic link /home/git/gitlab/public/assets/
  to point /home/git/data/tmp/assets if relative url is used.
  This is to store assets in the docker volume to avoid unnecessary recompilations.
  These assets are removed and recompiled only when the gitlab version or relative url root is changed.
2. By the change provided by gitlab.com/gitlab-org/gitlab!103715,
  rake task `gitlab:assets:compile` became to remove assets directory directly (by `FileUtils.rm_rf()`).
  It does not remove compiled assets itself, but remove symlink /home/git/gitlab/public/assets .
  Then it compiles assets as usual, but they will be stored in newly-created normal directory /home/git/gitlab/public/assets/
3. On container down, whole container statement (except volumes) will be reset.
  These compiled assets will be removed as well because they are not in docker volume.
4. As we store version info and relative url root path to /home/git/data/tmp/,
  we cannot recognize we have to recompile assets (that have been removed by mistake)

To avoid the issue, this commit add a build time patch to change the behavior of rake task `gitlab:assets:compile`
to empty assets instead of removing assets directory itself.
@kkimurak kkimurak force-pushed the issue/2866-fix-assets_webpack_manifest.json-not-found branch from 4d4698e to 3885a45 Compare January 18, 2024 09:10
@kkimurak
Copy link
Contributor Author

kkimurak commented Jan 18, 2024

Oops build fail with Errno::ENOENT: No such file or directory @ dir_initialize - public/assets.
I have forgotten to check if assets directory exists before iterating its children..
Updated and force-pushed.

@kkimurak
Copy link
Contributor Author

OK, build succeed.

@sachilles
Copy link
Collaborator

@kkimurak Thanks for this excellent work!

@sachilles sachilles merged commit 5b09272 into sameersbn:master Jan 19, 2024
3 checks passed
@kkimurak kkimurak deleted the issue/2866-fix-assets_webpack_manifest.json-not-found branch January 20, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENOENT: No such file or directory
2 participants