Skip to content

NEW FEATURE: Gather data for providers concurrently#2873

Merged
tlimoncelli merged 55 commits intomainfrom
tlim_parallel
Mar 27, 2024
Merged

NEW FEATURE: Gather data for providers concurrently#2873
tlimoncelli merged 55 commits intomainfrom
tlim_parallel

Conversation

@tlimoncelli
Copy link
Copy Markdown
Contributor

@tlimoncelli tlimoncelli commented Mar 12, 2024

Goal: collect "preview" information in parallel to improve dnscontrol peformance.

  • dnscontrol ppreview -- Like preview, but collects data in parallel for providers that permit it.
  • dnscontrol ppush -- Like ppreview but pushes
  • Flags:
    • --cmode=none Don't do any work concurrently (useful when you find a bug)
    • --cmode=all Run all providers concurrently (dangerous!)

NOTE: Eventually ppreview and ppush will replace preview and push. These are temporary commands. We'll probably do 1-2 public releases with the pp versions before we remove the non-parallel verions.

How to test this

Here's how to try the changes:

$ git clone https://github.com/StackExchange/dnscontrol.git$ cd dnscontrol
$ git checkout tlim_parallel$ go install
$ (cd to where your dnsconfig.js is)
$ dnscontrol preview                 # Old code$ dnscontrol ppreview --cmode=none   # New code, one provider at a time
$ dnscontrol ppreview                # New code, gather data concurrently when safe
$ dnscontrol ppreview --cmode=all    # New code, gather data concurrently no matter what! (unsafe!)

Is your provider safe to run concurrently?

Look for this line in the source file:

providers.CanConcur:              providers.Cannot(),

If you see providers.Can() then your provider has already been tested and verified to be working.

If you'd like to test your provider, change Cannot() to Can() and compile with the -race flag. This will attempt to detect any race conditions.

cd /my/source/code
vim provider/foo/fooProvider.go       # Change Cannot to Can
go install -race

cd /my/dns/config
dnscontrol ppreview --full

Please report any bugs, suggestions, or performance results in the comments below.

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes detected by Check Git Status Action

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes detected by Check Git Status Action

@tlimoncelli tlimoncelli changed the title Gather data for providers concurently Gather data for providers concurrently Mar 23, 2024
@tlimoncelli tlimoncelli changed the title Gather data for providers concurrently NEW FEATURE: Gather data for providers concurrently Mar 23, 2024
@tlimoncelli tlimoncelli merged commit 68c5e87 into main Mar 27, 2024
@tlimoncelli tlimoncelli deleted the tlim_parallel branch March 27, 2024 17:54
tlimoncelli pushed a commit that referenced this pull request Dec 1, 2025
Tested dnscontrol with `CanConcur()` enabled and seems to work fine.
Read #2873 to see what to do, and hope below is the right way to test.

```text
$ go build -race -o dnscontrol-race
$ ./dnscontrol-race version
v4.27.2-0.20251127184623-cf6b870052c0+dirty

$ dnscontrol-race preview
CONCURRENTLY checking for 16 zone(s)
SERIALLY checking for 6 zone(s)
Serially checking for zone: "domainX.tld"
Serially checking for zone: "domainX.tld"
Serially checking for zone: "domainX.tld"
Serially checking for zone: "domainX.tld"
Serially checking for zone: "domainX.tld"
Serially checking for zone: "domainX.tld"
Waiting for concurrent checking(s) to complete...DONE
CONCURRENTLY gathering records of 16 zone(s)
SERIALLY gathering records of 6 zone(s)
Serially Gathering: "domainX.tld"
Serially Gathering: "domainX.tld"
Serially Gathering: "domainX.tld"
Serially Gathering: "domainX.tld"
Serially Gathering: "domainX.tld"
Serially Gathering: "domainX.tld"
Waiting for concurrent gathering(s) to complete...DONE
******************** Domain: domainX.tld
INFO#1: 4 records not being deleted because of NO_PURGE:
[...]
******************** Domain: domainX.tld
******************** Domain: domainX.tld
INFO#1: 4 records not being deleted because of NO_PURGE:
[...]
******************** Domain: domainX.tld
******************** Domain: domainX.tld
******************** Domain: domainX.tld
1 correction (PK-INWX)
INFO#1: 1 records not being deleted because of IGNORE*():
[...]
******************** Domain: domainX.tld
******************** Domain: domainX.tld
******************** Domain: domainX.tld
******************** Domain: domainX.tld
30 corrections (PK-INWX)
[...]
******************** Domain: domainX.tld
******************** Domain: domainX.tld
2 corrections (PK-INWX)
[...]
******************** Domain: domainX.tld
******************** Domain: domainX.tld
******************** Domain: domainX.tld
******************** Domain: domainX.tld
2 corrections (PK-INWX)
[...]
******************** Domain: domainX.tld
******************** Domain: domainX.tld
Done. 37 corrections.
```

Unfortunately INWX sandbox is sporadically still broken so `go test` is
of limited help:
```text
$ go test -v -verbose -profile INWX
=== RUN   TestDNSProviders
Testing Profile="INWX" (TYPE="INWX")
    helpers_test.go:122: INWX: Unable to login
--- FAIL: TestDNSProviders (30.03s)
=== RUN   TestDualProviders
Testing Profile="INWX" (TYPE="INWX")
    provider_test.go:50: Clearing everything
    provider_test.go:57: Adding test nameservers
    provider_test.go:44: #1:
        + CREATE dnscontrol-inwx.com NS ns1.example.com. ttl=300
    provider_test.go:44: #2:
        + CREATE dnscontrol-inwx.com NS ns2.example.com. ttl=300
    provider_test.go:60: Running again to ensure stability
    provider_test.go:76: Removing test nameservers
    provider_test.go:44: #1:
        - DELETE dnscontrol-inwx.com NS ns1.example.com. ttl=300
    provider_test.go:44: #2:
        - DELETE dnscontrol-inwx.com NS ns2.example.com. ttl=300
--- PASS: TestDualProviders (2.44s)
=== RUN   TestNameserverDots
Testing Profile="INWX" (TYPE="INWX")
=== RUN   TestNameserverDots/No_trailing_dot_in_nameserver
--- PASS: TestNameserverDots (0.30s)
    --- PASS: TestNameserverDots/No_trailing_dot_in_nameserver (0.00s)
=== RUN   TestDuplicateNameservers
Testing Profile="INWX" (TYPE="INWX")
    provider_test.go:145: Skipping. Deduplication logic is not implemented for this provider.
--- SKIP: TestDuplicateNameservers (0.35s)
FAIL
exit status 1
FAIL    github.com/StackExchange/dnscontrol/v4/integrationTest  33.127s
```
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 this pull request may close these issues.

1 participant