首页 > 解决方案 > ddtrace Ruby gem 从 Ruby 2.5.8 升级到 2.6.6

问题描述

我正在一个有点旧的应用程序上将 Ruby 版本从 2.5 升级到 2.6。我们有一个通过 gitlab 部署到 kubernetes 的部署管道设置。

主要问题似乎在于尝试与其他服务的 TCP 连接,datadog(通过 ddtrace gem)是目前弹出的一个,而 AWS 连接发生了非常类似的错误。错误的相似之处是:

undefined method `<=' for 1024..65535:Range Did you mean? <=>

我从下面的 k8s pod 日志中粘贴了相关片段。我很感激任何关于在哪里寻找和提前尝试的帮助和建议。

E, [2021-06-29T18:22:14.438315 #1] ERROR -- ddtrace: [ddtrace] (/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-0.50.0/lib/ddtrace/transport/http/client.rb:35:in `rescue in send_request') Internal error during HTTP transport request. Cause: Failed to open TCP connection to {dd_host_url}:8126 (undefined method `<=' for 1024..65535:Range
Did you mean?  <=>) Location: /usr/local/lib/ruby/2.6.0/net/http.rb:949:in `rescue in block in connect'

[1] * Listening on http://0.0.0.0:3000
[1] ! WARNING: Detected 3 Thread(s) started in app boot:
[1] ! #<Thread:0x00007fafb759a5d8@/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:299 sleep> - /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:301:in `sleep'
[1] ! #<Thread:0x00007fafadf70d78@/app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:299 sleep> - /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:301:in `sleep'
[1] ! #<Thread:0x00007fafaa9343e0@Datadog::Workers::AsyncTransport@/app/vendor/bundle/ruby/2.6.0/gems/ddtrace-0.50.0/lib/ddtrace/workers.rb:73 sleep> - /app/vendor/bundle/ruby/2.6.0/gems/ddtrace-0.50.0/lib/ddtrace/workers.rb:116:in `sleep'
[1] Use Ctrl-C to stop
[1] - Worker 0 (PID: 35) booted in 0.01s, phase: 0
[1] - Worker 1 (PID: 42) booted in 0.0s, phase: 0
{"level":"ERROR","timestamp":"2021-06-29T18:23:31+00:00","application":"Community","environment":"production","message":"[f752a10a-09a0-47a8-9c2d-6e96e081b877] Failure in PriorityRedirector.matches? (0x3fd7d4314d7c) \nRecorded at /app/app/models/redirector.rb:104:in `rescue in matches?'\nin routes\nNoMethodError:undefined method `\u003c=' for 1024..65535:Range\nDid you mean?  \u003c=\u003e\napp/models/priority_redirector.rb:8:in `all_rules'\napp/models/redirector.rb:72:in `matching_path'\napp/models/redirector.rb:102:in `matches?'\nlib/spiceworks/reject_browser_prefetch.rb:34:in `call'\nlib/error_monitor.rb:16:in `call'"}
{"level":"ERROR","timestamp":"2021-06-29T18:23:31+00:00","application":"app_name","environment":"production","message":"[f752a10a-09a0-47a8-9c2d-6e96e081b877] Failure in Cms::Page.matches? (0x3fd7dabbbc54) \nRecorded at /app/engines/cms/app/models/cms/page.rb:518:in `rescue in matches?'\nin routes\nNoMethodError:undefined method `\u003c=' for 1024..65535:Range\nDid you mean?  \u003c=\u003e\nengines/cms/app/models/cms/page.rb:506:in `published_routes'\nengines/cms/app/models/cms/page.rb:516:in `matches?'\nlib/service/reject_browser_prefetch.rb:34:in `call'\nlib/error_monitor.rb:16:in `call'"}
{"level":"FATAL","timestamp":"2021-06-29T18:23:31+00:00","application":"app_name","environment":"production","message":"[f752a10a-09a0-47a8-9c2d-6e96e081b877]   "}
{"level":"FATAL","timestamp":"2021-06-29T18:23:31+00:00","application":"app_name","environment":"production","message":"[f752a10a-09a0-47a8-9c2d-6e96e081b877] NoMethodError (Failed to open TCP connection to aws.sqs.endpoint:443 (undefined method `\u003c=' for 1024..65535:Range\nDid you mean?  \u003c=\u003e)):"}
{"level":"FATAL","timestamp":"2021-06-29T18:23:31+00:00","application":"app_name","environment":"production","message":"[f752a10a-09a0-47a8-9c2d-6e96e081b877]   "}
{"level":"FATAL","timestamp":"2021-06-29T18:23:31+00:00","application":"app_name","environment":"production","message":"[f752a10a-09a0-47a8-9c2d-6e96e081b877] lib/mail_service/aws_sqs_connection.rb:40:in `get_queue_url'\n[f752a10a-09a0-47a8-9c2d-6e96e081b877] lib/mail_service/aws_sqs_connection.rb:32:in `connected?'\n[f752a10a-09a0-47a8-9c2d-6e96e081b877] app/controllers/health_controller.rb:23:in `index'\n[f752a10a-09a0-47a8-9c2d-6e96e081b877] lib/service/reject_browser_prefetch.rb:34:in `call'\n[f752a10a-09a0-47a8-9c2d-6e96e081b877] lib/error_monitor.rb:16:in `call'"}

编辑:原来这里的问题是我们用来生成随机数的方法,我们使用的是过时的 sysRandom。用 secureRandom ruby​​ 方法替换它解决了这个问题。

标签: ruby-on-railsrubyrubygems

解决方案


推荐阅读