From 7419dd2f1d54e7b431d06bfd468e5629656d93ef Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Thu, 31 Jul 2025 11:06:50 +0000 Subject: [PATCH 1/2] fix(agent/agentcontainers): fix devcontainer integration tests --- agent/agentcontainers/api.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/agent/agentcontainers/api.go b/agent/agentcontainers/api.go index c8cba67cea73f..baf8ced3f0857 100644 --- a/agent/agentcontainers/api.go +++ b/agent/agentcontainers/api.go @@ -161,8 +161,8 @@ func WithContainerCLI(ccli ContainerCLI) Option { // WithContainerLabelIncludeFilter sets a label filter for containers. // This option can be given multiple times to filter by multiple labels. -// The behavior is such that only containers matching one or more of the -// provided labels will be included. +// The behavior is such that only containers matching all of the provided +// labels will be included. func WithContainerLabelIncludeFilter(label, value string) Option { return func(api *API) { api.containerLabelIncludeFilter[label] = value @@ -927,13 +927,18 @@ func (api *API) processUpdatedContainersLocked(ctx context.Context, updated code slog.F("config_file", configFile), ) + // If we haven't set any include filters, we should explicitly ignore test devcontainers. + if len(api.containerLabelIncludeFilter) == 0 && container.Labels[DevcontainerIsTestRunLabel] == "true" { + continue + } + // Filter out devcontainer tests, unless explicitly set in include filters. - if len(api.containerLabelIncludeFilter) > 0 || container.Labels[DevcontainerIsTestRunLabel] == "true" { - var ok bool + if len(api.containerLabelIncludeFilter) > 0 { + ok := true for label, value := range api.containerLabelIncludeFilter { - if v, found := container.Labels[label]; found && v == value { - ok = true - } + v, found := container.Labels[label] + + ok = ok && (found && v == value) } // Verbose debug logging is fine here since typically filters // are only used in development or testing environments. From d1afe98c32ee085ecccbb2150045e688fa86fe07 Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Thu, 31 Jul 2025 11:17:49 +0000 Subject: [PATCH 2/2] chore: copilot had useful advice for once --- agent/agentcontainers/api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/agentcontainers/api.go b/agent/agentcontainers/api.go index baf8ced3f0857..48ade4bb195f4 100644 --- a/agent/agentcontainers/api.go +++ b/agent/agentcontainers/api.go @@ -934,15 +934,15 @@ func (api *API) processUpdatedContainersLocked(ctx context.Context, updated code // Filter out devcontainer tests, unless explicitly set in include filters. if len(api.containerLabelIncludeFilter) > 0 { - ok := true + includeContainer := true for label, value := range api.containerLabelIncludeFilter { v, found := container.Labels[label] - ok = ok && (found && v == value) + includeContainer = includeContainer && (found && v == value) } // Verbose debug logging is fine here since typically filters // are only used in development or testing environments. - if !ok { + if !includeContainer { logger.Debug(ctx, "container does not match include filter, ignoring devcontainer", slog.F("container_labels", container.Labels), slog.F("include_filter", api.containerLabelIncludeFilter)) continue }