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 } ;
2
2
use prost_types:: Timestamp ;
3
3
use time:: OffsetDateTime ;
4
4
use tokio:: fs:: { create_dir_all, remove_dir_all} ;
54
54
}
55
55
let base_dir = format ! ( "{}/{}" , self . dir, sandbox_data. id) ;
56
56
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
+ }
59
64
let resp = ControllerCreateResponse {
60
65
sandbox_id : req. sandbox_id . to_string ( ) ,
61
66
} ;
You can’t perform that action at this time.
0 commit comments