aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar luanphantiki <49431969+luanphantiki@users.noreply.github.com> 2021-01-12 19:38:18 +0700
committerGravatar GitHub <noreply@github.com> 2021-01-12 13:38:18 +0100
commited891c5c4e494248385510844c05a50826bff6a8 (patch)
tree24d6eb878af02e67cb6fdf90d8615d61ff6539dc /plugin
parent0f307cf7284f52307e991526919e0e58895c3a33 (diff)
downloadcoredns-ed891c5c4e494248385510844c05a50826bff6a8.tar.gz
coredns-ed891c5c4e494248385510844c05a50826bff6a8.tar.zst
coredns-ed891c5c4e494248385510844c05a50826bff6a8.zip
fix record missing for zone with many of records (#4328)
* fix record missing for zone with many of records * Update debug log * Update debug mesg * update test_clouddns
Diffstat (limited to 'plugin')
-rw-r--r--plugin/clouddns/clouddns.go2
-rw-r--r--plugin/clouddns/clouddns_test.go2
-rw-r--r--plugin/clouddns/gcp.go22
3 files changed, 18 insertions, 8 deletions
diff --git a/plugin/clouddns/clouddns.go b/plugin/clouddns/clouddns.go
index 343b4ca53..371832440 100644
--- a/plugin/clouddns/clouddns.go
+++ b/plugin/clouddns/clouddns.go
@@ -189,7 +189,7 @@ func (h *CloudDNS) updateZones(ctx context.Context) error {
for i, hostedZone := range z {
newZ := file.NewZone(zName, "")
newZ.Upstream = h.upstream
- rrListResponse, err = h.client.listRRSets(hostedZone.projectName, hostedZone.zoneName)
+ rrListResponse, err = h.client.listRRSets(ctx, hostedZone.projectName, hostedZone.zoneName)
if err != nil {
err = fmt.Errorf("failed to list resource records for %v:%v:%v from gcp: %v", zName, hostedZone.projectName, hostedZone.zoneName, err)
return
diff --git a/plugin/clouddns/clouddns_test.go b/plugin/clouddns/clouddns_test.go
index 7d9db85f3..f394f0593 100644
--- a/plugin/clouddns/clouddns_test.go
+++ b/plugin/clouddns/clouddns_test.go
@@ -24,7 +24,7 @@ func (c fakeGCPClient) zoneExists(projectName, hostedZoneName string) error {
return nil
}
-func (c fakeGCPClient) listRRSets(projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error) {
+func (c fakeGCPClient) listRRSets(ctx context.Context, projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error) {
if projectName == "bad-project" || hostedZoneName == "bad-zone" {
return nil, errors.New("the 'parameters.managedZone' resource named 'bad-zone' does not exist")
}
diff --git a/plugin/clouddns/gcp.go b/plugin/clouddns/gcp.go
index 6d9d85d43..0f5126c87 100644
--- a/plugin/clouddns/gcp.go
+++ b/plugin/clouddns/gcp.go
@@ -1,10 +1,14 @@
package clouddns
-import gcp "google.golang.org/api/dns/v1"
+import (
+ "context"
+
+ gcp "google.golang.org/api/dns/v1"
+)
type gcpDNS interface {
zoneExists(projectName, hostedZoneName string) error
- listRRSets(projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error)
+ listRRSets(ctx context.Context, projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error)
}
type gcpClient struct {
@@ -23,10 +27,16 @@ func (c gcpClient) zoneExists(projectName, hostedZoneName string) error {
// listRRSets is a wrapper method around `gcp.Service.ResourceRecordSets.List`
// it fetches and returns the record sets for a hosted zone.
-func (c gcpClient) listRRSets(projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error) {
- rr, err := c.ResourceRecordSets.List(projectName, hostedZoneName).Do()
- if err != nil {
+func (c gcpClient) listRRSets(ctx context.Context, projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error) {
+ req := c.ResourceRecordSets.List(projectName, hostedZoneName)
+ var rs []*gcp.ResourceRecordSet
+ if err := req.Pages(ctx, func(page *gcp.ResourceRecordSetsListResponse) error {
+ for _, rr := range page.Rrsets {
+ rs = append(rs, rr)
+ }
+ return nil
+ }); err != nil {
return nil, err
}
- return rr, nil
+ return &gcp.ResourceRecordSetsListResponse{Rrsets: rs}, nil
}