[log] Add debug logging to container detection in sys/container.go#2598
Merged
[log] Add debug logging to container detection in sys/container.go#2598
Conversation
Add a package-level debug logger (logSys) to the sys package following the project's pkg:filename naming convention. Add 4 meaningful debug log calls to IsRunningInContainer() that trace which detection method (dockerenv file, cgroup, or env var) triggered container detection, or confirm when no container environment is found. This helps developers and operators understand container detection behavior at runtime with DEBUG=sys:* or DEBUG=* enabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds targeted debug logging to sys.IsRunningInContainer() to make container detection decisions observable via the project’s DEBUG-controlled logger namespaces.
Changes:
- Introduces a package-level debug logger for
internal/sys/container.go. - Logs container detection flow at function entry, on each positive detection path, and on the “no indicators found” fallback.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "github.com/github/gh-aw-mcpg/internal/logger" | ||
| ) | ||
|
|
||
| var logSys = logger.New("sys:container") |
There was a problem hiding this comment.
Logger variable name logSys is not very descriptive in the sys package and deviates from the documented convention to use log<Component> names matching the component (e.g., logLauncher, logValidation). Consider renaming this to something like logContainer (or similar) to make its purpose clear and reduce ambiguity when grepping logs.
This was referenced Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a package-level debug logger (
logSys) and 4 meaningful debug log calls tointernal/sys/container.go, following the project'spkg:filenamenaming convention from AGENTS.md.Changes
File modified:
internal/sys/container.goWhat was added
github.com/github/gh-aw-mcpg/internal/loggervar logSys = logger.New("sys:container")"Detecting container environment""Container detected via /.dockerenv"(Method 1)"Container detected via /proc/1/cgroup"(Method 2)"Container detected via RUNNING_IN_CONTAINER env var"(Method 3)"No container indicators found, running on host"Why this is useful
IsRunningInContainer()is a critical detection function used to determine execution context and control security behavior (e.g., whether direct command execution is permitted). When troubleshooting container detection issues, developers had no visibility into which detection method triggered (or why detection failed). With this change, runningDEBUG=sys:* ./awmg --config config.tomlreveals exactly which method fires.Quality checklist
pkg:filenameconvention (sys:container)logSysmatcheslogConn,logSchema, etc.)