Skip to content

Added delay to dns porkbun dns update to prevent errors #911

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/provider/providers/porkbun/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net/http"
"net/netip"
"time"

"github.com/qdm12/ddns-updater/internal/models"
"github.com/qdm12/ddns-updater/internal/provider/constants"
Expand Down Expand Up @@ -141,6 +142,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add

for _, record := range records {
err = p.updateRecord(ctx, client, recordType, p.owner, ipStr, record.ID)
time.Sleep(time.Second)
Copy link
Collaborator

@bentemple bentemple Jan 14, 2025

Choose a reason for hiding this comment

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

I ran into this too.

One thing, is that if we're getting rate-limited, likely adding the same sleep delay here won't solely fix the underlying issue. This fixes it for lots of subdomains under the same hostname, but if you have DDNS-updater setup to do lots of different hostnames, you can also run into rate-limiting (as I have encountered).

@qdm12 any thoughts on how you'd want this fixed? Maybe wrap the HTTP client to have a general http request rate limit, either per host, or globally. Would that make sense to you? In my mind, you'd ideally be able to specify a max requests per period for a given provider or globally, and the http client would automatically handle queuing and staying within that request limit.

Copy link
Collaborator

@bentemple bentemple Jan 14, 2025

Choose a reason for hiding this comment

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

This also might be pretty unique to porkbun and we'd just want to setup a porkbun ratelimiter, though I could see it being an issue for any DNS provider during the update step.

if err != nil {
return netip.Addr{}, fmt.Errorf("updating record: %w", err)
}
Expand Down
Loading