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: objects get from lister must be treated as read-only #829

Merged
merged 3 commits into from
Feb 20, 2022
Merged

fix: objects get from lister must be treated as read-only #829

merged 3 commits into from
Feb 20, 2022

Conversation

nic-6443
Copy link
Member

@nic-6443 nic-6443 commented Jan 3, 2022

Type of change:

  • Bugfix

What this PR does / why we need it:

The object returned by the kubernetes listserver interface should be immutable, and this rule is explicitly stated in the listserver interface.

// IngressNamespaceLister helps list and get Ingresses.
// All objects returned here must be treated as read-only.
type IngressNamespaceLister interface {
}

If change the object, it will cause some strange behavior, for example: the oldObject you get in the control.onUpdate callback is incorrect.

2021-12-31T13:33:58+08:00	debug	ingress/ingress.go:267	ingress add event arrived	{"object": "&Ingress{ObjectMeta:{ingress-v1-lb  ingress-apisix-e2e-tests-default-513114146  394be781-cba8-4b3e-8249-87f7a96c4997 15867 1 2021-12-31 13:33:58 +0800 HKT <nil> <nil> map[] map[kubectl.kubernetes.io/last-applied-configuration:{\"apiVersion\":\"networking.k8s.io/v1\",\"kind\":\"Ingress\",\"metadata\":{\"annotations\":{\"kubernetes.io/ingress.class\":\"apisix\"},\"name\":\"ingress-v1-lb\",\"namespace\":\"ingress-apisix-e2e-tests-default-513114146\"},\"spec\":{\"rules\":[{\"host\":\"httpbin.org\",\"http\":{\"paths\":[{\"backend\":{\"service\":{\"name\":\"httpbin-service-e2e-test\",\"port\":{\"number\":80}}},\"path\":\"/ip\",\"pathType\":\"Exact\"}]}}]}}\n kubernetes.io/ingress.class:apisix] [] []  [{kubectl-client-side-apply Update networking.k8s.io/v1 2021-12-31 13:33:58 +0800 HKT FieldsV1 {\"f:metadata\":{\"f:annotations\":{\".\":{},\"f:kubectl.kubernetes.io/last-applied-configuration\":{},\"f:kubernetes.io/ingress.class\":{}}},\"f:spec\":{\"f:rules\":{}}} }]},Spec:IngressSpec{DefaultBackend:nil,TLS:[]IngressTLS{},Rules:[]IngressRule{IngressRule{Host:httpbin.org,IngressRuleValue:IngressRuleValue{HTTP:&HTTPIngressRuleValue{Paths:[]HTTPIngressPath{HTTPIngressPath{Path:/ip,Backend:IngressBackend{Resource:nil,Service:&IngressServiceBackend{Name:httpbin-service-e2e-test,Port:ServiceBackendPort{Name:,Number:80,},},},PathType:*Exact,},},},},},},IngressClassName:nil,},Status:IngressStatus{LoadBalancer:{[]},},}"}
2021-12-31T13:33:59+08:00	debug	ingress/ingress.go:302	ingress update event arrived	{"new object": "&Ingress{ObjectMeta:{ingress-v1-lb  ingress-apisix-e2e-tests-default-513114146  394be781-cba8-4b3e-8249-87f7a96c4997 15868 1 2021-12-31 13:33:58 +0800 HKT <nil> <nil> map[] map[kubectl.kubernetes.io/last-applied-configuration:{\"apiVersion\":\"networking.k8s.io/v1\",\"kind\":\"Ingress\",\"metadata\":{\"annotations\":{\"kubernetes.io/ingress.class\":\"apisix\"},\"name\":\"ingress-v1-lb\",\"namespace\":\"ingress-apisix-e2e-tests-default-513114146\"},\"spec\":{\"rules\":[{\"host\":\"httpbin.org\",\"http\":{\"paths\":[{\"backend\":{\"service\":{\"name\":\"httpbin-service-e2e-test\",\"port\":{\"number\":80}}},\"path\":\"/ip\",\"pathType\":\"Exact\"}]}}]}}\n kubernetes.io/ingress.class:apisix] [] []  [{kubectl-client-side-apply Update networking.k8s.io/v1 2021-12-31 13:33:58 +0800 HKT FieldsV1 {\"f:metadata\":{\"f:annotations\":{\".\":{},\"f:kubectl.kubernetes.io/last-applied-configuration\":{},\"f:kubernetes.io/ingress.class\":{}}},\"f:spec\":{\"f:rules\":{}}} } {apisix-ingress-controller Update networking.k8s.io/v1 2021-12-31 13:33:59 +0800 HKT FieldsV1 {\"f:status\":{\"f:loadBalancer\":{\"f:ingress\":{}}}} }]},Spec:IngressSpec{DefaultBackend:nil,TLS:[]IngressTLS{},Rules:[]IngressRule{IngressRule{Host:httpbin.org,IngressRuleValue:IngressRuleValue{HTTP:&HTTPIngressRuleValue{Paths:[]HTTPIngressPath{HTTPIngressPath{Path:/ip,Backend:IngressBackend{Resource:nil,Service:&IngressServiceBackend{Name:httpbin-service-e2e-test,Port:ServiceBackendPort{Name:,Number:80,},},},PathType:*Exact,},},},},},},IngressClassName:nil,},Status:IngressStatus{LoadBalancer:{[{10.6.6.6  []}]},},}", "old object": "&Ingress{ObjectMeta:{ingress-v1-lb  ingress-apisix-e2e-tests-default-513114146  394be781-cba8-4b3e-8249-87f7a96c4997 15867 1 2021-12-31 13:33:58 +0800 HKT <nil> <nil> map[] map[kubectl.kubernetes.io/last-applied-configuration:{\"apiVersion\":\"networking.k8s.io/v1\",\"kind\":\"Ingress\",\"metadata\":{\"annotations\":{\"kubernetes.io/ingress.class\":\"apisix\"},\"name\":\"ingress-v1-lb\",\"namespace\":\"ingress-apisix-e2e-tests-default-513114146\"},\"spec\":{\"rules\":[{\"host\":\"httpbin.org\",\"http\":{\"paths\":[{\"backend\":{\"service\":{\"name\":\"httpbin-service-e2e-test\",\"port\":{\"number\":80}}},\"path\":\"/ip\",\"pathType\":\"Exact\"}]}}]}}\n kubernetes.io/ingress.class:apisix] [] []  [{kubectl-client-side-apply Update networking.k8s.io/v1 2021-12-31 13:33:58 +0800 HKT FieldsV1 {\"f:metadata\":{\"f:annotations\":{\".\":{},\"f:kubectl.kubernetes.io/last-applied-configuration\":{},\"f:kubernetes.io/ingress.class\":{}}},\"f:spec\":{\"f:rules\":{}}} }]},Spec:IngressSpec{DefaultBackend:nil,TLS:[]IngressTLS{},Rules:[]IngressRule{IngressRule{Host:httpbin.org,IngressRuleValue:IngressRuleValue{HTTP:&HTTPIngressRuleValue{Paths:[]HTTPIngressPath{HTTPIngressPath{Path:/ip,Backend:IngressBackend{Resource:nil,Service:&IngressServiceBackend{Name:httpbin-service-e2e-test,Port:ServiceBackendPort{Name:,Number:80,},},},PathType:*Exact,},},},},},},IngressClassName:nil,},Status:IngressStatus{LoadBalancer:{[{10.6.6.6  []}]},},}"}

@nic-6443 nic-6443 marked this pull request as ready for review February 8, 2022 11:46
@codecov-commenter
Copy link

codecov-commenter commented Feb 9, 2022

Codecov Report

Merging #829 (1ccd07d) into master (6b0c139) will increase coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #829   +/-   ##
=======================================
  Coverage   32.07%   32.07%           
=======================================
  Files          70       71    +1     
  Lines        7736     7739    +3     
=======================================
+ Hits         2481     2482    +1     
- Misses       4980     4982    +2     
  Partials      275      275           
Impacted Files Coverage Δ
pkg/ingress/status.go 0.00% <0.00%> (ø)
test/e2e/e2e.go 100.00% <0.00%> (ø)

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 6b0c139...1ccd07d. Read the comment docs.

@tao12345666333
Copy link
Member

tao12345666333 commented Feb 16, 2022

Can you merge from master branch? we have fixed the CI

@nic-6443
Copy link
Member Author

Can you merge from master branch? we have fixed the CI

Got it

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.

Thanks

@tao12345666333 tao12345666333 merged commit 32a096c into apache:master Feb 20, 2022
@nic-6443 nic-6443 deleted the fix-wrong-usage branch April 3, 2022 14:25
tao12345666333 pushed a commit to tao12345666333/ingress-controller that referenced this pull request Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants