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

BIND: SOA number doesn't change if zone.js is required #2843

Closed
mraspor opened this issue Feb 19, 2024 · 12 comments · Fixed by #2908
Closed

BIND: SOA number doesn't change if zone.js is required #2843

mraspor opened this issue Feb 19, 2024 · 12 comments · Fixed by #2908

Comments

@mraspor
Copy link

mraspor commented Feb 19, 2024

Describe the bug
If D() is in the main dnsconfig.js file, the SOA number for the BIND provider will get correctly created and updated (for example from 2024021800 to 2024021900).

If we require a file from the main dnsconfig.js
require("./example.com.zone.js");
the resulting .zone file will have its SOA number set to 1 and will not update.

To Reproduce
Steps to reproduce the behavior:

  1. Create "zones" directory in the dnscontrol root directory
  2. Create file example.com.zone.js in dnscontrol root directory with the following data
    D('example.com', REG_NONE, DnsProvider(DSP_BIND), DefaultTTL('5m'), NAMESERVER_TTL('1h'), A('@', '10.10.10.10'), A('localhost', '127.0.0.1') );
  3. Edit dnsconfig.js and put the following at the end
    require("./example.com.zone.js");
  4. Execute dnscontrol push
  5. Check the resulting file in zones/example.com.zone
  6. Change something in the example.com.zone.js and execute dnscontrol push
  7. Observe the SOA number haven't changed in the resulting zones/example.com.zone file

Expected behavior
SOA number should change

DNS Provider

  • BIND
@tlimoncelli
Copy link
Contributor

Hey there! Thanks for reporting this.

When I try to reproduce this issue I see erratic behavior. Sometimes the serial resets to the ...00 serial for the day (2024040300) and sometimes not.

I'll investigate further.

@tlimoncelli
Copy link
Contributor

Hey friend!

I've tried to reproduce the bug with no success. Can you help me figure out what I'm doing differently?

==> creds.json <==
{}

==> dnsconfig.js <==
var REG_NONE = NewRegistrar("none");
var DSP_BIND = NewDnsProvider("bind");

require("./example.com.zone.js");

==> example.com.zone.js <==

D('example.com',
    REG_NONE,
    DnsProvider(DSP_BIND),
    DefaultTTL('5m'),
    NAMESERVER_TTL('1h'),
    A('@', '10.10.10.10'),
    A('localhost', '127.0.0.1'),
    A('test', '127.0.0.2'),
END);

==> zones/example.com.zone <==
$TTL 300
; generated with dnscontrol 2024-04-05T15:47:56-04:00
@                IN SOA   DEFAULT_NOT_SET. DEFAULT_NOT_SET. 2024040505 3600 600 604800 1440
                 IN A     10.10.10.10
localhost        IN A     127.0.0.1
test             IN A     127.0.0.2

@mraspor
Copy link
Author

mraspor commented Apr 8, 2024

Found the problem (at least for me). If any of the required files have SOA() in their domain configuration, all generated files (at least the ones following the require) have "1" as the serial. As said, this is for BIND.

==> example.com.zone.js <==

D('example.com', REG_NONE, DnsProvider(DSP_BIND),
  SOA("@", "ns1.example.com.", "hostmaster.example.com.", 3600, 600, 604800, 1440),
  DefaultTTL('5m'),
  NAMESERVER_TTL('1h'),
  A('@', '10.10.10.10'),
  A('localhost', '127.0.0.1')
);

==> zones/example.com.zone <==

$TTL 300
; generated with dnscontrol 2024-04-08T10:25:53+02:00
@          3600  IN SOA   ns1.example.com. hostmaster.example.com. 1 3600 600 604800 1440
                 IN A     10.10.10.10
localhost        IN A     127.0.0.1
$ dnscontrol version
DNSControl version 4.8.2

@tlimoncelli
Copy link
Contributor

Ah! Thanks for doing that research. I won't have time to investigate right away (things are busy at work) but I will try to diagnose this late this week or early next week.

@tlimoncelli
Copy link
Contributor

Hi @mraspor !

Please confirm if #2908 fixes your problem.

To test:

git clone https://github.com/StackExchange/dnscontrol.git
cd dnscontrol
git co tlim_b2843
go install

This will put dnscontrol in your $HOME/bin for you to test.

@tlimoncelli
Copy link
Contributor

@mraspor
Friendly ping?

@mraspor
Copy link
Author

mraspor commented Apr 29, 2024

Sorry mate for the delay. Tried to install it right now, unfortunately it seems I am unable to install and test on a fresh Debian 12 following your instructions:

# go install
go: errors parsing go.mod:
/root/dnscontrol/go.mod:3: invalid go version '1.22.1': must match format 1.23

OK, here I edited go.mod and substituted 1.22.1 with 1.23. Now it started to download:

# go install
go: downloading github.com/fatih/color v1.16.0
go: downloading github.com/ditashi/jsbeautifier-go v0.0.0-20141206144643-2520a8026a9c
go: downloading github.com/urfave/cli/v2 v2.27.1
go: downloading golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0
go: downloading golang.org/x/net v0.24.0
go: downloading github.com/mattn/go-colorable v0.1.13
go: downloading github.com/mattn/go-isatty v0.0.20
go: downloading github.com/gobwas/glob v0.2.4-0.20181002190808-e7a84e9525fe
go: downloading github.com/jinzhu/copier v0.4.0
go: downloading github.com/miekg/dns v1.1.58
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/qdm12/reprint v0.0.0-20200326205758-722754a53494
go: downloading github.com/go-acme/lego v2.7.2+incompatible
go: downloading github.com/hashicorp/vault/api v1.12.2
go: downloading github.com/DisposaBoy/JsonConfigReader v0.0.0-20201129172854-99cf318d67e7
go: downloading github.com/TomOnTime/utfutil v0.0.0-20230223141146-125e65197b36
go: downloading github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
go: downloading github.com/robertkrimen/otto v0.3.0
go: downloading github.com/xddxdd/ottoext v0.0.0-20221109171055-210517fa4419
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.2
go: downloading github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673
go: downloading golang.org/x/text v0.14.0
go: downloading github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2
go: downloading github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1
go: downloading github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1
go: downloading github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0
go: downloading github.com/Azure/go-autorest/autorest/to v0.4.0
go: downloading github.com/Azure/go-autorest v14.2.0+incompatible
go: downloading github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.2.0
go: downloading github.com/cloudflare/cloudflare-go v0.92.0
go: downloading github.com/digitalocean/godo v1.111.0
go: downloading golang.org/x/oauth2 v0.19.0
go: downloading github.com/dnsimple/dnsimple-go v1.5.1
go: downloading github.com/babolivier/go-doh-client v0.0.0-20201028162107-a76cff4cb8b6
go: downloading github.com/exoscale/egoscale v0.90.2
go: downloading github.com/go-gandi/go-gandi v0.7.0
go: downloading google.golang.org/api v0.172.0
go: downloading github.com/G-Core/gcore-dns-sdk-go v0.2.8
go: downloading github.com/PuerkitoBio/goquery v1.9.1
go: downloading github.com/pquerna/otp v1.4.0
go: downloading github.com/centralnicgroup-opensource/rtldev-middleware-go-sdk/v3 v3.5.6
go: downloading github.com/nrdcg/goinwx v0.10.0
go: downloading github.com/billputer/go-namecheap v0.0.0-20210108011502-994a912fb7f9
go: downloading github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04
go: downloading gopkg.in/ns1/ns1-go.v2 v2.7.11
go: downloading github.com/philhug/opensrs-go v0.0.0-20171126225031-9dfa7433020d
go: downloading github.com/oracle/oci-go-sdk/v32 v32.0.0
go: downloading github.com/ovh/go-ovh v1.4.3
go: downloading github.com/mittwald/go-powerdns v0.6.2
go: downloading github.com/aws/aws-sdk-go-v2 v1.26.1
go: downloading github.com/aws/aws-sdk-go-v2/config v1.27.11
go: downloading github.com/aws/aws-sdk-go-v2/credentials v1.17.11
go: downloading github.com/aws/aws-sdk-go-v2/service/route53 v1.40.4
go: downloading github.com/aws/aws-sdk-go-v2/service/route53domains v1.23.4
go: downloading github.com/softlayer/softlayer-go v1.1.3
go: downloading github.com/transip/gotransip/v6 v6.23.0
go: downloading github.com/vultr/govultr/v2 v2.17.2
go: downloading golang.org/x/sys v0.19.0
go: downloading golang.org/x/crypto v0.22.0
go: downloading github.com/cenkalti/backoff/v3 v3.0.0
go: downloading github.com/cenkalti/backoff v2.2.1+incompatible
go: downloading github.com/go-jose/go-jose/v3 v3.0.3
go: downloading github.com/hashicorp/errwrap v1.1.0
go: downloading github.com/hashicorp/go-cleanhttp v0.5.2
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading github.com/hashicorp/go-retryablehttp v0.7.5
go: downloading github.com/hashicorp/go-rootcerts v1.0.2
go: downloading github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6
go: downloading github.com/hashicorp/go-secure-stdlib/strutil v0.1.2
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading golang.org/x/time v0.5.0
go: downloading github.com/russross/blackfriday/v2 v2.1.0
go: downloading github.com/google/uuid v1.6.0
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/patrickmn/go-cache v2.1.0+incompatible
go: downloading github.com/sirupsen/logrus v1.9.0
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2
go: downloading github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1
go: downloading github.com/goccy/go-json v0.10.2
go: downloading github.com/google/go-querystring v1.1.0
go: downloading github.com/shopspring/decimal v1.3.1
go: downloading github.com/stretchr/testify v1.9.0
go: downloading cloud.google.com/go/compute/metadata v0.2.3
go: downloading cloud.google.com/go/compute v1.23.4
go: downloading google.golang.org/grpc v1.62.1
go: downloading golang.org/x/sync v0.7.0
go: downloading github.com/andybalholm/cascadia v1.3.2
go: downloading github.com/fatih/structs v1.1.0
go: downloading github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b
go: downloading github.com/juju/errors v1.0.0
go: downloading github.com/aws/smithy-go v1.20.2
go: downloading github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1
go: downloading github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0
go: downloading github.com/aws/aws-sdk-go-v2/service/sso v1.20.5
go: downloading github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4
go: downloading github.com/aws/aws-sdk-go-v2/service/sts v1.28.6
go: downloading github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.5
go: downloading github.com/jmespath/go-jmespath v0.4.0
go: downloading github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e
go: downloading github.com/hashicorp/go-sockaddr v1.0.2
go: downloading github.com/ryanuber/go-glob v1.0.0
go: downloading gopkg.in/sourcemap.v1 v1.0.5
go: downloading github.com/kylelemons/godebug v1.1.0
go: downloading github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
go: downloading github.com/deepmap/oapi-codegen v1.9.1
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading github.com/stretchr/objx v0.5.2
go: downloading github.com/peterhellberg/link v1.1.0
go: downloading moul.io/http2curl v1.0.0
go: downloading github.com/google/s2a-go v0.1.7
go: downloading github.com/googleapis/gax-go/v2 v2.12.3
go: downloading go.opencensus.io v0.24.0
go: downloading go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0
go: downloading github.com/boombuler/barcode v1.0.1
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.7
go: downloading github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.5
go: downloading gopkg.in/square/go-jose.v2 v2.5.1
go: downloading github.com/golang-jwt/jwt/v5 v5.2.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/golang/protobuf v1.5.3
go: downloading github.com/googleapis/enterprise-certificate-proxy v0.3.2
go: downloading google.golang.org/protobuf v1.33.0
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237
go: downloading github.com/felixge/httpsnoop v1.0.4
go: downloading go.opentelemetry.io/otel v1.24.0
go: downloading go.opentelemetry.io/otel/metric v1.24.0
go: downloading go.opentelemetry.io/otel/trace v1.24.0
go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: downloading github.com/go-logr/logr v1.4.1
go: downloading github.com/go-logr/stdr v1.2.2
commands/ppreviewPush.go:4:2: package cmp is not in GOROOT (/usr/lib/go-1.19/src/cmp)

As you can see, it errors out on the last line, I'm not golang savvy, so have no idea what to do. Google wasn't my friend :(

@tlimoncelli
Copy link
Contributor

Ah go.mod... my arch nemesis!

Can you try editing that to 1.22 (instead of 1.22.1)

What's the output of "go version"?

@mraspor
Copy link
Author

mraspor commented Apr 30, 2024

Changed as per your instruction to 1.22

# head -n5 go.mod 
module github.com/StackExchange/dnscontrol/v4

go 1.22

retract v4.8.0

And ran it again just now (same error):

# go install
commands/ppreviewPush.go:4:2: package cmp is not in GOROOT (/usr/lib/go-1.19/src/cmp)

Version is:

# go version
go version go1.19.8 linux/amd64

OS:

# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm

@tlimoncelli
Copy link
Contributor

Ah, you're on go 1.19.8 and the code now requires 1.22.1. Can you upgrade Go on your machine? Otherwise let me know your email address and I can send you a binary. (You can securely send me messages via https://transfer.secretoverflow.com/u/tlimoncelli )

@mraspor
Copy link
Author

mraspor commented May 2, 2024

Ah, thank you @tlimoncelli .

Go Version:

# go version
go version go1.22.2 linux/amd64

Adding example.com via required example.zone.js file, this is the file:

# cat example.zone.js 
D('example.com',
    REG_NONE,
    DnsProvider(DSP_BIND),
    DefaultTTL('5m'),
    NAMESERVER_TTL('1h'),
    A('@', '10.10.10.10'),
    A('localhost', '127.0.0.1'),
END);

Generates a correct SOA number:

# cat zones/example.com.zone 
$TTL 300
; generated with dnscontrol 2024-05-02T15:20:54+02:00
@                IN SOA   ns1.example.net. hostmaster.example.net. 2024050200 3600 600 604800 1440
                 IN A     10.10.10.10
localhost        IN A     127.0.0.1

Adding additional A host (test) to example.zone.js

D('example.com',
    REG_NONE,
    DnsProvider(DSP_BIND),
    DefaultTTL('5m'),
    NAMESERVER_TTL('1h'),
    A('@', '10.10.10.10'),
    A('localhost', '127.0.0.1'),
    A('test', '127.0.0.2'),
END);

Generates correctly an updated SOA number:

# cat zones/example.com.zone 
$TTL 300
; generated with dnscontrol 2024-05-02T15:21:40+02:00
@                IN SOA   ns1.example.net. hostmaster.example.net. 2024050201 3600 600 604800 1440
                 IN A     10.10.10.10
localhost        IN A     127.0.0.1
test             IN A     127.0.0.2

So, thank you, you squashed a bug! :)

@tlimoncelli
Copy link
Contributor

Oh good! I'm glad its working for you.

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

Successfully merging a pull request may close this issue.

2 participants