-
Notifications
You must be signed in to change notification settings - Fork 259
feat: add configurable action timeout for external operations #2342
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
Draft
brynary
wants to merge
9
commits into
main
Choose a base branch
from
feat-action-timeout
base: main
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.
Draft
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
910fec3
feat: add configurable action timeout for external operations
brynary 6af86de
fix: pass timeout through tool creation instead of thread-local
brynary 0634143
refactor: make timeout non-optional in Download::install
brynary 7530f99
fix: change default action timeout from 5 to 10 minutes
brynary 03889a9
feat: make runtime tools use configurable action timeout
brynary 17f40c8
refactor: thread action timeout from CLI throughout the system
brynary f875bc0
refactor: make action_timeout non-optional in Settings
brynary 55c5e6d
📝 qlty fmt
qltysh[bot] 8ac4a7b
refactor: simplify timeout handling by removing Option wrapping
brynary 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 |
|---|---|---|
|
|
@@ -127,7 +127,8 @@ impl Driver { | |
| let timer = Instant::now(); | ||
| let handle = cmd.start()?; | ||
| let pids = handle.pids(); | ||
| let timeout = plan.driver.timeout; | ||
| // Use the minimum of action_timeout and driver timeout | ||
| let timeout = std::cmp::min(plan.settings.action_timeout.as_secs(), plan.driver.timeout); | ||
| let invocation_label = plan.invocation_label(); | ||
| let running = Arc::new(AtomicBool::new(true)); | ||
| let running_clone = Arc::clone(&running); | ||
|
|
@@ -519,12 +520,42 @@ impl Driver { | |
| let timer = Instant::now(); | ||
| let invocation_label = plan.invocation_label(); | ||
|
|
||
| let output = cmd.run().with_context(|| { | ||
| // Use action_timeout from settings | ||
| let timeout = plan.settings.action_timeout; | ||
|
|
||
| // Start the command | ||
| let handle = cmd.start().with_context(|| { | ||
|
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. Can we move the timeout handling down into the cmd code? It looks like we already have a CmdWrapper of some sort. |
||
| format!( | ||
| "Failed to start prepare_script for {}: {}", | ||
| invocation_label, &rerun | ||
| ) | ||
| })?; | ||
| let pids = handle.pids(); | ||
| let running = Arc::new(AtomicBool::new(true)); | ||
| let running_clone = Arc::clone(&running); | ||
| let invocation_label_clone = invocation_label.clone(); | ||
|
|
||
| // Set up timeout thread | ||
| thread::spawn(move || { | ||
| thread::sleep(timeout); | ||
| if running_clone.load(Ordering::SeqCst) { | ||
| error!( | ||
| "Killing {} prepare_script after {}s", | ||
| invocation_label_clone, | ||
| timeout.as_secs() | ||
| ); | ||
| Self::terminate_processes(pids); | ||
| } | ||
| }); | ||
|
|
||
| // Wait for the process to complete | ||
| let output = handle.into_output().with_context(|| { | ||
| format!( | ||
| "Failed to run prepare_script for {}: {}", | ||
| invocation_label, &rerun | ||
| ) | ||
| })?; | ||
| running.store(false, Ordering::SeqCst); | ||
|
|
||
| info!( | ||
| "{}: prepare_script ran {} in {:.3}s (exit {}): stdout: {}", | ||
|
|
@@ -703,7 +734,7 @@ pub mod test { | |
| runtime_version: None, | ||
| plugin_name: "test".to_string(), | ||
| plugin: PluginDef::default(), | ||
| tool: Ruby::new_tool(""), | ||
| tool: Ruby::new_tool("", crate::settings::Settings::default().action_timeout), | ||
| driver_name: "test".to_string(), | ||
| driver: build_driver(vec![], vec![]), | ||
| plugin_configs: vec![], | ||
|
|
@@ -765,7 +796,7 @@ pub mod test { | |
| prefix: Some(prefix.to_string()), | ||
| ..Default::default() | ||
| }, | ||
| tool: Ruby::new_tool(""), | ||
| tool: Ruby::new_tool("", crate::settings::Settings::default().action_timeout), | ||
| driver_name: "test".to_string(), | ||
| driver: build_driver(vec![], vec![]), | ||
| plugin_configs: vec![], | ||
|
|
@@ -790,7 +821,7 @@ pub mod test { | |
| let workspace_dir = PathBuf::from("/var/root"); | ||
| let target_path = PathBuf::from("basic.py"); | ||
| let driver = build_driver(vec![], vec![]); | ||
| let tool = Ruby::new_tool(""); | ||
| let tool = Ruby::new_tool("", crate::settings::Settings::default().action_timeout); | ||
|
|
||
| let plan = InvocationPlan { | ||
| target_root: PathBuf::from(workspace_dir.clone()), | ||
|
|
@@ -841,7 +872,7 @@ pub mod test { | |
| let staging_dir = PathBuf::from("/tmp/staging"); | ||
| let target_path = PathBuf::from("basic.py"); | ||
| let driver = build_driver(vec![], vec![]); | ||
| let tool = Ruby::new_tool(""); | ||
| let tool = Ruby::new_tool("", crate::settings::Settings::default().action_timeout); | ||
|
|
||
| let plan = InvocationPlan { | ||
| target_root: PathBuf::from(staging_dir.clone()), | ||
|
|
||
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
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.
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.
The calculation of the effective timeout should be moved from the executor to the planner