Skip to content

Commit cc4f8da

Browse files
fix(agent/agentcontainers): fix devcontainer integration tests (#19109)
It appears we accidentally merged a change that broke our devcontainer integration tests #18570.
1 parent e4dc2d9 commit cc4f8da

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

agent/agentcontainers/api.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ func WithContainerCLI(ccli ContainerCLI) Option {
161161

162162
// WithContainerLabelIncludeFilter sets a label filter for containers.
163163
// This option can be given multiple times to filter by multiple labels.
164-
// The behavior is such that only containers matching one or more of the
165-
// provided labels will be included.
164+
// The behavior is such that only containers matching all of the provided
165+
// labels will be included.
166166
func WithContainerLabelIncludeFilter(label, value string) Option {
167167
return func(api *API) {
168168
api.containerLabelIncludeFilter[label] = value
@@ -927,17 +927,22 @@ func (api *API) processUpdatedContainersLocked(ctx context.Context, updated code
927927
slog.F("config_file", configFile),
928928
)
929929

930+
// If we haven't set any include filters, we should explicitly ignore test devcontainers.
931+
if len(api.containerLabelIncludeFilter) == 0 && container.Labels[DevcontainerIsTestRunLabel] == "true" {
932+
continue
933+
}
934+
930935
// Filter out devcontainer tests, unless explicitly set in include filters.
931-
if len(api.containerLabelIncludeFilter) > 0 || container.Labels[DevcontainerIsTestRunLabel] == "true" {
932-
var ok bool
936+
if len(api.containerLabelIncludeFilter) > 0 {
937+
includeContainer := true
933938
for label, value := range api.containerLabelIncludeFilter {
934-
if v, found := container.Labels[label]; found && v == value {
935-
ok = true
936-
}
939+
v, found := container.Labels[label]
940+
941+
includeContainer = includeContainer && (found && v == value)
937942
}
938943
// Verbose debug logging is fine here since typically filters
939944
// are only used in development or testing environments.
940-
if !ok {
945+
if !includeContainer {
941946
logger.Debug(ctx, "container does not match include filter, ignoring devcontainer", slog.F("container_labels", container.Labels), slog.F("include_filter", api.containerLabelIncludeFilter))
942947
continue
943948
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy