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

fix: avoid create pluginconfig in the tranlsation of route (#836) #845

Merged
merged 12 commits into from
Mar 2, 2022

Conversation

neverCase
Copy link
Contributor

Type of change:

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

What this PR does / why we need it:

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

@neverCase
Copy link
Contributor Author

ci need re-run @tao12345666333

Copy link
Contributor

@tokers tokers left a comment

Choose a reason for hiding this comment

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

Need some test cases to make sure the plugin_config_id is not written now.

@neverCase
Copy link
Contributor Author

Need some test cases to make sure the plugin_config_id is not written now.

ok, I will add more test cases today.

@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2022

Codecov Report

Merging #845 (4547a1a) into master (d30bef5) will increase coverage by 0.07%.
The diff coverage is 17.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #845      +/-   ##
==========================================
+ Coverage   32.01%   32.09%   +0.07%     
==========================================
  Files          70       70              
  Lines        7749     7730      -19     
==========================================
  Hits         2481     2481              
+ Misses       4993     4976      -17     
+ Partials      275      273       -2     
Impacted Files Coverage Δ
pkg/ingress/apisix_route.go 0.00% <0.00%> (ø)
pkg/kube/translation/apisix_route.go 22.43% <100.00%> (+0.60%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d30bef5...4547a1a. Read the comment docs.

@tao12345666333 tao12345666333 self-assigned this Jan 26, 2022
@tao12345666333 tao12345666333 added the bug Something isn't working label Jan 26, 2022
@neverCase
Copy link
Contributor Author

e2e test need to re-run @tao12345666333

@neverCase
Copy link
Contributor Author

ci error below:

• Failure [70.707 seconds]
ApisixRoute Testing
/home/runner/work/apisix-ingress-controller/apisix-ingress-controller/test/e2e/ingress/resourcepushing.go:28
  service is referenced by two ApisixRoutes [It]
  /home/runner/work/apisix-ingress-controller/apisix-ingress-controller/test/e2e/ingress/resourcepushing.go:502

  
  	Error Trace:	resourcepushing.go:607
  	            				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:      	"[%!s(*v1.Upstream=&{{45e6c8e6 ingress-apisix-e2e-tests-default-428202328_httpbin-service-e2e-test_80 Created by apisix-ingress-controller, DO NOT modify it manually map[managed-by:apisix-ingress-controller]} roundrobin vars  <nil> [{10.244.2.32 80 100}] http <nil> <nil> <nil>})]" should have 0 item(s), but has 1
  	Test:       	ApisixRoute Testing service is referenced by two ApisixRoutes

maybe it need to re-run once again. @tao12345666333

@tao12345666333
Copy link
Member

Wait for #859 to fix CI.

@tao12345666333
Copy link
Member

#859 has been merged. Re-run the CI.

Copy link
Member

@tao12345666333 tao12345666333 left a comment

Choose a reason for hiding this comment

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

LGTM

@tao12345666333
Copy link
Member

ping @tokers @gxthrj for review, thanks

route.PluginConfigId = part.PluginConfigName
}
if part.PluginConfigName != "" {
route.PluginConfigId = part.PluginConfigName
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, This is what needs to be refactored.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will refactor it right now

@neverCase
Copy link
Contributor Author

neverCase commented Feb 18, 2022

Actually, I found I had covert the plugin config name to plugin id in the apisixRouteController.
https://github.com/apache/apisix-ingress-controller/blob/master/pkg/ingress/apisix_route.go#L240
@tokers

@neverCase
Copy link
Contributor Author

It's been a long time and I almost forgot what I had done

@@ -977,13 +964,6 @@ func (t *translator) translateHTTPRouteV2beta3NotStrictly(ctx *TranslateContext,
route := apisixv1.NewDefaultRoute()
route.Name = apisixv1.ComposeRouteName(ar.Namespace, ar.Name, part.Name)
route.ID = id.GenID(route.Name)
pluginConfig := apisixv1.NewDefaultPluginConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we don't handle the PluginConfigName in this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's because when it creates the ApisixRoute and the field PluginConfigName has been specified, I want to use apisix.Cluster api to check the plugin was whether exist.
And at the same time replace it with the plugin id.
...
Since the method to generate the plugin id is fixed.
I will just remove the replacement and remain checking.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, I mean translateHTTPRouteV2beta3NotStrictly is basically same to translateHTTPRouteV2beta3, so here you should also set the plugin config id.

@tokers tokers changed the title fix: aviod create pluginconfig in the tranlsation of route (#836) fix: avoid create pluginconfig in the tranlsation of route (#836) Feb 23, 2022
if err != nil {
log.Errorw("replacePluginNameWithIdIfNotEmptyV2beta3 error: plugin_config not found",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should distinguish the error type, not all errors are "not found".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -977,13 +964,6 @@ func (t *translator) translateHTTPRouteV2beta3NotStrictly(ctx *TranslateContext,
route := apisixv1.NewDefaultRoute()
route.Name = apisixv1.ComposeRouteName(ar.Namespace, ar.Name, part.Name)
route.ID = id.GenID(route.Name)
pluginConfig := apisixv1.NewDefaultPluginConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

Well, I mean translateHTTPRouteV2beta3NotStrictly is basically same to translateHTTPRouteV2beta3, so here you should also set the plugin config id.

@neverCase
Copy link
Contributor Author

@tao12345666333
Ingress case check the ingress lb status is updated run failed.

@tao12345666333
Copy link
Member

let me re-run it

Copy link
Contributor

@gxthrj gxthrj left a comment

Choose a reason for hiding this comment

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

LGTM

@tao12345666333
Copy link
Member

CI is green. Wait for @tokers approval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: the tranlsation of route with plugin_config is pathological
6 participants