-
Notifications
You must be signed in to change notification settings - Fork 1
[TOW-1299] App Isolation traits #159
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
sammuti
wants to merge
16
commits into
develop
Choose a base branch
from
feature/tow-1299
base: develop
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.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b74ea44
impl first iter
sammuti 64c8956
Working k8s backend
sammuti 079982a
move k8s backend to tower-runner
sammuti 164c3c8
Minor
sammuti c066ab6
Remove cache abstractions
sammuti 3fb7831
Refactor run.rs correctly
sammuti 03c9a6d
Refactor back the k8s runtime
sammuti ef57bf7
minor
sammuti 7432ed6
Make AppLauncher generic over ExecutionBackend instead of app
sammuti d741dac
Renaming local -> subprocess
sammuti 26369da
CliBackend
sammuti 948d901
remove AppLauncher
sammuti 3b2947c
minor
sammuti 6d8860d
Update deps
sammuti bf8b042
dep updates
sammuti ad2c197
BundleRef -> PackageRef
sammuti 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| //! Simple backend for CLI --local runs | ||
| //! | ||
| //! This backend follows a simpler pattern than SubprocessBackend: | ||
| //! - The caller creates the output channel and passes the sender | ||
| //! - The caller keeps the receiver for direct consumption | ||
| //! - No need for complex handle.logs() method | ||
| //! - Single consumer model (better for CLI) | ||
|
|
||
| use crate::errors::Error; | ||
| use crate::local::LocalApp; | ||
| use crate::{App, OutputSender, StartOptions, Status}; | ||
| use std::collections::HashMap; | ||
| use std::path::PathBuf; | ||
| use std::sync::Arc; | ||
| use tokio::sync::Mutex; | ||
| use tower_package::Package; | ||
|
|
||
| /// CliBackend executes apps as local subprocesses for CLI --local runs | ||
| pub struct CliBackend { | ||
| /// Optional default cache directory to use | ||
| cache_dir: Option<PathBuf>, | ||
| } | ||
|
|
||
| impl CliBackend { | ||
| pub fn new(cache_dir: Option<PathBuf>) -> Self { | ||
| Self { cache_dir } | ||
| } | ||
|
|
||
| /// Launch an app with the given parameters | ||
| /// | ||
| /// Unlike SubprocessBackend.create(), this takes OutputSender directly | ||
| /// so the caller can immediately start consuming output from their receiver. | ||
| pub async fn launch( | ||
| &self, | ||
| ctx: tower_telemetry::Context, | ||
| output_sender: OutputSender, | ||
| package: Package, | ||
| environment: String, | ||
| secrets: HashMap<String, String>, | ||
| parameters: HashMap<String, String>, | ||
| env_vars: HashMap<String, String>, | ||
| ) -> Result<CliHandle, Error> { | ||
| let opts = StartOptions { | ||
| ctx, | ||
| package, | ||
| cwd: None, // LocalApp determines cwd from package | ||
| environment, | ||
| secrets, | ||
| parameters, | ||
| env_vars, | ||
| output_sender, | ||
| cache_dir: self.cache_dir.clone(), | ||
| }; | ||
|
|
||
| // Start the LocalApp | ||
| let app = LocalApp::start(opts).await?; | ||
|
|
||
| Ok(CliHandle { | ||
| app: Arc::new(Mutex::new(Some(app))), | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| /// CliHandle provides lifecycle management for a CLI local subprocess execution | ||
| pub struct CliHandle { | ||
| app: Arc<Mutex<Option<LocalApp>>>, | ||
| } | ||
|
|
||
| impl CliHandle { | ||
| /// Get current execution status | ||
| pub async fn status(&self) -> Result<Status, Error> { | ||
| let guard = self.app.lock().await; | ||
| if let Some(app) = guard.as_ref() { | ||
| app.status().await | ||
| } else { | ||
| // App has already been terminated | ||
| Ok(Status::Crashed { code: -1 }) | ||
| } | ||
| } | ||
|
|
||
| /// Terminate execution gracefully | ||
| pub async fn terminate(&mut self) -> Result<(), Error> { | ||
| let mut guard = self.app.lock().await; | ||
| if let Some(mut app) = guard.take() { | ||
| app.terminate().await | ||
| } else { | ||
| Ok(()) | ||
| } | ||
| } | ||
| } |
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.
This was renamed to "cli" but runner in third party infrastructure (e.g. self-hosted runners) will use local processes too, not Kubernetes...