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

CloudFlare as a new provider #140

Merged
merged 19 commits into from
Jun 16, 2017
Merged

CloudFlare as a new provider #140

merged 19 commits into from
Jun 16, 2017

Conversation

njuettner
Copy link
Member

@k8s-ci-robot
Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Apr 10, 2017
@ideahitme
Copy link

@njuettner thanks for the PR. I think u need to sign CLA ;)

@njuettner
Copy link
Member Author

Thx 👍 for the comment, will have a look.

@linki linki added this to the v0.5 milestone Apr 11, 2017
@linki
Copy link
Member

linki commented Apr 12, 2017

@njuettner Thanks for your contribution. We scheduled to review this after the v0.3 release.

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.

@linki linki added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 12, 2017
@linki
Copy link
Member

linki commented Apr 12, 2017

@njuettner I merged in the latest master and fixed a compile error. Let's see if that makes travis happy.

@njuettner
Copy link
Member Author

njuettner commented Apr 12, 2017

@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).

@thelinuxfoundation
Copy link

bump the CLA check

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 12, 2017
@ideahitme
Copy link

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 :)

@njuettner
Copy link
Member Author

njuettner commented Apr 14, 2017

Done, but CI did break because it's not updating the packages which will be required.
So new packages which I inherited in cloudflare won't be found like "github.com/cloudflare/cloudflare-go".

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?

@njuettner
Copy link
Member Author

njuettner commented Apr 14, 2017

Something like:

before_install:
 - go get github.com/Masterminds/glide

install:
 - cd $GOPATH/src/github.com/Masterminds/glide && git checkout v0.12.3 && go install && cd -
 - glide update

@linki
Copy link
Member

linki commented Apr 24, 2017

@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.

@linki
Copy link
Member

linki commented Apr 24, 2017

The alternative would be to not vendor but just commit glide.(yaml|lock) and then install and use glide on travis to fetch them on each build. We're currently discussing a uniform strategy to tackle this.

@njuettner
Copy link
Member Author

@linki Sounds good to me. Thanks for your input.

linki
linki previously requested changes Jun 12, 2017
Copy link
Member

@linki linki left a 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

@linki
Copy link
Member

linki commented Jun 12, 2017

Changed it to respect the domain filter flag as well. However, this needs to be tested due to unknown behaviour regarding the trailing dot.

@linki linki self-requested a review June 12, 2017 14:33
Copy link

@ideahitme ideahitme left a 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

"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.

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

// 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"))

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 ?

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

endpoints := []*endpoint.Endpoint{}
var record cloudflare.DNSRecord
for _, zone := range zones {
records, err := p.Client.DNSRecords(zone.ID, record)

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{})

}

for _, r := range records {
// TODO: limit Types

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 ?


func (p *cloudFlareProvider) getRecordID(zoneID string, record cloudflare.DNSRecord) (string, error) {
records := cloudflare.DNSRecord{}
zoneRecords, err := p.Client.DNSRecords(zoneID, records)

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

return zoneRecord.ID, nil
}
}
return "", fmt.Errorf("No record id found")

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

@ideahitme
Copy link

ideahitme commented Jun 13, 2017

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:

cloudflare/cloudflare-go#135

/cc @linki @mikkeloscar @njuettner

@k8s-ci-robot
Copy link
Contributor

@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:

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 once necessary. We can as well block this PR until we have this feature in place. Thoughts ?

I created an upstream issue with more details if you are interested:

cloudflare/cloudflare-go#135

/cc @linki @mikkeloscar @njuettner

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.

@ideahitme
Copy link

@linki can u please take another look, we fixed some bugs and improve test coverage

@ideahitme
Copy link

ideahitme commented Jun 15, 2017

the bug with finding suitable zone should be fixed, please give it another try
@mikkeloscar thanks for trying out and finding the bug ;)

@mikkeloscar
Copy link
Contributor

@ideahitme works 👍

@linki linki added lgtm "Looks good to me", indicates that a PR is ready to be merged. provider labels Jun 16, 2017
@ideahitme ideahitme merged commit cb58633 into kubernetes-sigs:master Jun 16, 2017
@linki linki added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/medium labels Jan 2, 2018
ffledgling pushed a commit to ffledgling/external-dns that referenced this pull request Jan 18, 2018
* 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
lou-lan pushed a commit to lou-lan/external-dns that referenced this pull request May 11, 2022
…#140)

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. provider size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants