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

feat: support for Service Discovery Across Multiple Nacos Clusters #10950

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

ShenFeng312
Copy link
Contributor

@ShenFeng312 ShenFeng312 commented Feb 21, 2024

Description

Fixes #10799

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@shreemaan-abhishek
Copy link
Contributor

please fix the linter

@monkeyDluffy6017 monkeyDluffy6017 changed the title feat: Support for Service Discovery Across Multiple Nacos Clusters feat: support for Service Discovery Across Multiple Nacos Clusters Feb 23, 2024
@ShenFeng312
Copy link
Contributor Author

@monkeyDluffy6017 hello~ These errors seem to be unrelated to this PR.

@monkeyDluffy6017
Copy link
Contributor

Could you add test cases to cover this?

@ShenFeng312
Copy link
Contributor Author

Could you add test cases to cover this?

I will add test cases next week

@zll600
Copy link
Contributor

zll600 commented Feb 27, 2024

@monkeyDluffy6017 hello~ These errors seem to be unrelated to this PR.

The ci problem has been fixed by #10959. Please merge latest master.

@shreemaan-abhishek
Copy link
Contributor

CI is still failing

@ShenFeng312
Copy link
Contributor Author

image
@shreemaan-abhishek hello~ i dont know how to fix this error

@shreemaan-abhishek
Copy link
Contributor

@ShenFeng312 try using --- response_body chomp

apisix/discovery/nacos/init.lua Outdated Show resolved Hide resolved
apisix/discovery/nacos/init.lua Outdated Show resolved Hide resolved
apisix/discovery/nacos/init.lua Outdated Show resolved Hide resolved
apisix/discovery/nacos/init.lua Outdated Show resolved Hide resolved
apisix/discovery/nacos/init.lua Outdated Show resolved Hide resolved
ShenFeng312 and others added 5 commits April 22, 2024 14:49
Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
@ShenFeng312
Copy link
Contributor Author

@shreemaan-abhishek The 'others' field represents a list of additional Nacos configurations. Since the previous schema for Nacos configuration was an object, directly changing it to an array would render existing configurations incompatible. Therefore, I've utilized the 'others' field to extend this functionality. Of course, if we decide that backward compatibility is not necessary, we can redesign this configuration schema. Currently, my implementation involves adding a new layer of 'nacosName' within the original 'applications' map. This layer corresponds to different Nacos configurations. Additionally, the asynchronous tasks for fetching Nacos configurations have been modified from fetching from a single Nacos instance to fetching from multiple instances. They are organized into different maps based on the 'name' specified in the configuration.

@shreemaan-abhishek
Copy link
Contributor

please pay attention here: #10950 (comment)

@ShenFeng312
Copy link
Contributor Author

please pay attention here: #10950 (comment)

fixed

@shreemaan-abhishek
Copy link
Contributor

shreemaan-abhishek commented Apr 29, 2024

can you also mention that host is deprecated now (both in code and docs). Here is an example:
image

https://apisix.apache.org/docs/apisix/plugins/kafka-logger/#attributes

@ShenFeng312
Copy link
Contributor Author

can you also mention that host is deprecated now (both in code and docs). Here is an example: image

https://apisix.apache.org/docs/apisix/plugins/kafka-logger/#attributes

Yes

@shreemaan-abhishek
Copy link
Contributor

I think this line is enough: 6d2dcc2?diff=split&w=0#diff-8d872babc717e9d733641b56bfc530ef98751fbe4e68f08d79b2b83109c22fffR302

we can skip these:
image

And it think it's better if the comment says: "deprecated, use nacos.hosts instead"

apisix/discovery/nacos/init.lua Outdated Show resolved Hide resolved
local query_path = instance_list_path .. service_info.service_name
.. token_param .. namespace_param .. group_name_param
.. signature_param
.. token_param .. namespace_param .. group_name_param
Copy link
Contributor

Choose a reason for hiding this comment

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

there are many other whitespace changes like this, please revert them

@@ -405,12 +434,17 @@ function _M.init_worker()
return
end

default_weight = local_conf.discovery.nacos.weight
log.info('default_weight:', default_weight)
--default_weight = local_conf.discovery.nacos.weight
Copy link
Contributor

Choose a reason for hiding this comment

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

why change these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because default_weight in different nacos may different @shreemaan-abhishek

local fetch_interval = local_conf.discovery.nacos.fetch_interval
log.info('fetch_interval:', fetch_interval)
access_key = local_conf.discovery.nacos.access_key
secret_key = local_conf.discovery.nacos.secret_key
--access_key = local_conf.discovery.nacos.access_key
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because access_key and secret_key in different nacos may different @shreemaan-abhishek

@@ -109,6 +109,7 @@ services:
- consul.cluster

## Nacos cluster

Copy link
Contributor

Choose a reason for hiding this comment

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

this change is not needed

host:
- "http://192.168.33.1:8848"
hosts:
- host:
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't seem the right way. I think the following is better:

nacos:
  hosts:
    - xyz
    - abc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean to configure it like this?

hosts:
  name1:
    - host:
       - xxx
  name2:
    - host:
       - xxx

@shreemaan-abhishek we may need config different access_key in different nacos

Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Support for Service Discovery Across Multiple Nacos Clusters
4 participants