Dd-trace-rb: Error while parsing container info. Cause: undefined method `[]' for nil:NilClass

Created on 21 Apr 2021  Â·  9Comments  Â·  Source: DataDog/dd-trace-rb

Since upgrading to 0.48, several of our developers running linux are running into the following error when starting up the app:

ERROR -- ddtrace: [ddtrace] (/home/mscrivo/affinity/vendor/bundle/ruby/3.0.0/gems/ddtrace-0.48.0/lib/ddtrace/runtime/container.rb:71:in `rescue in block in descriptor') Error while parsing container info. Cause: undefined method `[]' for nil:NilClass Location: /home/mscrivo/affinity/vendor/bundle/ruby/3.0.0/gems/ddtrace-0.48.0/lib/ddtrace/runtime/container.rb:56:in `block (2 levels) in descriptor'

Even if tracing is disabled. Note, they are running the code on VMs, but not containers. Downgrading to 0.47 gets rid of the error. People using macOS don't see this.

Ruby version: 3.0

bug community core

Most helpful comment

👋 Hi all, hope all is well, v0.49.0 is released if you'd like to upgrade and see if this resolves the issue. Cheers! https://github.com/DataDog/dd-trace-rb/releases/tag/v0.49.0

All 9 comments

As one of those developers running Linux, here's my /proc/self/cgroup:

12:perf_event:/
11:pids:/user.slice/user-1000.slice/[email protected]
10:rdma:/
9:memory:/user.slice/user-1000.slice/[email protected]
8:freezer:/
7:blkio:/user.slice
6:cpu,cpuacct:/user.slice
5:devices:/user.slice
4:cpuset:/
3:net_cls,net_prio:/
2:hugetlb:/
1:name=systemd:/user.slice/user-1000.slice/[email protected]/apps.slice/apps-org.gnome.Terminal.slice/vte-spawn-81208bf8-b9df-4b60-a446-90a4e546c059.scope
0::/user.slice/user-1000.slice/[email protected]/apps.slice/apps-org.gnome.Terminal.slice/vte-spawn-81208bf8-b9df-4b60-a446-90a4e546c059.scope

This is a bug introduced in this commit as some descriptor paths are just / and therefore have less than 2 parts, and falls into the else case which expects 3 parts. Fix is easy, PR to follow.

@mscrivo thanks for the report, and thanks @collinsauve thanks for the PR! I'll take a look at this. There's a lot of different kinds of descriptors out there, so it's challenging to cover them all; sorry this slipped through.

Was looking through existing tests... it looks like we actually did cover this case, however, we caught/logged the exception which didn't break RSpec assertions.

We should take @collinsauve 's change & make the tests assert no error was raised... that should fix the existing problem and make future problems like this visible in our CI.

Closed @collinsauve 's PR for this one: #1480 .

@collinsauve @mscrivo can you give that PR a try locally and verify it fixes your issue?

@delner The error is gone for me with your PR, thanks for the quick turnaround!

This occurs in Docker too. Here's a minimal reproduction on the latest ruby image:

➜ docker pull ruby
Using default tag: latest
latest: Pulling from library/ruby
Digest: sha256:091ee4779c0d90155b6d1a317855ce64714e6485f9db4413c812ddd112df7dc7
Status: Image is up to date for ruby:latest
docker.io/library/ruby:latest

➜ docker run \
  --rm \
  -it \
  -v ddtrace-gems:/usr/local/bundle \
  ruby@sha256:091ee4779c0d90155b6d1a317855ce64714e6485f9db4413c812ddd112df7dc7 \
  ruby -r bundler/inline -e "
    gemfile do
      source 'https://rubygems.org'
      gem 'ddtrace', '0.48.0'
    end
    require 'ddtrace'
    Datadog.tracer
  "
E, [2021-04-26T09:25:47.486630 #1] ERROR -- ddtrace: [ddtrace] (/usr/local/bundle/gems/ddtrace-0.48.0/lib/ddtrace/runtime/container.rb:71:in `rescue in block in descriptor') Error while parsing container info. Cause: undefined method `[]' for nil:NilClass Location: /usr/local/bundle/gems/ddtrace-0.48.0/lib/ddtrace/runtime/container.rb:56:in `block (2 levels) in descriptor'

It's still present on master too (c82e5b3).

Interestingly, it doesn't occur on my Arch Linux host.

Edit: #1480 does fix it in my Dockerised example

Edit 2: My cgroups:

➜ docker run --rm -it -v ddtrace-gems:/usr/local/bundle ruby@sha256:091ee4779c0d90155b6d1a317855ce64714e6485f9db4413c812ddd112df7dc7 cat /proc/self/cgroup      
0::/

➜ cat /proc/self/cgroup                                                                                                                                   
0::/user.slice/user-1000.slice/[email protected]/app.slice/app-org.gnome.Terminal.slice/vte-spawn-6fec48c4-1f82-4313-a1c2-29e205a96958.scope

@ZimbiX I just merged #1480 to master: does that fully address the issue for you?

@delner Yep; thanks!

👋 Hi all, hope all is well, v0.49.0 is released if you'd like to upgrade and see if this resolves the issue. Cheers! https://github.com/DataDog/dd-trace-rb/releases/tag/v0.49.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mariogintili picture mariogintili  Â·  3Comments

TildeWill picture TildeWill  Â·  5Comments

mikhailov picture mikhailov  Â·  4Comments

allcentury picture allcentury  Â·  5Comments

tomasv picture tomasv  Â·  7Comments