File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 1- use log:: { debug, info} ;
1+ use log:: { debug, info, warn } ;
22use prost_types:: Timestamp ;
33use time:: OffsetDateTime ;
44use tokio:: fs:: { create_dir_all, remove_dir_all} ;
5454 }
5555 let base_dir = format ! ( "{}/{}" , self . dir, sandbox_data. id) ;
5656 create_dir_all ( & * base_dir) . await ?;
57- let opt = SandboxOption :: new ( base_dir, sandbox_data) ;
58- self . sandboxer . create ( & * req. sandbox_id , opt) . await ?;
57+ let opt = SandboxOption :: new ( base_dir. clone ( ) , sandbox_data) ;
58+ if let Err ( e) = self . sandboxer . create ( & * req. sandbox_id , opt) . await {
59+ if let Err ( re) = remove_dir_all ( base_dir) . await {
60+ warn ! ( "roll back in sandbox create rmdir: {}" , re) ;
61+ }
62+ return Err ( e. into ( ) ) ;
63+ }
5964 let resp = ControllerCreateResponse {
6065 sandbox_id : req. sandbox_id . to_string ( ) ,
6166 } ;
You can’t perform that action at this time.
0 commit comments