Repository navigation
feat(spider-execution-manager): Forward RUST_LOG and configured environment variables to spawned task executors.
#389
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cf9b1fb
Done.
LinZhihao-723 b5bde70
Fix docstring.
LinZhihao-723 0d77c7c
Merge branch 'main' into logging-fix
LinZhihao-723 f7bf6f6
Merge branch 'main' into logging-fix
LinZhihao-723 db9f7b0
Merge branch 'main' into logging-fix
sitaowang1998 fd9fc20
Rename.
LinZhihao-723 0b4fd48
Merge branch 'main' into logging-fix
LinZhihao-723 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
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 |
|---|---|---|
|
|
@@ -49,6 +49,11 @@ pub struct ProcessPoolConfig { | |
| /// Per-spawn filenames mean each respawn naturally rotates onto a fresh file; a long-lived | ||
| /// healthy executor accumulates into one file. | ||
| pub log_dir: PathBuf, | ||
|
|
||
| /// Names of environment variables forwarded from the execution manager's process into each | ||
| /// spawned executor. For each key, the value is read from this process's environment at spawn | ||
| /// time and set on the child; a key that is unset (or non-Unicode) is skipped with a warning. | ||
| pub env_keys: Vec<String>, | ||
| } | ||
|
|
||
| /// Request to execute a task inside the spawned task executor. | ||
|
|
@@ -203,7 +208,8 @@ impl ProcessPool { | |
| /// log file, and wraps the child's stdin/stdout in length-delimited codec frames. | ||
| /// | ||
| /// The child's stderr is redirected to `<log_dir>/<em_id>-<executor_id>.log` in | ||
| /// create-or-append mode. | ||
| /// create-or-append mode. `RUST_LOG`, if set, is forwarded to the spawned task executor to make | ||
| /// the child process' log level match the current execution manager. | ||
| /// | ||
| /// # Returns | ||
| /// | ||
|
|
@@ -234,6 +240,28 @@ impl ProcessPool { | |
| .stdout(Stdio::piped()) | ||
| .stderr(Stdio::from(log_file)) | ||
| .kill_on_drop(true); | ||
|
|
||
| if let Ok(rust_log) = std::env::var("RUST_LOG") { | ||
| command.env("RUST_LOG", rust_log); | ||
| } | ||
|
|
||
| for key in &self.config.env_keys { | ||
| match std::env::var(key) { | ||
| Ok(value) => { | ||
|
Collaborator
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. We need to check and skip
Member
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. I don't think we need to do an extra check since:
|
||
| command.env(key, value); | ||
| } | ||
| Err(e) => { | ||
| tracing::warn!( | ||
| executor_id, | ||
| env_key = % key, | ||
| err = % e, | ||
| "Configured env key could not be read from the execution manager's \ | ||
| environment; skipping." | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| let mut child = command.spawn()?; | ||
| let stdin = child | ||
| .stdin | ||
|
|
||
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
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
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
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.
I don't think
env_keysis a good name in the config. Since these envs are to be passed into task executor., how aboutexecutor_env_keys.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 don't fully agree. While these keys are indeed passed into the executor, it's also required that the execution manager has these environment variables defined. A more precise name would probably be
inherited_env_keys, but that sounds too developer-oriented.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.
Actually, maybe
envorenvironmentshould be sufficient: these are how k8s and docker-compose specify the env keys (without values), respectively.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.
Is there any risk a user of Spider is not a developer or a coding agent? lol.
I am ok with no
keys. How aboutinherited_env?