-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Improve logging in boot.go to facilitate future triaging #38342
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
Open
shunping
wants to merge
4
commits into
apache:master
Choose a base branch
from
shunping:debug-boot
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+19
−11
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -185,10 +185,14 @@ func launchSDKProcess() error { | |
| } | ||
|
|
||
| experiments := getExperiments(options) | ||
| logger.Printf(ctx, "Experiments=%v", experiments) | ||
|
|
||
| pipNoBuildIsolation = false | ||
| if slices.Contains(experiments, "pip_no_build_isolation") { | ||
| pipNoBuildIsolation = true | ||
| logger.Printf(ctx, "Disabled build isolation when installing packages with pip") | ||
| logger.Printf(ctx, "Build isolation disabled when installing packages with pip") | ||
| } else { | ||
| logger.Printf(ctx, "Build isolation enabled when installing packages with pip") | ||
| } | ||
|
|
||
| // (2) Retrieve and install the staged packages. | ||
|
|
@@ -408,6 +412,10 @@ func installSetupPackages(ctx context.Context, logger *tools.Logger, files []str | |
| bufLogger := tools.NewBufferedLogger(logger) | ||
| bufLogger.Printf(ctx, "Installing setup packages ...") | ||
|
|
||
| if err := logRuntimeDependencies(ctx, bufLogger, "pre-installation"); err != nil { | ||
| bufLogger.Printf(ctx, "couldn't fetch the runtime python dependencies: %v", err) | ||
| } | ||
|
|
||
| // Install the Dataflow Python SDK if one was staged. In released | ||
| // container images, SDK is already installed, but can be overriden | ||
| // using the --sdk_location pipeline option. | ||
|
|
@@ -432,7 +440,7 @@ func installSetupPackages(ctx context.Context, logger *tools.Logger, files []str | |
| if err := pipInstallPackage(ctx, logger, files, workDir, workflowFile, false, true, nil); err != nil { | ||
| return fmt.Errorf("failed to install workflow: %v", err) | ||
| } | ||
| if err := logRuntimeDependencies(ctx, bufLogger); err != nil { | ||
| if err := logRuntimeDependencies(ctx, bufLogger, "post-installation"); err != nil { | ||
| bufLogger.Printf(ctx, "couldn't fetch the runtime python dependencies: %v", err) | ||
| } | ||
| if err := logSubmissionEnvDependencies(ctx, bufLogger, workDir); err != nil { | ||
|
|
@@ -485,20 +493,20 @@ func processArtifactsInSetupOnlyMode() { | |
|
|
||
| // logRuntimeDependencies logs the python dependencies | ||
| // installed in the runtime environment. | ||
| func logRuntimeDependencies(ctx context.Context, bufLogger *tools.BufferedLogger) error { | ||
| func logRuntimeDependencies(ctx context.Context, bufLogger *tools.BufferedLogger, phase string) error { | ||
| pythonVersion, err := expansionx.GetPythonVersion() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| bufLogger.Printf(ctx, "Using Python version:") | ||
| bufLogger.Printf(ctx, "Using Python version (%s):", phase) | ||
| args := []string{"--version"} | ||
| if err := execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...); err != nil { | ||
| bufLogger.FlushAtError(ctx) | ||
| } else { | ||
| bufLogger.FlushAtDebug(ctx) | ||
| } | ||
| bufLogger.Printf(ctx, "Logging runtime dependencies:") | ||
| args = []string{"-m", "pip", "freeze"} | ||
| bufLogger.Printf(ctx, "Logging runtime dependencies (%s):", phase) | ||
| args = []string{"-m", "pip", "freeze", "--all"} | ||
|
Collaborator
Author
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. The argument |
||
| if err := execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...); err != nil { | ||
| bufLogger.FlushAtError(ctx) | ||
| } else { | ||
|
|
||
Oops, something went wrong.
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.
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.
What is the use-case for this?
Uh oh!
There was an error while loading. Please reload this page.
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.
While we already log dependencies after installation,
boot.goexits immediately if any installation step fails.Adding a pre-installation call ensures we capture the environment state regardless of whether the installation succeeds. This is useful for reproducing and triaging environment-specific failures from customers.
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.
'pre-installation', 'post-installation' sounds a bit cryptic for end user who is not a beam dev, and the output may be a a bit verbose.
How about we think of a way to enable debug logging for boot.go and only print pre-installation env if debug logging is enabled? then, we can ask affected customers to run their pipeline with debug logging enabled if necessary.
Uh oh!
There was an error while loading. Please reload this page.
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.
The new logs only add 4 lines and are already emitted at the DEBUG level, which allows users to filter them out as needed.
Given this minimal footprint, I’d prefer to avoid adding complexity of a new configuration mechanism or flag in
boot.goto keep the boot logic as simple as possible.I used the term "installation" because of the line of "Installing setup packages ..." prior to these logs (see above screenshot too), but I am open to any better term.
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.
sg, thanks!
Uh oh!
There was an error while loading. Please reload this page.
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.
i do think that the
pre-installationoutput is confusing unless you know why you need to look at it; most of the time, you need to look at the final list after all the installations.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.
Perhaps we could change logs to the below:
Installing setup packages->Installing additional runtime dependencies if any are specified in --requirements_file, --setup_file or --extra_package options.post-installation->post-installation (final runtime environment)Uh oh!
There was an error while loading. Please reload this page.
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.
Great. I made the change to use "initial runtime environmemnt" and "final runtime environment". I also included some small edits to existing messages to make them consistent and concise. PTAL