@@ -30,7 +30,10 @@ use tokio_util::codec::LengthDelimitedCodec;
3030
3131use super :: api_client:: client:: { EdfSpec , ScriptSpec } ;
3232use crate :: {
33- cli:: { app:: COMAN_VERSION , rpc:: ComanRPCClient } ,
33+ cli:: {
34+ app:: COMAN_VERSION ,
35+ rpc:: { ComanRPCClient , ResourceUsage } ,
36+ } ,
3437 config:: { ComputePlatform , Config , get_data_dir} ,
3538 cscs:: {
3639 api_client:: {
@@ -168,10 +171,10 @@ pub async fn cscs_job_log(
168171 }
169172}
170173
171- pub async fn cscs_resource_usage ( job_id : i64 , system : Option < String > ) -> Result < ( ) > {
174+ pub async fn cscs_resource_usage ( job_id : i64 , system : Option < String > ) -> Result < ResourceUsage > {
172175 let endpoint_id = get_endpoint_id ( job_id, system) . await ?;
173176
174- let alpn: Vec < u8 > = "/coman/rpc" . to_string ( ) . into_bytes ( ) ;
177+ let alpn: Vec < u8 > = b "/coman/rpc". to_vec ( ) ;
175178 let secret_key = SecretKey :: generate ( & mut rand:: rng ( ) ) ;
176179 let endpoint = Endpoint :: builder ( ) . secret_key ( secret_key) . bind ( ) . await ?;
177180
@@ -183,10 +186,11 @@ pub async fn cscs_resource_usage(job_id: i64, system: Option<String>) -> Result<
183186 let framed = codec_builder. new_framed ( combined) ;
184187 let transport = serde_transport:: new ( framed, Bincode :: default ( ) ) ;
185188 let client = ComanRPCClient :: new ( client:: Config :: default ( ) , transport) ;
186- let result = client. spawn ( ) . version ( context:: current ( ) ) . await ?;
187- let _ = dbg ! ( result) ;
188-
189- Ok ( ( ) )
189+ client
190+ . spawn ( )
191+ . resource_usage ( context:: current ( ) )
192+ . await
193+ . wrap_err ( "couldn't get resource usage from remote" )
190194 }
191195 Err ( e) => Err ( e) . wrap_err ( "couldn't establish tunnel to remote" ) ,
192196 }
@@ -517,7 +521,7 @@ async fn inject_coman_squash(
517521 let config = Config :: new ( ) . unwrap ( ) ;
518522 let local_squash_path = maybe_download_latest_squash ( current_system, & config) . await ?;
519523 let target = base_path. join ( "coman.sqsh" ) ;
520- let file_meta = std:: fs:: metadata ( local_squash_path. clone ( ) ) ?;
524+ let file_meta = std:: fs:: metadata ( local_squash_path. clone ( ) ) . wrap_err ( "couldn't load coman squash file" ) ?;
521525
522526 #[ cfg( target_family = "unix" ) ]
523527 let size = file_meta. size ( ) as usize ;
0 commit comments