fix: pass SSH keys and config profile to startInstance in create form
The create-session-form was calling startInstance() without passing the selected config profile and SSH keys. This caused the backend to receive ssh_key_ids=[] and clear the keys that were stored during createInstance. The .ssh directory was never mounted because instance.ssh_key_ids was wiped during the start call. Also includes minor formatting cleanup on the data migration. Quality gates: pytest (18 passed)
This commit is contained in:
@@ -25,14 +25,18 @@ def upgrade() -> None:
|
|||||||
|
|
||||||
# Get the pi-agent manifest
|
# Get the pi-agent manifest
|
||||||
result = conn.execute(
|
result = conn.execute(
|
||||||
sa.text("SELECT id, manifest FROM tool_definition_manifests WHERE name = 'pi-agent'")
|
sa.text(
|
||||||
|
"SELECT id, manifest FROM tool_definition_manifests WHERE name = 'pi-agent'"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
row = result.fetchone()
|
row = result.fetchone()
|
||||||
if not row:
|
if not row:
|
||||||
return
|
return
|
||||||
|
|
||||||
manifest_id, manifest_json = row
|
manifest_id, manifest_json = row
|
||||||
manifest = manifest_json if isinstance(manifest_json, dict) else json.loads(manifest_json)
|
manifest = (
|
||||||
|
manifest_json if isinstance(manifest_json, dict) else json.loads(manifest_json)
|
||||||
|
)
|
||||||
|
|
||||||
mounts = manifest.get("mounts", [])
|
mounts = manifest.get("mounts", [])
|
||||||
original_count = len(mounts)
|
original_count = len(mounts)
|
||||||
@@ -58,14 +62,18 @@ def downgrade() -> None:
|
|||||||
conn = op.get_bind()
|
conn = op.get_bind()
|
||||||
|
|
||||||
result = conn.execute(
|
result = conn.execute(
|
||||||
sa.text("SELECT id, manifest FROM tool_definition_manifests WHERE name = 'pi-agent'")
|
sa.text(
|
||||||
|
"SELECT id, manifest FROM tool_definition_manifests WHERE name = 'pi-agent'"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
row = result.fetchone()
|
row = result.fetchone()
|
||||||
if not row:
|
if not row:
|
||||||
return
|
return
|
||||||
|
|
||||||
manifest_id, manifest_json = row
|
manifest_id, manifest_json = row
|
||||||
manifest = manifest_json if isinstance(manifest_json, dict) else json.loads(manifest_json)
|
manifest = (
|
||||||
|
manifest_json if isinstance(manifest_json, dict) else json.loads(manifest_json)
|
||||||
|
)
|
||||||
|
|
||||||
mounts = manifest.get("mounts", [])
|
mounts = manifest.get("mounts", [])
|
||||||
|
|
||||||
@@ -74,14 +82,16 @@ def downgrade() -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Add the ssh_keys mount back
|
# Add the ssh_keys mount back
|
||||||
mounts.append({
|
mounts.append(
|
||||||
"name": "ssh_keys",
|
{
|
||||||
"target": "/home/user/.ssh",
|
"name": "ssh_keys",
|
||||||
"source_type": "ssh_key",
|
"target": "/home/user/.ssh",
|
||||||
"mode": "0700",
|
"source_type": "ssh_key",
|
||||||
"file_mode": "0600",
|
"mode": "0700",
|
||||||
"readonly": True,
|
"file_mode": "0600",
|
||||||
})
|
"readonly": True,
|
||||||
|
}
|
||||||
|
)
|
||||||
manifest["mounts"] = mounts
|
manifest["mounts"] = mounts
|
||||||
|
|
||||||
conn.execute(
|
conn.execute(
|
||||||
|
|||||||
@@ -171,7 +171,13 @@ export const CreateSessionForm = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
setProgress("Starting container...");
|
setProgress("Starting container...");
|
||||||
await startInstance(projectId, repoId, instance.id);
|
await startInstance(
|
||||||
|
projectId,
|
||||||
|
repoId,
|
||||||
|
instance.id,
|
||||||
|
selectedConfigProfile || undefined,
|
||||||
|
selectedSshKeyIds.length > 0 ? selectedSshKeyIds : undefined
|
||||||
|
);
|
||||||
|
|
||||||
// Reset form
|
// Reset form
|
||||||
if (!fixedProjectId) setSelectedProject("");
|
if (!fixedProjectId) setSelectedProject("");
|
||||||
|
|||||||
Reference in New Issue
Block a user