fix: do not compare all svc.spec for user modified scene#1342
Conversation
d163cca to
1ddf9d3
Compare
Codecov Report
@@ Coverage Diff @@
## main #1342 +/- ##
==========================================
+ Coverage 62.44% 62.55% +0.11%
==========================================
Files 79 79
Lines 11084 11088 +4
==========================================
+ Hits 6921 6936 +15
+ Misses 3707 3697 -10
+ Partials 456 455 -1
|
7ea2c83 to
79b9cf8
Compare
79b9cf8 to
4cbb1a0
Compare
4cbb1a0 to
f2595e9
Compare
There was a problem hiding this comment.
there are two bugs associated with this logic
-
we are comparing the entire
Spechere, instead we should be comparing all the fields the infra layer sets or skip the fields the infra layer does not set https://pkg.go.dev/k8s.io/api/core/v1#ServiceSpec. -
when updating the service, we need to set immutable fields like
ClusterIPandClusterIPs
// clusterIP is the IP address of the service and is usually assigned
// randomly. If an address is specified manually, is in-range (as per
// system configuration), and is not in use, it will be allocated to the
// service; otherwise creation of the service will fail. This field may not
// be changed through updates unless the type field is also being changed
// to ExternalName (which requires this field to be blank) or the type
// field is being changed from ExternalName (in which case this field may
// optionally be specified, as describe above). Valid values are "None",
// empty string (""), or a valid IP address. Setting this to "None" makes a
// "headless service" (no virtual IP), which is useful when direct endpoint
// connections are preferred and proxying is not required. Only applies to
// types ClusterIP, NodePort, and LoadBalancer. If this field is specified
// when creating a Service of type ExternalName, creation will fail. This
// field will be wiped when updating a Service to type ExternalName.
// More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
// +optional
ClusterIP [string](https://pkg.go.dev/builtin#string) `json:"clusterIP,omitempty" protobuf:"bytes,3,opt,name=clusterIP"`
There was a problem hiding this comment.
1, ok, i'll add imutable fields compare we set.
2, when updating the svc, is these be better that just patch what we need rather than set everything to the new svc?
3, actually,when we use loadbalacer by default, svc.Spec.ports[*].nodePort will be set an random number by k8s, so it's not just about user modified the svc type.
There was a problem hiding this comment.
Reg 2. Patch is fine, my only request is to keep the code simple so it can be enhanced with more fields in the future
Reg 3. its okay to undo what user did, to solve this, we must
- support
Nodeportnatively - support BYO Envoy Svc and Envoy Deployment and disable managed infra
There was a problem hiding this comment.
raise another pr for support NodePort natively might be a better way?
There was a problem hiding this comment.
the infra layer also sets Type and SessionAffinity
There was a problem hiding this comment.
something for the future, we should find a sane way to ensure we check what we set
There was a problem hiding this comment.
is there any need to update svc type rather than follow user's setting?
There was a problem hiding this comment.
added some comments above, Patch is fine as long as its easy to mantain
|
thanks for highlighting this bug @spwangxp, added some comments |
|
also @spwangxp if you are using service type |
f2595e9 to
aae2408
Compare
|
@qicz can you take a first pass ? with the recent refactor want to make sure the logic lives in the right place, TIA |
Signed-off-by: spwangxp <wangshengpeng@cestc.cn>
aae2408 to
87488d9
Compare
|
I got this @qicz |
Signed-off-by: spwangxp <wangshengpeng@cestc.cn>
Signed-off-by: spwangxp <wangshengpeng@cestc.cn>
|
/hold can we compare the entire I've raised two issues to track your use case @spwangxp
|
1, actual |
every time an API change is made to the |
check and remove ignored field should de done when |
|
The ignore list shouldnt change in the codebase, but should only only increase whenever upstream K8s API adds a dynamic field into the |
|
1, add some comment on
check list:
|
|
afaik we should only ignore since they are generated by K8s |
+1 since this makes it easy to maintain / not need to remember this, otherwise lgtm |
Signed-off-by: spwangxp <wangshengpeng@cestc.cn>
|
done |
Signed-off-by: spwangxp <wangshengpeng@cestc.cn>
|
ci needs to retrigger |
arkodg
left a comment
There was a problem hiding this comment.
LGTM thanks for considering all the suggestions !
What type of PR is this?
fix: #1340What this PR does / why we need it:
if not, the ir will encounter an error when update svc.
for example, user A deployed an envoyproxy, and set the svc type to NodePort instead of LoadBalancer, then the gateway restart, the check will always be error.
Which issue(s) this PR fixes:
Fixes #1340