@@ -114,22 +114,20 @@ async fn main() -> Result<(), anyhow::Error> {
114
114
copy_core_dump_composer_to_hostdir ( host_location) ?;
115
115
apply_sysctl (
116
116
"kernel.core_pattern" ,
117
- format ! ( "{}/core_pattern.bak" , host_location ) . as_str ( ) ,
117
+ format ! ( "{host_location }/core_pattern.bak" ) . as_str ( ) ,
118
118
format ! (
119
- "|{}/{} -c=%c -e=%e -p=%p -s=%s -t=%t -d={} -h=%h -E=%E" ,
120
- host_location, CDC_NAME , core_dir_command
121
- )
119
+ "|{host_location}/{CDC_NAME} -c=%c -e=%e -p=%p -s=%s -t=%t -d={core_dir_command} -h=%h -E=%E" )
122
120
. as_str ( ) ,
123
121
) ?;
124
122
apply_sysctl (
125
123
"kernel.core_pipe_limit" ,
126
- format ! ( "{}/core_pipe_limit.bak" , host_location ) . as_str ( ) ,
124
+ format ! ( "{host_location }/core_pipe_limit.bak" ) . as_str ( ) ,
127
125
"128" ,
128
126
) ?;
129
127
130
128
apply_sysctl (
131
129
"fs.suid_dumpable" ,
132
- format ! ( "{}/suid_dumpable.bak" , host_location ) . as_str ( ) ,
130
+ format ! ( "{host_location }/suid_dumpable.bak" ) . as_str ( ) ,
133
131
& suid,
134
132
) ?;
135
133
@@ -165,12 +163,12 @@ async fn main() -> Result<(), anyhow::Error> {
165
163
let mut i_interval = match interval. parse :: < u64 > ( ) {
166
164
Ok ( v) => v,
167
165
Err ( e) => {
168
- error ! ( "Error parsing interval : {} Error: {}" , interval , e ) ;
169
- panic ! ( "Error parsing interval {}" , e ) ;
166
+ error ! ( "Error parsing interval : {interval } Error: {e}" ) ;
167
+ panic ! ( "Error parsing interval {e}" ) ;
170
168
}
171
169
} ;
172
170
i_interval /= 1000 ;
173
- schedule = format ! ( "1/{} * * * * *" , i_interval ) ;
171
+ schedule = format ! ( "1/{i_interval } * * * * *" ) ;
174
172
if use_inotify == "true" {
175
173
warn ! ( "Both schedule and INotify set. Running schedule" )
176
174
}
@@ -181,8 +179,8 @@ async fn main() -> Result<(), anyhow::Error> {
181
179
let sched = match JobScheduler :: new ( ) . await {
182
180
Ok ( v) => v,
183
181
Err ( e) => {
184
- error ! ( "Schedule Creation Failed with {}" , e ) ;
185
- panic ! ( "Schedule Creation Failed with {}" , e )
182
+ error ! ( "Schedule Creation Failed with {e}" ) ;
183
+ panic ! ( "Schedule Creation Failed with {e}" )
186
184
}
187
185
} ;
188
186
@@ -200,23 +198,23 @@ async fn main() -> Result<(), anyhow::Error> {
200
198
} ) {
201
199
Ok ( v) => v,
202
200
Err ( e) => {
203
- error ! ( "Schedule Job Creation with {} failed, {}" , schedule , e ) ;
204
- panic ! ( "Schedule Job Creation with {} failed, {}" , schedule , e )
201
+ error ! ( "Schedule Job Creation with {schedule } failed, {e}" ) ;
202
+ panic ! ( "Schedule Job Creation with {schedule } failed, {e}" )
205
203
}
206
204
} ;
207
205
info ! ( "Created Schedule job: {:?}" , s_job. guid( ) ) ;
208
206
match sched. add ( s_job) . await {
209
207
Ok ( v) => v,
210
208
Err ( e) => {
211
- error ! ( "Job Add failed {:#?}" , e ) ;
212
- panic ! ( "Job Scheduing failed, {:#?}" , e ) ;
209
+ error ! ( "Job Add failed {e :#?}" ) ;
210
+ panic ! ( "Job Scheduing failed, {e :#?}" ) ;
213
211
}
214
212
} ;
215
213
match sched. start ( ) . await {
216
214
Ok ( v) => v,
217
215
Err ( e) => {
218
- error ! ( "Schedule Start failed {:#?}" , e ) ;
219
- panic ! ( "Schedule Start failed, {:#?}" , e ) ;
216
+ error ! ( "Schedule Start failed {e :#?}" ) ;
217
+ panic ! ( "Schedule Start failed, {e :#?}" ) ;
220
218
}
221
219
} ;
222
220
loop {
@@ -230,16 +228,16 @@ async fn main() -> Result<(), anyhow::Error> {
230
228
let mut inotify = match Inotify :: init ( ) {
231
229
Ok ( v) => v,
232
230
Err ( e) => {
233
- error ! ( "Inotify init failed: {}" , e ) ;
234
- panic ! ( "Inotify init failed: {}" , e )
231
+ error ! ( "Inotify init failed: {e}" ) ;
232
+ panic ! ( "Inotify init failed: {e}" )
235
233
}
236
234
} ;
237
235
info ! ( "INotify Initialised..." ) ;
238
236
match inotify. add_watch ( & core_dir_command, WatchMask :: CLOSE ) {
239
237
Ok ( _) => { }
240
238
Err ( e) => {
241
- error ! ( "Add watch failed: {}" , e ) ;
242
- panic ! ( "Add watch failed: {}" , e )
239
+ error ! ( "Add watch failed: {e}" ) ;
240
+ panic ! ( "Add watch failed: {e}" )
243
241
}
244
242
} ;
245
243
info ! ( "INotify watching : {}" , core_dir_command) ;
@@ -426,7 +424,7 @@ fn generate_crio_config(host_location: &str) -> Result<(), std::io::Error> {
426
424
. unwrap_or_else ( |_| "unix:///run/containerd/containerd.sock" . to_string ( ) ) ;
427
425
let destination = format ! ( "{}/{}" , host_location, "crictl.yaml" ) ;
428
426
let mut crictl_file = File :: create ( destination) ?;
429
- let text = format ! ( "runtime-endpoint: {}\n image-endpoint: {}\n timeout: 2\n debug: false\n pull-image-on-create: false" , endpoint , endpoint ) ;
427
+ let text = format ! ( "runtime-endpoint: {endpoint }\n image-endpoint: {endpoint }\n timeout: 2\n debug: false\n pull-image-on-create: false" ) ;
430
428
crictl_file. write_all ( text. as_bytes ( ) ) ?;
431
429
crictl_file. flush ( ) ?;
432
430
Ok ( ( ) )
@@ -444,14 +442,14 @@ fn copy_core_dump_composer_to_hostdir(host_location: &str) -> Result<(), std::io
444
442
let version = env:: var ( "VENDOR" ) . unwrap_or_else ( |_| "default" . to_string ( ) ) ;
445
443
match version. to_lowercase ( ) . as_str ( ) {
446
444
"default" => {
447
- let location = format ! ( "./vendor/default/{}" , CDC_NAME ) ;
448
- let destination = format ! ( "{}/{}" , host_location , CDC_NAME ) ;
445
+ let location = format ! ( "./vendor/default/{CDC_NAME}" ) ;
446
+ let destination = format ! ( "{host_location }/{CDC_NAME}" ) ;
449
447
info ! ( "Copying the composer from {} to {}" , location, destination) ;
450
448
fs:: copy ( location, destination) ?;
451
449
}
452
450
"rhel7" => {
453
- let location = format ! ( "./vendor/rhel7/{}" , CDC_NAME ) ;
454
- let destination = format ! ( "{}/{}" , host_location , CDC_NAME ) ;
451
+ let location = format ! ( "./vendor/rhel7/{CDC_NAME}" ) ;
452
+ let destination = format ! ( "{host_location }/{CDC_NAME}" ) ;
455
453
info ! ( "Copying the composer from {} to {}" , location, destination) ;
456
454
fs:: copy ( location, destination) ?;
457
455
}
@@ -494,9 +492,7 @@ fn create_env_file(host_location: &str) -> Result<(), std::io::Error> {
494
492
info ! ( "Creating {} file with LOG_LEVEL={}" , destination, loglevel) ;
495
493
let mut env_file = File :: create ( destination) ?;
496
494
let text = format ! (
497
- "LOG_LEVEL={}\n IGNORE_CRIO={}\n CRIO_IMAGE_CMD={}\n USE_CRIO_CONF={}\n FILENAME_TEMPLATE={}\n LOG_LENGTH={}\n POD_SELECTOR_LABEL={}\n TIMEOUT={}\n COMPRESSION={}\n CORE_EVENTS={}\n EVENT_DIRECTORY={}\n " ,
498
- loglevel, ignore_crio, crio_image, use_crio_config, filename_template, log_length, pod_selector_label, timeout, compression, core_events, event_directory
499
- ) ;
495
+ "LOG_LEVEL={loglevel}\n IGNORE_CRIO={ignore_crio}\n CRIO_IMAGE_CMD={crio_image}\n USE_CRIO_CONF={use_crio_config}\n FILENAME_TEMPLATE={filename_template}\n LOG_LENGTH={log_length}\n POD_SELECTOR_LABEL={pod_selector_label}\n TIMEOUT={timeout}\n COMPRESSION={compression}\n CORE_EVENTS={core_events}\n EVENT_DIRECTORY={event_directory}\n " ) ;
500
496
info ! ( "Writing composer .env \n {}" , text) ;
501
497
env_file. write_all ( text. as_bytes ( ) ) ?;
502
498
env_file. flush ( ) ?;
@@ -537,7 +533,7 @@ fn apply_sysctl(name: &str, location: &str, value: &str) -> Result<(), anyhow::E
537
533
}
538
534
539
535
fn overwrite_sysctl ( name : & str , value : & str ) -> Result < ( ) , anyhow:: Error > {
540
- let s = format ! ( "{}={}" , name , value ) ;
536
+ let s = format ! ( "{name }={value}" ) ;
541
537
let output = Command :: new ( "sysctl" )
542
538
. env ( "PATH" , get_path ( ) )
543
539
. args ( [ "-w" , s. as_str ( ) ] )
@@ -557,11 +553,11 @@ fn remove() -> Result<(), anyhow::Error> {
557
553
restore_sysctl ( "kernel" , "core_pipe_limit" ) ?;
558
554
restore_sysctl ( "fs" , "suid_dumpable" ) ?;
559
555
let host_dir = env:: var ( "HOST_DIR" ) . unwrap_or_else ( |_| DEFAULT_BASE_DIR . to_string ( ) ) ;
560
- let exe = format ! ( "{}/{}" , host_dir , CDC_NAME ) ;
561
- let env_file = format ! ( "{}/{}" , host_dir , " .env") ;
562
- let crictl_file = format ! ( "{}/{}" , host_dir , " crictl.yaml") ;
563
- let composer_file = format ! ( "{}/{}" , host_dir , " composer.log") ;
564
- let crictl_exe = format ! ( "{}/{}" , host_dir , " crictl") ;
556
+ let exe = format ! ( "{host_dir }/{CDC_NAME}" ) ;
557
+ let env_file = format ! ( "{host_dir}/ .env" ) ;
558
+ let crictl_file = format ! ( "{host_dir}/ crictl.yaml" ) ;
559
+ let composer_file = format ! ( "{host_dir}/ composer.log" ) ;
560
+ let crictl_exe = format ! ( "{host_dir}/ crictl" ) ;
565
561
566
562
fs:: remove_file ( exe) ?;
567
563
fs:: remove_file ( env_file) ?;
@@ -581,8 +577,8 @@ fn remove() -> Result<(), anyhow::Error> {
581
577
fn restore_sysctl ( prefix : & str , name : & str ) -> Result < ( ) , anyhow:: Error > {
582
578
info ! ( "Restoring Backup of {}" , name) ;
583
579
let host_dir = env:: var ( "HOST_DIR" ) . unwrap_or_else ( |_| DEFAULT_BASE_DIR . to_string ( ) ) ;
584
- let file_name = format ! ( "{}/{}.bak" , host_dir , name ) ;
585
- let sysctl_name = format ! ( "{}.{}" , prefix , name ) ;
580
+ let file_name = format ! ( "{host_dir }/{name }.bak" ) ;
581
+ let sysctl_name = format ! ( "{prefix }.{name}" ) ;
586
582
let line = fs:: read_to_string ( & file_name) ?;
587
583
overwrite_sysctl ( sysctl_name. as_str ( ) , line. as_str ( ) ) ?;
588
584
fs:: remove_file ( file_name) ?;
0 commit comments