mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-08 03:10:26 +00:00
Name Daytona sandboxes arc-{run_id} for easy correlation with workflow runs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
11b9159534
commit
686d6bbdb0
3 changed files with 22 additions and 10 deletions
|
|
@ -507,6 +507,7 @@ pub async fn run_command(
|
|||
daytona_client,
|
||||
config,
|
||||
github_app.clone(),
|
||||
Some(run_id.clone()),
|
||||
);
|
||||
let emitter_cb = Arc::clone(&emitter);
|
||||
env.set_event_callback(Arc::new(move |event| {
|
||||
|
|
@ -1373,8 +1374,12 @@ async fn run_preflight(
|
|||
SandboxProvider::Daytona => match daytona_sdk::Client::new().await {
|
||||
Ok(daytona_client) => {
|
||||
let config = daytona_config.unwrap_or_default();
|
||||
let env =
|
||||
crate::daytona_sandbox::DaytonaSandbox::new(daytona_client, config, github_app);
|
||||
let env = crate::daytona_sandbox::DaytonaSandbox::new(
|
||||
daytona_client,
|
||||
config,
|
||||
github_app,
|
||||
None,
|
||||
);
|
||||
Ok(Arc::new(env) as Arc<dyn Sandbox>)
|
||||
}
|
||||
Err(e) => Err(format!("Daytona client creation failed: {e}")),
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ pub struct DaytonaSandbox {
|
|||
event_callback: Option<SandboxEventCallback>,
|
||||
/// HTTPS origin URL stored after clone so we can refresh push credentials later.
|
||||
origin_url: tokio::sync::OnceCell<String>,
|
||||
run_id: Option<String>,
|
||||
}
|
||||
|
||||
impl DaytonaSandbox {
|
||||
|
|
@ -167,6 +168,7 @@ impl DaytonaSandbox {
|
|||
client: daytona_sdk::Client,
|
||||
config: DaytonaConfig,
|
||||
github_app: Option<GitHubAppCredentials>,
|
||||
run_id: Option<String>,
|
||||
) -> Self {
|
||||
Self {
|
||||
config,
|
||||
|
|
@ -176,6 +178,7 @@ impl DaytonaSandbox {
|
|||
rg_available: tokio::sync::OnceCell::const_new(),
|
||||
event_callback: None,
|
||||
origin_url: tokio::sync::OnceCell::new(),
|
||||
run_id,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -218,11 +221,15 @@ impl DaytonaSandbox {
|
|||
|
||||
/// Build `SandboxBaseParams` from config, generating a unique sandbox name.
|
||||
fn base_params(&self) -> daytona_sdk::SandboxBaseParams {
|
||||
let name = format!(
|
||||
"arc-{}-{:04x}",
|
||||
chrono::Utc::now().format("%Y%m%d-%H%M%S"),
|
||||
rand::thread_rng().gen_range(0..0x10000u32),
|
||||
);
|
||||
let name = if let Some(ref id) = self.run_id {
|
||||
format!("arc-{id}")
|
||||
} else {
|
||||
format!(
|
||||
"arc-{}-{:04x}",
|
||||
chrono::Utc::now().format("%Y%m%d-%H%M%S"),
|
||||
rand::thread_rng().gen_range(0..0x10000u32),
|
||||
)
|
||||
};
|
||||
let (network_block_all, network_allow_list) = match &self.config.network {
|
||||
Some(DaytonaNetwork::Block) => (Some(true), None),
|
||||
Some(DaytonaNetwork::AllowAll) => (Some(false), None),
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ async fn create_env_with_github_app(
|
|||
let client = daytona_sdk::Client::new()
|
||||
.await
|
||||
.expect("Failed to create Daytona client — is DAYTONA_API_KEY set?");
|
||||
DaytonaSandbox::new(client, DaytonaConfig::default(), github_app)
|
||||
DaytonaSandbox::new(client, DaytonaConfig::default(), github_app, None)
|
||||
}
|
||||
|
||||
fn load_github_app_credentials() -> arc_workflows::github_app::GitHubAppCredentials {
|
||||
|
|
@ -250,7 +250,7 @@ async fn daytona_snapshot_sandbox() {
|
|||
};
|
||||
|
||||
let creds = load_github_app_credentials();
|
||||
let env = DaytonaSandbox::new(client, config, Some(creds));
|
||||
let env = DaytonaSandbox::new(client, config, Some(creds), None);
|
||||
env.initialize().await.unwrap();
|
||||
|
||||
// Verify rg is available (installed by snapshot)
|
||||
|
|
@ -922,7 +922,7 @@ async fn run_daytona_cli_test(provider: Provider, model: &str, install_command:
|
|||
}),
|
||||
..DaytonaConfig::default()
|
||||
};
|
||||
let env = DaytonaSandbox::new(client, config, Some(creds));
|
||||
let env = DaytonaSandbox::new(client, config, Some(creds), None);
|
||||
env.initialize().await.unwrap();
|
||||
let env: Arc<dyn Sandbox> = Arc::new(env);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue