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: add mqtt-proxy plugin in ApisixRoute (#966) #1056

Merged
merged 12 commits into from
Aug 21, 2022

Conversation

stillfox-lee
Copy link
Contributor

@stillfox-lee stillfox-lee commented May 30, 2022

Type of change:

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches

What this PR does / why we need it:

Add mqtt-proxy plugin in ApisixRoute.Stream.

ref: issue

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@codecov-commenter
Copy link

codecov-commenter commented May 30, 2022

Codecov Report

Merging #1056 (cd9ee1a) into master (356b220) will decrease coverage by 0.05%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #1056      +/-   ##
==========================================
- Coverage   42.78%   42.72%   -0.06%     
==========================================
  Files          73       73              
  Lines        6477     6486       +9     
==========================================
  Hits         2771     2771              
- Misses       3409     3418       +9     
  Partials      297      297              
Impacted Files Coverage Δ
pkg/providers/apisix/translation/apisix_route.go 19.14% <0.00%> (-0.22%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@tao12345666333
Copy link
Member

Great! Thanks!

I will reivew this later. I'm working on an issue #1055 (high priority)
It blocked our CI jobs.

@stillfox-lee
Copy link
Contributor Author

@tao12345666333
Hi, I saw you fix wolf-rbac test case issue. But I still can't pass e2e-test although I merged master branch. I'm not sure if three is something wrong with my env or wolf-rbac test case?
Here is the error message:

• Failure [111.542 seconds]
suite-features: ApisixConsumer
/Users/liaosiyi/Developer/github/stillfox-lee/apisix/apisix-ingress-controller/test/e2e/suite-features/consumer.go:30
  ApisixRoute with wolfRBAC consumer using secret [It]
  /Users/liaosiyi/Developer/github/stillfox-lee/apisix/apisix-ingress-controller/test/e2e/suite-features/consumer.go:511


  	Error Trace:	reporter.go:23
  	            				reporter.go:23
  	            				chain.go:21
  	            				response.go:585
  	            				response.go:151
  	            				consumer.go:614
  	            				runner.go:113
  	            				runner.go:64
  	            				it_node.go:26
  	            				spec.go:215
  	            				spec.go:138
  	            				spec_runner.go:200
  	            				spec_runner.go:170
  	            				spec_runner.go:66
  	            				suite.go:79
  	            				ginkgo_dsl.go:238
  	            				ginkgo_dsl.go:213
  	            				e2e_test.go:26
  	Error:
  	            		Error Trace:	reporter.go:23
  	            		            				chain.go:21
  	            		            				response.go:585
  	            		            				response.go:151
  	            		            				consumer.go:614
  	            		            				runner.go:113
  	            		            				runner.go:64
  	            		            				it_node.go:26
  	            		            				spec.go:215
  	            		            				spec.go:138
  	            		            				spec_runner.go:200
  	            		            				spec_runner.go:170
  	            		            				spec_runner.go:66
  	            		            				suite.go:79
  	            		            				ginkgo_dsl.go:238
  	            		            				ginkgo_dsl.go:213
  	            		            				e2e_test.go:26
  	            		Error:
  	            		            	expected status equal to:
  	            		            	 "200 OK"

  	            		            	but got:
  	            		            	 "500 Internal Server Error"
  	Test:       	suite-features: ApisixConsumer ApisixRoute with wolfRBAC consumer using secret

The second error looks like a string format issue. It got an unexpected '\n'. But I have no idea how to fix it.

------------------------------
• Failure [62.149 seconds]
suite-features: ApisixConsumer
/Users/liaosiyi/Developer/github/stillfox-lee/apisix/apisix-ingress-controller/test/e2e/suite-features/consumer.go:30
  ApisixRoute with wolfRBAC consumer [It]
  /Users/liaosiyi/Developer/github/stillfox-lee/apisix/apisix-ingress-controller/test/e2e/suite-features/consumer.go:393


  	Error Trace:	consumer.go:422
  	            				runner.go:113
  	            				runner.go:64
  	            				it_node.go:26
  	            				spec.go:215
  	            				spec.go:138
  	            				spec_runner.go:200
  	            				spec_runner.go:170
  	            				spec_runner.go:66
  	            				suite.go:79
  	            				ginkgo_dsl.go:238
  	            				ginkgo_dsl.go:213
  	            				e2e_test.go:26
  	Error:      	Not equal:
  	            	expected: map[string]interface {}{"appid":"test-app", "header_prefix":"X-", "server":"http://-n 172.25.0.1 :12180"}
  	            	actual  : map[string]interface {}{"appid":"test-app", "header_prefix":"X-", "server":"http://-n 172.25.0.1\n:12180"}

  	            	Diff:
  	            	--- Expected
  	            	+++ Actual
  	            	@@ -3,3 +3,3 @@
  	            	  (string) (len=13) "header_prefix": (string) (len=2) "X-",
  	            	- (string) (len=6) "server": (string) (len=27) "http://-n 172.25.0.1 :12180"
  	            	+ (string) (len=6) "server": (string) (len=27) "http://-n 172.25.0.1\n:12180"
  	            	 }
  	Test:       	suite-features: ApisixConsumer ApisixRoute with wolfRBAC consumer

@tao12345666333
Copy link
Member

Could you please merge master latest code? #1055 has been merged. We can make test cases pass.

@stillfox-lee
Copy link
Contributor Author

@tao12345666333 This PR also adds a feature for ApisixRoute Stream plugins. So may be we should update the doc about how to use stream plugin?
But the doc just for v2beta3 only, in origin issue, we dedciede add this feature to v2 APIversion only. Should I add this feature to other APIversion great than v2?

@tao12345666333
Copy link
Member

So may be we should update the doc about how to use stream plugin?

we should add apisix_route_v2 reference doc. And add stream plugin content.

Should I add this feature to other APIversion great than v2?

No, just keep this feature in v2 APIVersion. We will mark v2beta3 as deprecated in the future. You can check #707 for more details

@tao12345666333
Copy link
Member

I have created one issue for track #1063

@stillfox-lee
Copy link
Contributor Author

I have created one issue for track #1063

I can work on it after this PR is merged.
For now, could you please check CI test? It seems like CI test env has some problems. These errors do not occur when running the e2e-test on my computer.

@stillfox-lee
Copy link
Contributor Author

@tao12345666333 Hi. These errors do not occur when running e2e-test on my computer. It looks like e2e-test may have some random fail problem?
About the spell checker fails. I use docker image named eclipse-mosquitto:1.6 in e2e-test. But linter need use mosquito to replace mosquitto. I'm afraid the image name can't be changed.
When you have time can you help me look at this PR? Thanks!

@tao12345666333
Copy link
Member

Let me take a look.

@tao12345666333
Copy link
Member

@stillfox-lee As I said in my previous comment #831 (comment), we are addressing #954
The task is currently over, I can have time to advance this PR.

Can you merge the latest code and resolve conflicts? I think the previous e2e problem should have been solved.

@stillfox-lee stillfox-lee force-pushed the master branch 2 times, most recently from 2db627a to 516df9b Compare July 18, 2022 15:08
@stillfox-lee stillfox-lee marked this pull request as draft July 19, 2022 03:26
@AlinsRan
Copy link
Contributor

@stillfox-lee Please replace suite-plugins/mqtt-proxy.go with suite-plugins/suite-plugins-other/mqtt-proxy.go. Because the secondary directory will not be started when there is a tertiary directory.

@stillfox-lee
Copy link
Contributor Author

@stillfox-lee Please replace suite-plugins/mqtt-proxy.go with suite-plugins/suite-plugins-other/mqtt-proxy.go. Because the secondary directory will not be started when there is a tertiary directory.

Yes, I found that too. And test code needs to adapt V2 e2e-test, so I converted this PR to Draft. Maybe I can do some refactor work when I have time this weekend.

@tao12345666333
Copy link
Member

@stillfox-lee hi, thanks for your contribution, we plan to enter v1.5 release window.

I have a few suggestions for this PR

  • I would like to put this PR into v1.6
  • Currently we have unified all resources to the v2 version of the API, I recommend implementing this feature only for the v2 version of ApisixRoute. Because when the v1.5 version is released, we will mark the v2beta3 version as deprecated. You can check proposal: use a uniform CRD APIVersion #707 for more detail (I have explained before)

@tao12345666333
Copy link
Member

I will add a commit to help you fix CI

"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
)

var _ = ginkgo.FDescribe("suite-plugins: mqtt-proxy plugin", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

suite-plugins-other

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, My fault.

@tao12345666333
Copy link
Member

the failed job due to #1199

@tao12345666333
Copy link
Member

please merge master branch latest code to fix CI job errors. Thanks

@tao12345666333
Copy link
Member

hi, there has one conflicting file, do you have time to resolve it? thanks

@stillfox-lee
Copy link
Contributor Author

@tao12345666333 The issue cause CI failed. It's not related to this PR.

@tao12345666333
Copy link
Member

I re-runed it and the problem is gone

@tao12345666333 tao12345666333 added this to the v1.6.0 milestone Aug 17, 2022
@tao12345666333 tao12345666333 linked an issue Aug 19, 2022 that may be closed by this pull request
@tao12345666333 tao12345666333 merged commit 530ce52 into apache:master Aug 21, 2022
@tao12345666333 tao12345666333 added the changelog Issues with this label should be added to changelog when public a new release label Aug 21, 2022
@tao12345666333 tao12345666333 linked an issue Aug 21, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/controller changelog Issues with this label should be added to changelog when public a new release enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

feat request: native MQTT Protocol proxy Feature suggestion: support stream route with plugins
6 participants