-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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 Service and WorkloadEntry updates #27184
Fix Service and WorkloadEntry updates #27184
Conversation
@@ -206,10 +206,12 @@ type Controller struct { | |||
// we run through the label selectors here to pick only ones that we need. | |||
// Only nodes with ExternalIP addresses are included in this map ! | |||
nodeInfoMap map[string]kubernetesNode | |||
// externalNameSvcInstanceMap stores hostname ==> instance, is used to store instances for ExternalName k8s services | |||
// externalNameSvcInstanceMap stores hostname ==2> instance, is used to store instances for ExternalName k8s services |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
if err := cg.ServiceEntryRegistry.AppendWorkloadHandler(k8s.WorkloadInstanceHandler); err != nil { | ||
t.Fatal(err) | ||
} | ||
if err := k8s.AppendWorkloadHandler(cg.ServiceEntryRegistry.WorkloadInstanceHandler); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will may need to call SyncAll
again after this. We call k8s.Run()
inside of its constructor, so the WorkloadHandler could miss the initial SyncAll
from inside the k8s controller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ended up causing a race so I think Ill pass it the handler in the constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either that, or fake kube controller should have Run
called outside the constructor and share the same stop chan as the other controllers.
Thanks for the fix! Will also take a look later. Hopefully it can address the issues described in #25110 |
/retest too see if its a flake |
/retest |
1 similar comment
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some minor comments. @hzxuzhonghu Can you also PTAL?
@@ -708,8 +712,9 @@ func (c *Controller) serviceInstancesFromWorkloadInstances(svc *model.Service, r | |||
workloadInstancesExist = len(c.workloadInstancesByIP) > 0 | |||
c.RUnlock() | |||
|
|||
// Only select internal Kubernetes services with selectors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This comment and code below is little confusing. It took a while for me to understand we are doing an exclusion here rather than selecting
@@ -904,7 +909,14 @@ func (c *Controller) WorkloadInstanceHandler(si *model.WorkloadInstance, event m | |||
case model.EventDelete: | |||
delete(c.workloadInstancesByIP, si.Endpoint.Address) | |||
default: // add or update | |||
// Check to see if the workload entry changed. If it did, clear the old entry | |||
k := si.Name + "~" + si.Namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to this but - We are using "~" separator at multiple places in the code, May be we should move that to some constant like ISTIO_SEPARATOR
:-) or some thing and use it every where so that in future for some odd reason if we have to change, we can change easilt
@@ -210,6 +210,8 @@ type Controller struct { | |||
externalNameSvcInstanceMap map[host.Name][]*model.ServiceInstance | |||
// workload instances from workload entries - map of ip -> workload instance | |||
workloadInstancesByIP map[string]*model.WorkloadInstance | |||
// Stores a map of workload instance name/namespace to address | |||
workloadInstancesIPsByName map[string]string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: workloadInstancesIPsByName-> workloadInstanceIPByName /workloadInstanceAddressByName?
// Check to see if the workload entry changed. If it did, clear the old entry | ||
k := si.Name + "~" + si.Namespace | ||
existing := c.workloadInstancesIPsByName[k] | ||
if existing != si.Endpoint.Address { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think in add case, delete will always be executed which is redundant may be only do this for update case?.
4be8693
to
aa678e7
Compare
/retest |
aa678e7
to
0b90c3d
Compare
In response to a cherrypick label: #27184 failed to apply on top of branch "release-1.7":
|
In response to a cherrypick label: new issue created for failed cherrypick: #27304 |
PR is split into many commits
Somehow we managed to have 4 different bugs covering all 4 update scenarios. They should be all fixed and tested now.
cc @kyessenov @JimmyCYJ