-
Notifications
You must be signed in to change notification settings - Fork 39
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(k8sprocessor): Pod Service cache invalidation #1425
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fix(k8sprocessor): Pod Service cache invalidation |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,15 +37,15 @@ func waitForWatchToBeEstablished(client *fake.Clientset, resource string) <-chan | |
gvr := action.GetResource() | ||
ns := action.GetNamespace() | ||
|
||
watch, err := client.Tracker().Watch(gvr, ns) | ||
watcher, err := client.Tracker().Watch(gvr, ns) | ||
if err != nil { | ||
return false, nil, err | ||
} | ||
|
||
if action.GetVerb() == "watch" { | ||
close(ch) | ||
} | ||
return true, watch, nil | ||
return true, watcher, nil | ||
}) | ||
return ch | ||
} | ||
|
@@ -569,7 +569,6 @@ func Test_OwnerProvider_GetServices(t *testing.T) { | |
}) | ||
|
||
t.Run("updating endpoints", func(t *testing.T) { | ||
t.Skip("Known bug, see https://github.com/SumoLogic/sumologic-otel-collector/issues/1414") | ||
_, err = c.DiscoveryV1().EndpointSlices(namespace). | ||
Update(context.Background(), endpointSlice2Updated, metav1.UpdateOptions{}) | ||
require.NoError(t, err) | ||
|
@@ -579,8 +578,20 @@ func Test_OwnerProvider_GetServices(t *testing.T) { | |
t.Logf("services: %v", services) | ||
return false | ||
} | ||
return assert.Equal(t, []string{"my-service"}, services) | ||
}, 5*time.Second, 10*time.Millisecond) | ||
|
||
return len(services) == 1 | ||
// update back to the original value | ||
_, err = c.DiscoveryV1().EndpointSlices(namespace). | ||
Update(context.Background(), endpointSlice2, metav1.UpdateOptions{}) | ||
require.NoError(t, err) | ||
assert.Eventually(t, func() bool { | ||
services := op.GetServices(pod.Name) | ||
if len(services) != 2 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we checking if the length is not 2 here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be 2, we continue waiting while it's not 2. And it should be 2 because we updated back to the original state, where the EndpointSlice contains the Pod. |
||
t.Logf("services: %v", services) | ||
return false | ||
} | ||
return assert.Equal(t, []string{"my-service", "my-service-2"}, services) | ||
}, 5*time.Second, 10*time.Millisecond) | ||
}) | ||
|
||
|
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.
Is a call to
deleteServiceFromPod
going to ensure that our cache doesn't have any stale entries? So my understanding here is that whenever any EndpointSlice for a service is updated this method gets called with the params as mentioned here - https://pkg.go.dev/k8s.io/[email protected]/tools/cache#ResourceEventHandlerFuncs.OnUpdateThere 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.
Yes, that's the idea. An update to an EndpointSlice can mean that some Pods were removed from the Service, and this is what we do here.