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

Failed to load zones or crashes on queries #122

Closed
SivaKesava1 opened this issue Nov 5, 2020 · 3 comments
Closed

Failed to load zones or crashes on queries #122

SivaKesava1 opened this issue Nov 5, 2020 · 3 comments
Assignees
Labels

Comments

@SivaKesava1
Copy link

SivaKesava1 commented Nov 5, 2020

Hi,

I built erldns using make and then added the following file as erldns.config.

[
  {erldns,[
      {servers, [
        [{name, inet_localhost_1}, {address, "127.0.0.1"}, {port, 53}, {family, inet}]
      ]},

      {use_root_hints, false},
      {catch_exceptions, false},
      {zones, "priv/campus.json"}
    ]},
  {lager, [
      {error_logger_redirect, false}
    ]}
].

I have placed the following campus.json file in priv directory.

[
  {
    "name": "campus.edu",
    "records": [
      {
        "name": "campus.edu",
        "type": "SOA",
        "ttl": 3600,
        "data": {
          "mname": "ns1.campus.edu",
          "rname": "root.campus.edu",
          "serial": 3,
          "refresh": 86400,
          "retry": 7200,
          "expire": 604800,
          "minimum": 300
        }
      },
      {
        "name": "campus.edu",
        "type": "NS",
        "ttl": "500",
        "data": {
          "dname": "ns1.outside.edu"
        }
      },
      {
        "name": "*.e.campus.edu",
        "type": "A",
        "ttl": "500",
        "data": {
          "ip": "1.1.1.1"
        }
      },
      {
        "name": "t.e.campus.edu",
        "type": "A",
        "ttl": "500",
        "data": {
          "ip": "2.2.2.2"
        }
      }
    ]
  }
]

Then I ran ./rebar3 release . Though there were some out of date warnings, it successfully assembled it. Then I ran ./_build/default/rel/erldns/bin/erldns foreground which gave the error Failed to load zones (module: erldns_zone_loader, event: read_file_error, reason: enoent). Whatever I did and wherever I placed the file, it gave the same error. I finally tried naming the file as example.zone.json, and it successfully loaded it!! I am not sure what the problem here is, and any help would be useful.

The logs while loading the file were:

09:33:01.061 [info] Loaded zones (count: 1)
09:33:01.061 [info] Notifying servers to start
09:33:01.061 [info] Starting the UDP and TCP supervisor
09:33:01.061 [info] Starting UDP server (family: inet, address: {127,0,0,1}, port: 53)
09:33:01.061 [info] UDP server (family: inet, address: {127,0,0,1}, socket: #Port<0.10>)
09:33:01.062 [info] Starting TCP server for inet on address {127,0,0,1} port 53

Then I queried it using dig @127.0.0.1 +norecurse t.e.campus.edu, which resulted in a huge crash report message. Some parts of that message are:

=ERROR REPORT==== 5-Nov-2020::09:35:40.091530 ===
** Generic server <0.771.0> terminating
** Last message in was {process,
                           {dns_message,46922,false,0,false,false,true,false,
                               ....
** When Server state == {state}
** Reason for termination ==
** {badarg,
       [{dns,encode_message_rec,3,
           ....

=CRASH REPORT==== 5-Nov-2020::09:35:40.092258 ===
  crasher:
    initial call: erldns_worker_process:init/1
    pid: <0.771.0>
    registered_name: []
    exception error: bad argument
      in function  dns:encode_message_rec/3 (/erldns/_build/default/lib/dns_erlang/src/dns.erl, line 590)
      in call from dns:encode_message_rec_list/5 (/erldns/_build/default/lib/dns_erlang/src/dns.erl, line 557)
      in call from dns:encode_message_d_req/5 (/erldns/_build/default/lib/dns_erlang/src/dns.erl, line 423)
      in call from dns:encode_message_def

09:35:50.093 [error] Error handling UDP query (module: erldns_worker, event: handle_udp_query_error, error: {error,{exit,{{badarg,.....
{dns_message,46922,false,0,false,false,true,false,true,false,0,1,0,0,1,[{dns_query,<<"t.e.campus.edu">>,1,1}],[],[],..

System:
OS: Ubuntu bionic (actually a docker image)
Erlang installed using the steps mentioned here as the apt install erlang gave errors for the make.

I am not used to Erlang, so I did not try much to find the root cause. Thanks for any help in advance

@san983
Copy link
Member

san983 commented Jan 20, 2025

Hi @SivaKesava1, I'm showing that the JSON you've pasted specifies the TTLs as strings ("500") not integers. I was able to reproduce the error, and also to successfully load/query the zone switching the TTL to integers

@san983 san983 closed this as completed Jan 20, 2025
@san983 san983 self-assigned this Jan 20, 2025
@san983 san983 added the bug label Jan 20, 2025
@SivaKesava1
Copy link
Author

Thanks, @san983 for the reply. I, now run into JSON issues with the release command. I have the following Dockerfile to run ErlDNS:

FROM ubuntu:jammy

RUN apt-get update 
RUN apt-get -y upgrade 
RUN apt-get install -y \
    make \
    curl \
    erlang \
    git \
    gnupg \
    python3 \
    rebar3 \
    vim \
    wget \
    dnsutils 
 
ENV TZ=US/Pacific
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN git clone https://github.com/dnsimple/erldns.git
RUN cd erldns && \
    make

COPY Erldns/erldns.config erldns/
RUN cd erldns && rebar3 release

# Run eternal loop
CMD ["/bin/bash", "-c", "while :; do sleep 10; done"]

where I have also added the above erldns.config and the fixed JSON.

When I run rebar3 release now, I get JSON errors:

===> Assembling release erldns-3.0.0...
===> There are missing function calls in the release.
===> Make sure all applications needed at runtime are included in the release.
===> erldns_storage:load_zones/1 calls undefined function json:decode/3
===> erldns_zone_encoder:json_encode_kw_list/1 calls undefined function json:encode/2
===> erldns_zone_encoder:json_encode_term/2 calls undefined function json:encode_key_value_list/2
===> erldns_zone_encoder:json_encode_term/2 calls undefined function json:encode_value/2
===> erldns_zone_loader:load_zones/0 calls undefined function json:decode/3

I saw that this commit 08f1a8a#diff-427d8ddce21ccc4fae24fb547c7a82c2a793ed57208d8343e519e0aec8119ff7 updated to the default JSON module. However, I am still seeing issues on Ubuntu:Jammy.

@san983
Copy link
Member

san983 commented Jan 23, 2025

@SivaKesava1 I'm showing that your Dockerfile actually installs erlang v24.x which is EOL already. The current version of main actually works on erlang 27+

root@c14a951b1dd4:/erldns# apt-cache policy erlang
erlang:
  Installed: 1:24.2.1+dfsg-1ubuntu0.1
  Candidate: 1:24.2.1+dfsg-1ubuntu0.1
  Version table:
 *** 1:24.2.1+dfsg-1ubuntu0.1 500
        500 http://ports.ubuntu.com/ubuntu-ports jammy-updates/universe arm64 Packages
        500 http://ports.ubuntu.com/ubuntu-ports jammy-security/universe arm64 Packages
        100 /var/lib/dpkg/status
     1:24.2.1+dfsg-1 500
        500 http://ports.ubuntu.com/ubuntu-ports jammy/universe arm64 Packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants