-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
CloudFlare as a new provider #140
CloudFlare as a new provider #140
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://github.com/kubernetes/kubernetes/wiki/CLA-FAQ to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@njuettner thanks for the PR. I think u need to sign CLA ;) |
Thx 👍 for the comment, will have a look. |
@njuettner Thanks for your contribution. We scheduled to review this after the Meanwhile we'd be interested in how your experience was contributing a new provider to this project. We intend to make that as easy as possible. |
@njuettner I merged in the latest master and fixed a compile error. Let's see if that makes travis happy. |
@linki thanks for taking a look. So far it's pretty easy to implement a new provider (I was also thinking inheriting digital ocean). The only thing what is currently driving me crazy is getting authorized. I raised a ticket for that (CLA was signed, git email is the same which I used for signing the contract). |
bump the CLA check |
it would be nice if you could rebase without the vendor commit, so we can review your changes without going to commits one by one :) |
Done, but CI did break because it's not updating the packages which will be required. Maybe the .travis.yml can be changed. Before "travis_wait 20 goveralls -service=travis-ci" runs, an glide install will be triggered and makes sure new dependencies are in place? |
Something like:
|
@njuettner You did it perfectly fine before. We currently do vendor all our dependencies. @ideahitme was just asking to leave out the vendor folder in this PR so it's easier for us to review. Just make sure your project builds locally, don't push your vendor folder and let travis fail. Once your code looks great you commit your vendor folder and we'll wait for travis to be green. |
The alternative would be to not vendor but just commit |
@linki Sounds good to me. Thanks for your input. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
domain-filter is ignored
Changed it to respect the domain filter flag as well. However, this needs to be tested due to unknown behaviour regarding the trailing dot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits are not of course blockers, but it'd be great to have the rest of the changes in place before merge
provider/cloudflare.go
Outdated
"github.com/kubernetes-incubator/external-dns/plan" | ||
) | ||
|
||
// cloudFlareDNSInterface is the subset of the CloudFlare API that we actually use. Add methods as required. Signatures must match exactly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "Interface" suffix is redundant. type cloudFlareDNS interface{}
is already explicit enough
provider/cloudflare.go
Outdated
// NewCloudFlareProvider initializes a new CloudFlare DNS based Provider. | ||
func NewCloudFlareProvider(domainFilter string, dryRun bool) (Provider, error) { | ||
// initialize via API email and API key and returns new API object | ||
config, err := cloudflare.New(os.Getenv("CF_API_KEY"), os.Getenv("CF_API_EMAIL")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are the consequences of not having this defined os.Getenv("CF_API_KEY"), os.Getenv("CF_API_EMAIL")
?
IIUC this will make external-dns consistently silently fail to perform any dns operation, can we add a check here if either is required and undefined we return an error ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore, cloudflare.New
already performs this check
provider/cloudflare.go
Outdated
endpoints := []*endpoint.Endpoint{} | ||
var record cloudflare.DNSRecord | ||
for _, zone := range zones { | ||
records, err := p.Client.DNSRecords(zone.ID, record) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: p.Client.DNSRecords(zone.ID, cloudflare.DNSRecord{})
provider/cloudflare.go
Outdated
} | ||
|
||
for _, r := range records { | ||
// TODO: limit Types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this TODO a blocker ?
provider/cloudflare.go
Outdated
|
||
func (p *cloudFlareProvider) getRecordID(zoneID string, record cloudflare.DNSRecord) (string, error) { | ||
records := cloudflare.DNSRecord{} | ||
zoneRecords, err := p.Client.DNSRecords(zoneID, records) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as in DigitalOcean, let's make a single call per zone not to spam CF API
provider/cloudflare.go
Outdated
return zoneRecord.ID, nil | ||
} | ||
} | ||
return "", fmt.Errorf("No record id found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: error message should be lower-cased
One more important thing which I forgot to include into PR review, is that ListZones call does not retrieve all zones, there is a pagination in place but it is not implemented in the sdk. It is however implemented for DNSRecords API. I am not entirely sure how easy it would be to have it fixed (it doesn't seem simple IMO). I am personally fine with having this merged without zones pagination because pagination on Zones does not seem to be critical for External DNS implementation, though of course should be implemented when possible. We can as well block this PR until we have this feature in place. Thoughts ? @linki mentioned that this might potentially be problematic if response on the first page is not consistent on different API calls I created an upstream issue with more details if you are interested: |
@ideahitme: GitHub didn't allow me to request PR reviews from the following users: mikkeloscar, njuettner. Note that only kubernetes-incubator members can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
* reduce the number of API calls * match by type and name for record id
@linki can u please take another look, we fixed some bugs and improve test coverage |
the bug with finding suitable zone should be fixed, please give it another try |
@ideahitme works 👍 |
* CloudFlare Provider * updating glide * gofmt cloudflare_test.go * Unset envs to test NewCloudFlareProvider * More tests * fix(cloudflare): fix compiler errors resulting from merge * Typo * Undo vendor changes * decrease api calls, fix some nits * Cloudflare iteration (#2) * reduce the number of API calls * match by type and name for record id * improve coverage and fix the bug with suitable zone * tests failed due to wrong formatting * add cloudflare integration to the main * vendor cloudflare deps * fix cloudflare zone detection + tests * fix conflicting test function names
…#140) Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
#139