From 8f80294716331303a147e215ed3d77f1264f441f Mon Sep 17 00:00:00 2001 From: Raymond Kroeker Date: Wed, 27 May 2026 10:32:30 -0700 Subject: [PATCH 1/3] Use builtin for random chars * On MacOS the command snippet to collect 5 random characters for a test id intermettently fails with 'tr: Illegal byte sequence' due to binary output and charactersets. Use the builtin function [choose](https://just.systems/man/en/built-in-functions.html#random) to grab 5 random hex chars. --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index c93f99d5b2b89..fd38781830052 100644 --- a/justfile +++ b/justfile @@ -263,7 +263,7 @@ _k3d-dns-ready: # If DOCKER_REGISTRY is not already set, use a bogus registry with a unique # name so that it's virtually impossible to accidentally use an incorrect image. export DOCKER_REGISTRY := env_var_or_default("DOCKER_REGISTRY", "test.l5d.io/" + _test-id ) -_test-id := `tr -dc 'a-z0-9' Date: Wed, 27 May 2026 10:39:58 -0700 Subject: [PATCH 2/3] Add Failing Test Case * Add a third external workload to the test case for external workload selection. It resides in another namespace and should not come back. This specific commit fails with: ```bash /Users/rkroeker/Code/linkerd/linkerd2/controller/api/destination/external-workload/endpoints_controller_test.go:260: Expected 1 endpoint in first slice, got: 2 ``` --- .../external-workload/endpoints_controller_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/controller/api/destination/external-workload/endpoints_controller_test.go b/controller/api/destination/external-workload/endpoints_controller_test.go index 7e0f5aa1108cc..73100ae94a543 100644 --- a/controller/api/destination/external-workload/endpoints_controller_test.go +++ b/controller/api/destination/external-workload/endpoints_controller_test.go @@ -238,6 +238,11 @@ func TestSyncServiceExternalWorkloadSelection(t *testing.T) { ew2.Labels["foo"] = "boo" esController.externalWorkloadsStore.Add(ew2) + // ensure this ew will not match the selector + altNs := "test-ns-alt" + ew3 := newExternalWorkload(3, altNs, true, false) + esController.externalWorkloadsStore.Add(ew3) + standardSyncService(t, esController, ns, "testing-1") expectActions(t, actions(), 1, "create", "endpointslices") From 05890563f34153aea05ad88dbad2eedaf0a853fa Mon Sep 17 00:00:00 2001 From: Raymond Kroeker Date: Wed, 27 May 2026 10:57:05 -0700 Subject: [PATCH 3/3] Filter by Namespace * When synchronizing, filter both external workloads as well as endpoints by namespace. --- .../destination/external-workload/endpoints_controller.go | 6 ++++-- .../external-workload/endpoints_controller_test.go | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/controller/api/destination/external-workload/endpoints_controller.go b/controller/api/destination/external-workload/endpoints_controller.go index bf75bd4ed0db0..ac685cb4cc731 100644 --- a/controller/api/destination/external-workload/endpoints_controller.go +++ b/controller/api/destination/external-workload/endpoints_controller.go @@ -373,7 +373,8 @@ func (ec *EndpointsController) syncService(update string) error { } ewSelector := labels.Set(svc.Spec.Selector).AsSelectorPreValidated() - ews, err := ec.k8sAPI.ExtWorkload().Lister().List(ewSelector) + ews, err := ec.k8sAPI.ExtWorkload().Lister(). + ExternalWorkloads(namespace).List(ewSelector) if err != nil { // This operation should be infallible since we retrieve from the cache // (we can guarantee we will receive at least an empty list), for good @@ -385,7 +386,8 @@ func (ec *EndpointsController) syncService(update string) error { discoveryv1.LabelServiceName: svc.Name, discoveryv1.LabelManagedBy: managedBy, }).AsSelectorPreValidated() - epSlices, err := ec.k8sAPI.ES().Lister().List(esSelector) + epSlices, err := ec.k8sAPI.ES().Lister(). + EndpointSlices(namespace).List(esSelector) if err != nil { return err } diff --git a/controller/api/destination/external-workload/endpoints_controller_test.go b/controller/api/destination/external-workload/endpoints_controller_test.go index 73100ae94a543..f64367e29a4bc 100644 --- a/controller/api/destination/external-workload/endpoints_controller_test.go +++ b/controller/api/destination/external-workload/endpoints_controller_test.go @@ -246,7 +246,8 @@ func TestSyncServiceExternalWorkloadSelection(t *testing.T) { standardSyncService(t, esController, ns, "testing-1") expectActions(t, actions(), 1, "create", "endpointslices") - // an endpoint slice should be created, it should only reference ew1 (not ew2) + // an endpoint slice should be created, it should only reference ew1 (not + // ew2 and not ew3) slices, err := client.Client.DiscoveryV1().EndpointSlices(ns).List(context.TODO(), metav1.ListOptions{}) if err != nil { t.Errorf("Expected no error fetching endpoint slices, got: %s", err)