유효한 키를 사용해도 maxmind db 다운로드 실패, 컨테이너 내부에서는 DB 다운로드 가능

이 문제로 인해 빌드가 실패했습니다. ENV 변수를 제거하고 이를 사용하지 않은 상태로 다시 빌드했습니다. 그런 다음 컨테이너 안에서 디버깅을 시작했습니다. discourse.conf에 키를 추가했는데도 여전히 실패합니다.

(다행히도 클라이언트에게 잘못된 키를 제공했다고 알리기 전에 이 작업을 수행했습니다!)

rake 태스크에 puts를 추가하여 데이터베이스를 다운로드하려고 하는 URL을 다음과 같이 출력하도록 했습니다:

    url =
      "https://download.maxmind.com/app/geoip_download?license_key=#{GlobalSetting.maxmind_license_key}&edition_id=#{name}&suffix=tar.gz"

    gz_file =
      FileHelper.download(
        url,
        max_file_size: 100.megabytes,
        tmp_file_name: "#{name}.gz",
        validate_uri: false,
        follow_redirect: false,
      )

    if gz_file.nil?
      puts "no gzfile"
    end
    puts "Got file #{gz_file} for #{url}"
    filename = File.basename(gz_file.path)

이제 다음과 같은 결과를 얻습니다:

root@web-only:/var/www/discourse# rake maxminddb:get
Plugin name is 'discourse-topic-voting', but plugin directory is named 'discourse-voting'
Downloading MaxMindDb's GeoLite2-City...
no gzfile
Got file  for https://download.maxmind.com/app/geoip_download?license_key=VALID_KEY_IS_HERE&edition_id=GeoLite2-City&suffix=tar.gz
rake aborted!
NoMethodError: undefined method `path' for nil:NilClass (NoMethodError)

    filename = File.basename(gz_file.path)
                                    ^^^^^
/var/www/discourse/lib/discourse_ip_info.rb:52:in `mmdb_download'
/var/www/discourse/lib/tasks/maxminddb.rake:9:in `block (2 levels) in <main>'
/var/www/discourse/lib/tasks/maxminddb.rake:7:in `each'
/var/www/discourse/lib/tasks/maxminddb.rake:7:in `block in <main>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => maxminddb:get
(See full trace by running task with --trace)

Maxmind에 의해 사이트가 차단되어 문제가 발생한 다른 토픽이 있어서, 해당 서버의 컨테이너 안에서 wget을 사용하여 해당 URL을 성공적으로 다운로드해 보았습니다.

FileHelper.download는 결국 Helper가 아니라, 파일 대신 nil을 조용히 반환하는 것 같습니다. 파일은 단 44MB이므로 용량 문제가 아닙니다. wget으로 전체 헤더를 확인해 봤을 때 리다이렉트는 보이지 않습니다.

이것이 어떤 문제일 수 있는지 아이디어가 있을까요?

이 에러를 잡아(invalid key로 빌드가 완료되도록) 처리하지 않는 이유가 있을까요? 아마 경고만 출력하면 되지 않을까요?

1개의 좋아요

follow_redirect: true를 사용하면 더 잘 작동하나요?

최근 변경 사항에 따라 MaxMind가 다운로드 URL을 변경했지만, 리다이렉트를 허용하는 한 원래 URL을 계속 사용할 수 있습니다.

2개의 좋아요

오해가 있어서 5월 1일에 시작되는 게 아닌 건 아닌지 궁금하다. :thinking:

2개의 좋아요

오. 네. 왜 그걸 그냥 바꾸지 않고 리다이렉트가 안 되는 줄 알았는지 모르겠네요.

4개의 좋아요

좋아요, 병합했습니다. 진행 상황 알려주세요!

3개의 좋아요

포럼의 MaxMind 키를 다시 사용하도록 설정해 봤지만, 재구성을 시도할 때 여전히 원래의 오류가 발생합니다.

1개의 좋아요

최신 Discourse 버전을 사용 중인지 확인해 주시겠어요? Jay에게는 정상적으로 작동하고 있고, MaxMind의 권장 사항을 따르고 있으므로 당신에게도 작동하지 않을 이유는 없다고 생각됩니다. :thinking:

1개의 좋아요

앱을 다시 빌드할 때 최신 버전이 아닐 리가 없는데 어떻게 그런 일이 생길지 모르겠네요.

맞아요. 하지만 알 수 없는 법이죠. :smile: 표시된 해시 버전은 무엇인가요? 최소한 그것만은 바로 확인할 수 있습니다.

MaxMind의 공지사항을 다시 읽어보았지만, URL 변경이나 리다이렉트 허용 외에 다른 내용은 보이지 않습니다. :thinking:

1개의 좋아요

tests-passed인지 latest-release인지 어떤 것을 실행하고 계신가요?

현재 tests-passed 상태입니다. 제 지식 범위 내에서는 그렇습니다.

소스를 볼 때 커밋을 가져오려면 URL이 뭔가요?

크래시된 빌드의 로그 끝부분:

Downloading MaxMindDB...
Compressing Javascript and Generating Source Maps
I, [2024-03-26T13:27:38.305597 #1] INFO -- : Terminating async processes
I, [2024-03-26T13:27:38.307312 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 42
I, [2024-03-26T13:27:38.307891 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 111
111:signal-handler (1711459658) Received SIGTERM scheduling shutdown...
2024-03-26 13:27:38.307 UTC [42] LOG:  received fast shutdown request
2024-03-26 13:27:38.314 UTC [42] LOG:  aborting any active transactions
2024-03-26 13:27:38.321 UTC [42] LOG:  background worker "logical replication launcher" (PID 51) exited with exit code 1
2024-03-26 13:27:38.322 UTC [46] LOG:  shutting down
111:M 26 Mar 2024 13:27:38.353 # User requested shutdown...
111:M 26 Mar 2024 13:27:38.353 * Saving the final RDB snapshot before exiting.
2024-03-26 13:27:38.415 UTC [42] LOG:  database system is shut down
111:M 26 Mar 2024 13:27:39.896 * DB saved on disk
111:M 26 Mar 2024 13:27:39.896 # Redis is now ready to exit, bye bye...
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake themes:update assets:precompile' failed with return #<Process::Status: pid 3889 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"assets_precompile", "cmd"=>["su discourse -c 'bundle exec rake themes:update assets:precompile'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
fe4eec7726fdbe08aaa2691e806bb17423a8f4eaedb8414397e3097d725e04c7

커밋: https://github.com/discourse/discourse/commits/f350cea5d2

나중에 덧붙이자면, 이 문제가 발생한 사이트를 링크하지 않은 이유는, 해당 서버의 별도 컨테이너에서 스태프 중 한 명이 커널 버그를 테스트하던 중 실수로 서버 전체를 크래시 시켰기 때문에, 사이트를 링크해도 아무런 도움이 되지 않았을 것이기 때문입니다.

1개의 좋아요

@Firepup650 님, 아직도 그런 일이 일어나나요?

일부러 리빌드를 해보고 싶었으니, 한 번 돌려볼게.

1개의 좋아요

확인했습니다. 더 이상 문제가 발생하지 않습니다. 이제 포럼이 정상적으로 재구성됩니다.

4개의 좋아요

이 주제는 26시간 후 자동으로 닫혔습니다. 새로운 답글은 더 이상 허용되지 않습니다.