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: Allow use in cmode=concurrent #3254

Merged
merged 5 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 5 additions & 2 deletions commands/ppreviewPush.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ func generatePopulateCorrections(provider *models.DNSProviderInstance, zoneName
}

return []*models.Correction{{
Msg: fmt.Sprintf("Create zone '%s' in the '%s' profile", aceZoneName, provider.Name),
Msg: fmt.Sprintf("Ensuring zone %q exists in %q", aceZoneName, provider.Name),
F: func() error { return creator.EnsureZoneExists(aceZoneName) },
}}
}
Expand All @@ -604,7 +604,10 @@ func generateDelegationCorrections(zone *models.DomainConfig, providers []*model
nameservers.AddNSRecords(zone)

if len(zone.Nameservers) == 0 && zone.Metadata["no_ns"] != "true" {
return []*models.Correction{{Msg: fmt.Sprintf("No nameservers declared for domain %q; skipping registrar. Add {no_ns:'true'} to force", zone.Name)}}, 0
return []*models.Correction{{Msg: fmt.Sprintf("Skipping registrar %q: No nameservers declared for domain %q. Add {no_ns:'true'} to force",
zone.RegistrarName,
zone.Name,
)}}, 0
}

corrections, err := zone.RegistrarInstance.Driver.GetRegistrarCorrections(zone)
Expand Down
32 changes: 16 additions & 16 deletions providers/bind/bindProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var features = providers.DocumentationNotes{
// See providers/capabilities.go for the entire list of capabilities.
providers.CanAutoDNSSEC: providers.Can("Just writes out a comment indicating DNSSEC was requested"),
providers.CanGetZones: providers.Can(),
providers.CanConcur: providers.Cannot(),
providers.CanConcur: providers.Can(),
providers.CanUseCAA: providers.Can(),
providers.CanUseDHCID: providers.Can(),
providers.CanUseDNAME: providers.Can(),
Expand Down Expand Up @@ -126,8 +126,6 @@ type bindProvider struct {
nameservers []*models.Nameserver
directory string
filenameformat string
zonefile string // Where the zone data is e texpected
zoneFileFound bool // Did the zonefile exist?
}

// GetNameservers returns the nameservers for a domain.
Expand Down Expand Up @@ -162,6 +160,7 @@ func (c *bindProvider) ListZones() ([]string, error) {

// GetZoneRecords gets the records of a zone and returns them in RecordConfig format.
func (c *bindProvider) GetZoneRecords(domain string, meta map[string]string) (models.Records, error) {
var zonefile string

if _, err := os.Stat(c.directory); os.IsNotExist(err) {
printer.Printf("\nWARNING: BIND directory %q does not exist! (will create)\n", c.directory)
Expand All @@ -172,29 +171,25 @@ func (c *bindProvider) GetZoneRecords(domain string, meta map[string]string) (mo
// This layering violation is needed for tests only.
// Otherwise, this is set already.
// Note: In this situation there is no "uniquename" or "tag".
c.zonefile = filepath.Join(c.directory,
zonefile = filepath.Join(c.directory,
makeFileName(c.filenameformat, domain, domain, ""))
} else {
c.zonefile = filepath.Join(c.directory,
zonefile = filepath.Join(c.directory,
makeFileName(c.filenameformat,
meta[models.DomainUniqueName], domain, meta[models.DomainTag]),
)
}
content, err := os.ReadFile(c.zonefile)
content, err := os.ReadFile(zonefile)
if os.IsNotExist(err) {
// If the file doesn't exist, that's not an error. Just informational.
c.zoneFileFound = false
fmt.Fprintf(os.Stderr, "File does not yet exist: %q (will create)\n", c.zonefile)
fmt.Fprintf(os.Stderr, "File does not yet exist: %q (will create)\n", zonefile)
return nil, nil
}
if err != nil {
return nil, fmt.Errorf("can't open %s: %w", c.zonefile, err)
return nil, fmt.Errorf("can't open %s: %w", zonefile, err)
}
c.zoneFileFound = true

zonefileName := c.zonefile

return ParseZoneContents(string(content), domain, zonefileName)
return ParseZoneContents(string(content), domain, zonefile)
}

// ParseZoneContents parses a string as a BIND zone and returns the records.
Expand All @@ -216,9 +211,14 @@ func ParseZoneContents(content string, zoneName string, zonefileName string) (mo
return foundRecords, nil
}

func (n *bindProvider) EnsureZoneExists(_ string) error {
return nil
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (c *bindProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, int, error) {
var corrections []*models.Correction
var zonefile string

changes := false
var msg string
Expand Down Expand Up @@ -270,7 +270,7 @@ func (c *bindProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundR
comments = append(comments, "Automatic DNSSEC signing requested")
}

c.zonefile = filepath.Join(c.directory,
zonefile = filepath.Join(c.directory,
makeFileName(c.filenameformat,
dc.Metadata[models.DomainUniqueName], dc.Name, dc.Metadata[models.DomainTag]),
)
Expand All @@ -287,8 +287,8 @@ func (c *bindProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundR
&models.Correction{
Msg: msg,
F: func() error {
printer.Printf("WRITING ZONEFILE: %v\n", c.zonefile)
fname, err := preprocessFilename(c.zonefile)
printer.Printf("WRITING ZONEFILE: %v\n", zonefile)
fname, err := preprocessFilename(zonefile)
if err != nil {
return fmt.Errorf("could not create zonefile: %w", err)
}
Expand Down
Loading