Skip to content

Commit

Permalink
Merge pull request #761 from cvvz/restart-blobfuse-proxy
Browse files Browse the repository at this point in the history
fix: restart blobfuse proxy when necessary
  • Loading branch information
k8s-ci-robot authored Sep 28, 2022
2 parents b89b8ff + cfd61ef commit cc070a4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
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

0 comments on commit cc070a4

Please sign in to comment.