Skip to content

Commit

Permalink
init: refine cleaning up old volume staging path
Browse files Browse the repository at this point in the history
Remove stall vol_data.json, or we cannot remove the directory.
Iterate over the volumes, so that we are not limited by the command length.
  • Loading branch information
huww98 committed Jun 20, 2024
1 parent 8fe9626 commit ed3f095
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions build/lib/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ echo "detected host arch: $ARCH"

OLD_STAGING_PATH=/var/lib/kubelet/plugins/kubernetes.io/csi/pv
if [ -d "$OLD_STAGING_PATH" ]; then
echo unmount old volume staging path. # kubelet will mount the new path at startup.
echo $OLD_STAGING_PATH/*/globalmount
umount $OLD_STAGING_PATH/*/globalmount
rmdir $OLD_STAGING_PATH/*/globalmount
rmdir $OLD_STAGING_PATH/*/
rmdir $OLD_STAGING_PATH
echo cleaning up old volume staging path. # kubelet will mount the new path at startup.
(
cd $OLD_STAGING_PATH
for i in *; do
echo $i
umount $i/globalmount
rmdir $i/globalmount
rm -f $i/vol_data.json
rmdir $i
done
)
rmdir $OLD_STAGING_PATH && echo "removed $OLD_STAGING_PATH, finished cleanup."
fi

## check which plugin is running
Expand Down

0 comments on commit ed3f095

Please sign in to comment.