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

Add the provider for the Tencent Cloud. #2630

Merged
merged 1 commit into from
Sep 15, 2022

Conversation

Hyzhou
Copy link
Contributor

@Hyzhou Hyzhou commented Mar 4, 2022

Signed-off-by: misakazhou misakazhou@tencent.com

Description

Add the provider for tencent cloud.
PrivateDNS service provides intranet DNS resolution.
DNSPod service provides internet DNS resolution.
Unit tests and document is updated for the tencent cloud provider.

Any issue about the tencent cloud provider can ask @Hyzhou for help and upgrade.

Fixes #ISSUE

Checklist

  • Unit tests updated
  • End user documentation updated

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 4, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @Hyzhou!

It looks like this is your first PR to kubernetes-sigs/external-dns 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/external-dns has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 4, 2022
@Hyzhou
Copy link
Contributor Author

Hyzhou commented Mar 8, 2022

@Raffo Would you like to review this PR. Thank you.

@Hyzhou Hyzhou changed the title add the provider for the tencent cloud. Add the provider for the Tencent Cloud. Mar 8, 2022
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 21, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 19, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 19, 2022
@lostz
Copy link

lostz commented Aug 5, 2022

I need it so much。

@Hyzhou
Copy link
Contributor Author

Hyzhou commented Aug 5, 2022

I need it so much。

you can use it now.
https://cloud.tencent.com/document/product/457/72679

@lostz
Copy link

lostz commented Aug 6, 2022

I need it so much。

you can use it now. https://cloud.tencent.com/document/product/457/72679

thx

@ysicing
Copy link

ysicing commented Aug 24, 2022

@Hyzhou only support Tencent Cloud(TKE)?

@Hyzhou
Copy link
Contributor Author

Hyzhou commented Aug 24, 2022

@Hyzhou only support Tencent Cloud(TKE)?

It is a driver support for Tencent Cloud, and test in TKE Clusters.
But if you build an kubernetes cluster in Tencent Cloud by your self. I think this driver also work too.

@ysicing
Copy link

ysicing commented Aug 24, 2022

@Hyzhou example, I want to support DNSPod in EKS(Other Cloud K8s) Clusters, this driver maybe not work.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 24, 2022
@Hyzhou Hyzhou force-pushed the tencentcloud-provider branch 3 times, most recently from 41b88c6 to 10fad34 Compare August 25, 2022 03:09
@Hyzhou
Copy link
Contributor Author

Hyzhou commented Aug 25, 2022

/sig cloud-provider

@k8s-ci-robot k8s-ci-robot added the sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. label Aug 25, 2022
@Hyzhou
Copy link
Contributor Author

Hyzhou commented Aug 25, 2022

@Raffo @njuettner @seanmalloy Would you like to review this PR. Thank you.

@ysicing
Copy link

ysicing commented Sep 8, 2022

/assign @szuecs

}
for _, record := range records {
if *record.Type == "TXT" && strings.HasPrefix(*record.Value, "heritage=") {
record.Value = common.StringPtr(fmt.Sprintf("\"%s\"", *record.Value))
Copy link
Contributor

Choose a reason for hiding this comment

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

a bit nicer would be:

record.Value = common.StringPtr(fmt.Sprintf(`"%s"`, *record.Value))

for _, endpoint := range endpoints {
for _, target := range endpoint.Targets {
if endpoint.RecordType == "TXT" && strings.HasPrefix(target, "\"heritage=") {
target = strings.Trim(target, "\"")
Copy link
Contributor

Choose a reason for hiding this comment

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

I am just scrolling the code a bit and this line and the above looks a bit weird to me

for _, record := range recordGroup.RecordList {
key := *record.Type + ":" + *record.Name + "." + *recordGroup.Domain.Name
if *record.Name == TencentCloudEmptyPrefix {
key = *record.Type + ":" + *recordGroup.Domain.Name
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you don't need to dereference pointers here (ibmcloud seems to also does it, but all others not) and basically all over the place. See also the inmemory provider.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I just not understand only this feedback. I wants to group the target by dnsname and type here.

Copy link
Contributor

@szuecs szuecs Sep 11, 2022

Choose a reason for hiding this comment

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

Ok sorry!
You can use for example record.Name without prepending *.
It's different from C or C++

Copy link
Contributor Author

@Hyzhou Hyzhou Sep 11, 2022

Choose a reason for hiding this comment

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

key := record.Type + ":" + record.Name + "." + recordGroup.Domain.Name

like this? it looks wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes like that and in general I prefer fmt.Sprintf for string concatenation.

Copy link
Contributor Author

@Hyzhou Hyzhou Sep 11, 2022

Choose a reason for hiding this comment

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

record.Type is *string type. remove the * make go language syntax error.

fmt is ok, I already change to fmt.Sprintf

func NewTencentCloudProvider(domainFilter endpoint.DomainFilter, zoneIDFilter provider.ZoneIDFilter, configFile string, zoneType string, dryRun bool) (*TencentCloudProvider, error) {
cfg := tencentCloudConfig{}
if configFile != "" {
contents, err := ioutil.ReadFile(configFile)
Copy link
Contributor

Choose a reason for hiding this comment

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

os.ReadFile.

if configFile != "" {
contents, err := ioutil.ReadFile(configFile)
if err != nil {
return nil, fmt.Errorf("failed to read Tencent Cloud config file '%s': %v", configFile, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use always:

fmt.Errorf("....: %w", err)

instead of %v

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you, the above all points. I will check it soon.

t.Errorf("Incorrect number of records: %d", len(endpoints))
}
for _, endpoint := range endpoints {
t.Logf("Endpoint for %++v", *endpoint)
Copy link
Contributor

Choose a reason for hiding this comment

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

%++v -> %+v

Copy link
Contributor

@szuecs szuecs left a comment

Choose a reason for hiding this comment

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

Small Go code things here and there that requires fixes.
Other than that we have to discuss in maintainers meeting if we merge all provider PRs or if we have it on hold as we have since more than a half year.

@szuecs
Copy link
Contributor

szuecs commented Sep 8, 2022

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Sep 8, 2022
@szuecs
Copy link
Contributor

szuecs commented Sep 8, 2022

/assign @Raffo

@szuecs
Copy link
Contributor

szuecs commented Sep 8, 2022

@Raffo to run the tests looks fine to me

@Hyzhou Hyzhou force-pushed the tencentcloud-provider branch 2 times, most recently from 523ed7b to dce3174 Compare September 11, 2022 13:04
@Raffo
Copy link
Contributor

Raffo commented Sep 15, 2022

I approved tests to run, deferring to @szuecs for the final review and call on merge.

@Raffo
Copy link
Contributor

Raffo commented Sep 15, 2022

I see this in the CI build:

sh -s -- -b $(go env GOPATH)/bin v1.45.2
golangci/golangci-lint info checking GitHub for tag 'v1.4[5](https://github.com/kubernetes-sigs/external-dns/actions/runs/3031914931/jobs/4935438158#step:6:6).2'
golangci/golangci-lint info found version: 1.45.2 for v1.45.2/linux/amd[6](https://github.com/kubernetes-sigs/external-dns/actions/runs/3031914931/jobs/4935438158#step:6:7)4
golangci/golangci-lint info installed /home/runner/go/bin/golangci-lint
>> checking license header
license header checking failed:
./provider/tencentcloud/privatedns.go
./provider/tencentcloud/dnspod.go
./provider/tencentcloud/tencent_cloud_test.go
make: *** [Makefile:5[8](https://github.com/kubernetes-sigs/external-dns/actions/runs/3031914931/jobs/4935438158#step:6:9): licensecheck] Error 1
./provider/tencentcloud/cloudapi/readonlyapi.go
./provider/tencentcloud/cloudapi/mockapi.go
./provider/tencentcloud/cloudapi/clientset.go
./provider/tencentcloud/cloudapi/api.go
./provider/tencentcloud/cloudapi/tencentapi.go
./provider/tencentcloud/tencent_cloud.go
Error: Process completed with exit code 2.

there's also a conflict with the go.mod now. Can you please fix that @Hyzhou ?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 15, 2022
@Hyzhou
Copy link
Contributor Author

Hyzhou commented Sep 15, 2022

I see this in the CI build:

sh -s -- -b $(go env GOPATH)/bin v1.45.2
golangci/golangci-lint info checking GitHub for tag 'v1.4[5](https://github.com/kubernetes-sigs/external-dns/actions/runs/3031914931/jobs/4935438158#step:6:6).2'
golangci/golangci-lint info found version: 1.45.2 for v1.45.2/linux/amd[6](https://github.com/kubernetes-sigs/external-dns/actions/runs/3031914931/jobs/4935438158#step:6:7)4
golangci/golangci-lint info installed /home/runner/go/bin/golangci-lint
>> checking license header
license header checking failed:
./provider/tencentcloud/privatedns.go
./provider/tencentcloud/dnspod.go
./provider/tencentcloud/tencent_cloud_test.go
make: *** [Makefile:5[8](https://github.com/kubernetes-sigs/external-dns/actions/runs/3031914931/jobs/4935438158#step:6:9): licensecheck] Error 1
./provider/tencentcloud/cloudapi/readonlyapi.go
./provider/tencentcloud/cloudapi/mockapi.go
./provider/tencentcloud/cloudapi/clientset.go
./provider/tencentcloud/cloudapi/api.go
./provider/tencentcloud/cloudapi/tencentapi.go
./provider/tencentcloud/tencent_cloud.go
Error: Process completed with exit code 2.

there's also a conflict with the go.mod now. Can you please fix that @Hyzhou ?

I get it

@Hyzhou Hyzhou force-pushed the tencentcloud-provider branch 2 times, most recently from 17cad62 to 4fd48e4 Compare September 15, 2022 08:24
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 15, 2022
@Hyzhou
Copy link
Contributor Author

Hyzhou commented Sep 15, 2022

I see this in the CI build:

sh -s -- -b $(go env GOPATH)/bin v1.45.2
golangci/golangci-lint info checking GitHub for tag 'v1.4[5](https://github.com/kubernetes-sigs/external-dns/actions/runs/3031914931/jobs/4935438158#step:6:6).2'
golangci/golangci-lint info found version: 1.45.2 for v1.45.2/linux/amd[6](https://github.com/kubernetes-sigs/external-dns/actions/runs/3031914931/jobs/4935438158#step:6:7)4
golangci/golangci-lint info installed /home/runner/go/bin/golangci-lint
>> checking license header
license header checking failed:
./provider/tencentcloud/privatedns.go
./provider/tencentcloud/dnspod.go
./provider/tencentcloud/tencent_cloud_test.go
make: *** [Makefile:5[8](https://github.com/kubernetes-sigs/external-dns/actions/runs/3031914931/jobs/4935438158#step:6:9): licensecheck] Error 1
./provider/tencentcloud/cloudapi/readonlyapi.go
./provider/tencentcloud/cloudapi/mockapi.go
./provider/tencentcloud/cloudapi/clientset.go
./provider/tencentcloud/cloudapi/api.go
./provider/tencentcloud/cloudapi/tencentapi.go
./provider/tencentcloud/tencent_cloud.go
Error: Process completed with exit code 2.

there's also a conflict with the go.mod now. Can you please fix that @Hyzhou ?

I already add the lisence header. and rebase the code

@Raffo
Copy link
Contributor

Raffo commented Sep 15, 2022

Approved CI again.

@Hyzhou
Copy link
Contributor Author

Hyzhou commented Sep 15, 2022

Approved CI again.

Sorry, I will run it local.

Signed-off-by: misakazhou <misakazhou@tencent.com>
@szuecs
Copy link
Contributor

szuecs commented Sep 15, 2022

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 15, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Hyzhou, szuecs

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 15, 2022
@k8s-ci-robot k8s-ci-robot merged commit 78b5175 into kubernetes-sigs:master Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants