‘bundle exec rake themes:update assets:precompile’ 실행으로 인해 Launcher Rebuild 실패

새로운 Discourse Docker 이미지를 빌드하고 있는데, migrate 단계에서 실패하는 것 같습니다.

    I, [2020-12-15T15:02:28.688540 #1] INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'

    I, [2020-12-15T15:04:19.530701 #1] INFO -- :

    I, [2020-12-15T15:04:19.530966 #1] INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile'

    Purging temp files

    Bundling assets

    I, [2020-12-15T15:04:36.448680 #374] INFO -- : Writing /var/www/discourse/public/assets/vendor-bdb3fefe8aefde7bf6aef331a6edd24482502b370ed9f6f299836c72ee6a843c.js

    I, [2020-12-15T15:04:43.818563 #374] INFO -- : Writing /var/www/discourse/public/assets/admin-073db5e5695d9f3834b9ad41d66ef30a02b9ca85fc9c95f272257ea9c7a67f21.js

    I, [2020-12-15T15:04:43.822864 #374] INFO -- : Writing /var/www/discourse/public/assets/browser-detect-115ab5953de1b5bb122bfb26b757f5391dd8d1d2aef2b81baf7b59aee99d9f34.js
.
.
.
.
.
.
.
.
.
.
.

    35:M 15 Dec 2020 15:06:27.009 * 10 changes in 300 seconds. Saving...

    35:M 15 Dec 2020 15:06:27.010 * Background saving started by pid 1066

    1066:C 15 Dec 2020 15:06:27.010 # Failed opening the RDB file dump.rdb (in server root dir /pups) for saving: Permission denied

    35:M 15 Dec 2020 15:06:27.110 # Background saving error

    35:M 15 Dec 2020 15:06:33.020 * 10 changes in 300 seconds. Saving...

    35:M 15 Dec 2020 15:06:33.020 * Background saving started by pid 1067

    1067:C 15 Dec 2020 15:06:33.020 # Failed opening the RDB file dump.rdb (in server root dir /pups) for saving: Permission denied

    35:M 15 Dec 2020 15:06:33.121 # Background saving error

    35:M 15 Dec 2020 15:06:39.030 * 10 changes in 300 seconds. Saving...

    35:M 15 Dec 2020 15:06:39.031 * Background saving started by pid 1068

    1068:C 15 Dec 2020 15:06:39.031 # Failed opening the RDB file dump.rdb (in server root dir /pups) for saving: Permission denied

    35:M 15 Dec 2020 15:06:39.131 # Background saving error

    gzip -f -c -9 /var/www/discourse/public/assets/application-42d4413fabab7a4b12e0c25fb01f736af560aa283089071a8493f37c9b042a4a.js > /var/www/discourse/public/assets/application-42d4413fabab7a4b12e0c25fb01f736af560aa283089071a8493f37c9b042a4a.js.gz

    brotli -f --quality=11 /var/www/discourse/public/assets/application-42d4413fabab7a4b12e0c25fb01f736af560aa283089071a8493f37c9b042a4a.js --output=/var/www/discourse/public/assets/application-42d4413fabab7a4b12e0c25fb01f736af560aa283089071a8493f37c9b042a4a.js.br

    35:M 15 Dec 2020 15:06:45.041 * 10 changes in 300 seconds. Saving...

    35:M 15 Dec 2020 15:06:45.042 * Background saving started by pid 1072

    1072:C 15 Dec 2020 15:06:45.042 # Failed opening the RDB file dump.rdb (in server root dir /pups) for saving: Permission denied

    35:M 15 Dec 2020 15:06:45.142 # Background saving error

    Done compressing application-42d4413fabab7a4b12e0c25fb01f736af560aa283089071a8493f37c9b042a4a.js : 25.87 secs

    Done compressing all JS files : 83.62 secs

    Start compiling CSS: 2020-12-15 15:06:49 UTC

    Compiling css for default 2020-12-15 15:06:49 UTC

    precompile target: desktop Dark

    35:M 15 Dec 2020 15:06:51.051 * 10 changes in 300 seconds. Saving...

    35:M 15 Dec 2020 15:06:51.051 * Background saving started by pid 1074

    1074:C 15 Dec 2020 15:06:51.051 # Failed opening the RDB file dump.rdb (in server root dir /pups) for saving: Permission denied

    35:M 15 Dec 2020 15:06:51.151 # Background saving error

    rake aborted!

    Redis::CommandError: ERR Error running script (call to f_45fe64238f6598e6c505af0aad74b4e178e891f4): @user_script:14: @user_script: 14: -MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis/client.rb:132:in `call'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-2.2.0/lib/mini_profiler/profiling_methods.rb:85:in `block in profile_method'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis.rb:2585:in `block in _eval'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis.rb:69:in `block in synchronize'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis.rb:69:in `synchronize'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis.rb:2584:in `_eval'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.5/lib/redis.rb:2636:in `evalsha'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/message_bus-3.3.4/lib/message_bus/backends/redis.rb:425:in `cached_eval'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/message_bus-3.3.4/lib/message_bus/backends/redis.rb:144:in `publish'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/message_bus-3.3.4/lib/message_bus.rb:382:in `publish'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/message_bus-3.3.4/lib/message_bus/distributed_cache.rb:80:in `publish'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/message_bus-3.3.4/lib/message_bus/distributed_cache.rb:90:in `set'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/message_bus-3.3.4/lib/message_bus/distributed_cache.rb:135:in `[]='

    /var/www/discourse/app/models/theme.rb:142:in `get_set_cache'

    /var/www/discourse/app/models/theme.rb:158:in `components_for'

    /var/www/discourse/app/models/theme.rb:185:in `block in transform_ids'

    /var/www/discourse/app/models/theme.rb:142:in `get_set_cache'

    /var/www/discourse/app/models/theme.rb:177:in `transform_ids'

    /var/www/discourse/app/models/theme.rb:371:in `list_baked_fields'

    /var/www/discourse/app/models/theme.rb:367:in `resolve_baked_field'

    /var/www/discourse/lib/stylesheet/manager.rb:423:in `color_scheme_digest'

    /var/www/discourse/lib/stylesheet/manager.rb:361:in `digest'

    /var/www/discourse/lib/stylesheet/manager.rb:339:in `stylesheet_filename'

    /var/www/discourse/lib/stylesheet/manager.rb:300:in `source_map_filename'

    /var/www/discourse/lib/stylesheet/manager.rb:251:in `compile'

    /var/www/discourse/lib/stylesheet/manager.rb:169:in `block (2 levels) in precompile_css'

    /var/www/discourse/lib/stylesheet/manager.rb:162:in `each'

    /var/www/discourse/lib/stylesheet/manager.rb:162:in `block in precompile_css'

    /var/www/discourse/lib/stylesheet/manager.rb:161:in `each'

    /var/www/discourse/lib/stylesheet/manager.rb:161:in `precompile_css'

    /var/www/discourse/lib/tasks/assets.rake:54:in `block (2 levels) in <main>'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rails_multisite-2.5.0/lib/rails_multisite/connection_management.rb:76:in `with_connection'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rails_multisite-2.5.0/lib/rails_multisite/connection_management.rb:86:in `each_connection'

    /var/www/discourse/lib/tasks/assets.rake:47:in `block in <main>'

    /var/www/discourse/lib/tasks/assets.rake:331:in `block in <main>'

    /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'

    /usr/local/bin/bundle:23:in `load'

    /usr/local/bin/bundle:23:in `<main>'

    Tasks: TOP => assets:precompile:css

    (See full trace by running task with --trace)

    I, [2020-12-15T15:06:53.012968 #1] INFO -- : Downloading MaxMindDB...

    Compressing Javascript and Generating Source Maps

    I, [2020-12-15T15:06:53.013385 #1] INFO -- : Terminating async processes

    I, [2020-12-15T15:06:53.013424 #1] INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 35

    35:signal-handler (1608044813) Received SIGTERM scheduling shutdown...

    35:M 15 Dec 2020 15:06:53.054 # User requested shutdown...

    35:M 15 Dec 2020 15:06:53.054 * Saving the final RDB snapshot before exiting.

    35:M 15 Dec 2020 15:06:53.054 # Failed opening the RDB file dump.rdb (in server root dir /pups) for saving: Permission denied

    35:M 15 Dec 2020 15:06:53.054 # Error trying to save the DB, can't exit.

    35:M 15 Dec 2020 15:06:53.054 # SIGTERM received but errors trying to shut down the server, check the logs for more information

    35:M 15 Dec 2020 15:06:57.060 * 10 changes in 300 seconds. Saving...

    35:M 15 Dec 2020 15:06:57.060 * Background saving started by pid 1078

    1078:C 15 Dec 2020 15:06:57.061 # Failed opening the RDB file dump.rdb (in server root dir /pups) for saving: Permission denied

    35:M 15 Dec 2020 15:06:57.161 # Background saving error

    I, [2020-12-15T15:07:03.014092 #1] INFO -- : exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid:35 did not terminate cleanly, forcing termination!

    FAILED

    --------------------

    Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile' failed with return #<Process::Status: pid 372 exit 1>

    Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'

    exec failed with the params {"cd"=>"$home", "hook"=>"assets_precompile", "cmd"=>["su discourse -c 'bundle exec rake themes:update assets:precompile'"]}

    be9c92f00a4814e5e9ebcdb06f25232b03f7522390b97c157085c2f7ef7f3387

    ** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.

    간결하게 말하자면, 저는 다음과 같은 오류를 보고 있습니다.

    68:C 15 Dec 2020 15:06:39.031 # Failed opening the RDB file dump.rdb (in server root dir /pups) for saving: Permission denied

    35:M 15 Dec 2020 15:06:39.131 # Background saving error

    35:M 15 Dec 2020 15:06:51.051 * Background saving started by pid 1074

    1074:C 15 Dec 2020 15:06:51.051 # Failed opening the RDB file dump.rdb (in server root dir /pups) for saving: Permission denied

    35:M 15 Dec 2020 15:06:51.151 # Background saving error

    rake aborted!

    Redis::CommandError: ERR Error running script (call to f_45fe64238f6598e6c505af0aad74b4e178e891f4): @user_script:14: @user_script: 14: -MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

제 app.yaml 파일은 다음과 같습니다.

templates:
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/redis.template.yml"
env:
  LANG: en_US.UTF-8
  UNICORN_WORKERS: 8
  DISCOURSE_DB_USERNAME: discourse
  DISCOURSE_DB_PASSWORD: "xxxxx"
  DISCOURSE_DB_HOST: "xxxxx"
  DISCOURSE_REDIS_HOST: 127.0.0.1
  DISCOURSE_REDIS_PORT: "6379"
  DISCOURSE_DB_NAME:  discourse_prod_2
  DISCOURSE_DEVELOPER_EMAILS: 'xxxxxxx'
  DISCOURSE_HOSTNAME: 'localhost'
  DISCOURSE_DB_PORT: "5301"  
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - mkdir -p plugins
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-voting.git
          - git clone https://github.com/discourse/discourse-slack-official.git
          - git clone https://github.com/discourse/discourse-assign.git
run:
  - exec:
      cd: /var/www/discourse
      cmd:
        - sed -i 's/GlobalSetting.serve_static_assets/true/' config/environments/production.rb

보안을 위해 비밀번호, 호스트명, 이메일은 숨겼습니다. Redis는 별도의 Docker 컨테이너를 실행하고 있습니다. localhost와 지정된 포트에서 연결할 수 있습니다.

무엇을 놓치고 있는지 알려주시면 좋겠습니다.

별도의 컨테이너에서 실행 중이라면 app.yml에서 다음 줄을 제거해야 합니다.

- "templates/redis.template.yml"

외부 Redis가 잘못 구성되었거나 I/O 대기 압력이 높아 이 문제가 발생하고 있습니다. 이를 수정해야 합니다.

@Falco 파일에서 Redis 호스트와 포트를 제거하여 기본 Redis를 사용해도 동일한 오류가 발생합니다

sets',url='/assets/application-42d4413fabab7a4b12e0c25fb01f736af560aa283089071a8493f37c9b042a4a.js.map'"

35:M 15 Dec 2020 16:43:25.078 * 10 changes in 300 seconds. Saving...

35:M 15 Dec 2020 16:43:25.079 * Background saving started by pid 1064

1064:C 15 Dec 2020 16:43:25.079 # Failed opening the RDB file dump.rdb (in server root dir /pups) for saving: Permission denied

35:M 15 Dec 2020 16:43:25.179 # Background saving error 

Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile' failed with return #<Process::Status: pid 371 exit 1>

Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'

exec failed with the params {"cd"=>"$home", "hook"=>"assets_precompile", "cmd"=>["su discourse -c 'bundle exec rake themes:update assets:precompile'"]}

d514879d2a044425c1e7d833dafb8196ae0a3026aa75119512349188531b2a5d

파일 권한이 손상되었습니다. Redis가 자체 덤프 파일을 열 수 없습니다.

@Falco 하지만 이것은 discourse 도커가 이미지를 빌드하는 동안 내부에서 발생하는 것입니다. 어떻게 변경할 수 있을까요?

app.yml에 redis 템플릿을 다시 추가하셨나요?

해당 파일은 644 권한으로 UID 106 \ GID 110이 소유하고 있으며 /var/discourse/shared/standalone/redis_data/dump.rdb에 위치해 있습니다.

이 파일의 권한을 수동으로 변경하셨고, 다른 파일들도 마찬가지일 수 있는 것 같습니다.

아직 이미지를 빌드하지도 않았는데, 어떻게 변경될 수 있는지 여전히 이해가 되지 않습니다. 파일에 redis.template.yml을 추가해 두었습니다.

templates:
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/redis.template.yml"
env:
  LANG: en_US.UTF-8
  UNICORN_WORKERS: 8
  DISCOURSE_DB_USERNAME: discourse
  DISCOURSE_DB_PASSWORD: "xxxxx"
  DISCOURSE_DB_HOST: "xxxxx"
  DISCOURSE_DB_NAME:  discourse_prod_2
  DISCOURSE_DEVELOPER_EMAILS: 'xxxxxxx'
  DISCOURSE_HOSTNAME: 'localhost'
  DISCOURSE_DB_PORT: "5301"  
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - mkdir -p plugins
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-voting.git
          - git clone https://github.com/discourse/discourse-slack-official.git
          - git clone https://github.com/discourse/discourse-assign.git
run:
  - exec:
      cd: /var/www/discourse
      cmd:
        - sed -i 's/GlobalSetting.serve_static_assets/true/' config/environments/production.rb

그러나 저는 루트 사용자로 ./launcher rebuild를 실행하고 있습니다. 이것이 이 문제에 영향을 미칠까요?

이제 영향을 받은 파일의 권한을 수동으로 수정해야 합니다.

postgres와 redis를 각각 별도의 컨테이너로 빌드하고 app.yml에서 "templates/redis.template.yml" 줄을 제거한 후 문제가 해결되었습니다.