File tree Expand file tree Collapse file tree 1 file changed +19
-13
lines changed
rust/operator-binary/src/csi_server Expand file tree Collapse file tree 1 file changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -592,19 +592,25 @@ mod pod_dir {
592592 default_addr_dir. get_or_insert ( addr_dir) ;
593593 }
594594
595- let default_addr_link = target_path. join ( "default-address" ) ;
596- // Remove any existing symlink because `tokio::fs::symlink` fails if it already exists.
597- // This happens if the node was restarted. The pod then restarts with the same UID and
598- // the pre-populated volume.
599- let _ = tokio:: fs:: remove_file ( & default_addr_link) . await ;
600- tokio:: fs:: symlink (
601- default_addr_dir
602- . context ( NoDefaultAddressSnafu ) ?
603- . strip_prefix ( target_path)
604- . context ( DefaultAddrIsOutsideRootSnafu ) ?,
605- & default_addr_link,
606- )
607- . await ?;
595+ let relative_default_addr_dir = default_addr_dir
596+ . context ( NoDefaultAddressSnafu ) ?
597+ . strip_prefix ( target_path)
598+ . context ( DefaultAddrIsOutsideRootSnafu ) ?
599+ . to_owned ( ) ;
600+ let default_addr_dir_link = target_path. join ( "default-address" ) ;
601+ // Check if the symlink needs to be updated
602+ if tokio:: fs:: read_link ( & default_addr_dir_link)
603+ . await
604+ . ok ( )
605+ . as_ref ( )
606+ != Some ( & relative_default_addr_dir)
607+ {
608+ // Remove any existing symlink because `tokio::fs::symlink` fails if it already exists.
609+ // This happens if the node was restarted. The pod then restarts with the same UID and
610+ // the pre-populated volume.
611+ let _ = tokio:: fs:: remove_file ( & default_addr_dir_link) . await ;
612+ tokio:: fs:: symlink ( relative_default_addr_dir, & default_addr_dir_link) . await ?;
613+ }
608614 Ok ( ( ) )
609615 }
610616}
You can’t perform that action at this time.
0 commit comments