Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: restart blobfuse proxy when necessary #761

Merged
merged 2 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/blobfuse-proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mkdir -p /var/lib/kubelet/plugins/blob.csi.azure.com
systemctl enable blobfuse-proxy
systemctl start blobfuse-proxy
```
> blobfuse-proxy start unix socket under `/var/lib/kubelet/blobfuse-proxy.sock` by default
> blobfuse-proxy start unix socket under `/var/lib/kubelet/plugins/blob.csi.azure.com/blobfuse-proxy.sock` by default

- make sure all required [Protocol Buffers](https://github.com/protocolbuffers/protobuf) binaries are installed
```console
Expand Down
39 changes: 30 additions & 9 deletions pkg/blobfuse-proxy/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,46 @@ then
$HOST_CMD rm -f /etc/packages-microsoft-prod.deb
fi

if [ ! -f "/host/usr/bin/blobfuse-proxy" ];then
updateBlobfuseProxy="true"
if [ -f "/host/usr/bin/blobfuse-proxy" ];then
old=$(sha256sum /host/usr/bin/blobfuse-proxy | awk '{print $1}')
new=$(sha256sum /blobfuse-proxy/blobfuse-proxy | awk '{print $1}')
if [ "$old" = "$new" ];then
updateBlobfuseProxy="false"
echo "no need to update blobfuse-proxy"
fi
fi

if [ "$updateBlobfuseProxy" = "true" ];then
echo "copy blobfuse-proxy...."
rm -rf /host/var/lib/kubelet/plugins/blob.csi.azure.com/blobfuse-proxy.sock
cp /blobfuse-proxy/blobfuse-proxy /host/usr/bin/blobfuse-proxy
chmod 755 /host/usr/bin/blobfuse-proxy
fi

if [ ! -f "/host/usr/lib/systemd/system/blobfuse-proxy.service" ];then
updateService="true"
if [ -f "/host/usr/lib/systemd/system/blobfuse-proxy.service" ];then
old=$(sha256sum /host/usr/lib/systemd/system/blobfuse-proxy.service | awk '{print $1}')
new=$(sha256sum /blobfuse-proxy/blobfuse-proxy.service | awk '{print $1}')
if [ "$old" = "$new" ];then
updateService="false"
echo "no need to update blobfuse-proxy.service"
fi
fi

if [ "$updateService" = "true" ];then
echo "copy blobfuse-proxy.service...."
mkdir -p /host/usr/lib/systemd/system
cp /blobfuse-proxy/blobfuse-proxy.service /host/usr/lib/systemd/system/blobfuse-proxy.service
fi

if [ "${INSTALL_BLOBFUSE_PROXY}" = "true" ]
then
$HOST_CMD systemctl daemon-reload
$HOST_CMD systemctl enable blobfuse-proxy.service
# According to the issue https://github.com/kubernetes-sigs/blob-csi-driver/issues/693,
# do NOT RESTART blobfuse-proxy, just start it at first time.
$HOST_CMD systemctl start blobfuse-proxy.service
if [ "${INSTALL_BLOBFUSE_PROXY}" = "true" ];then
if [ "$updateBlobfuseProxy" = "true" ] || [ "$updateService" = "true" ];then
echo "start blobfuse-proxy...."
$HOST_CMD systemctl daemon-reload
$HOST_CMD systemctl enable blobfuse-proxy.service
$HOST_CMD systemctl restart blobfuse-proxy.service
fi
fi

if [ "${SET_MAX_OPEN_FILE_NUM}" = "true" ]
Expand Down