Skip to content

Commit cc070a4

Browse files
authored
Merge pull request #761 from cvvz/restart-blobfuse-proxy
fix: restart blobfuse proxy when necessary
2 parents b89b8ff + cfd61ef commit cc070a4

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

pkg/blobfuse-proxy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mkdir -p /var/lib/kubelet/plugins/blob.csi.azure.com
88
systemctl enable blobfuse-proxy
99
systemctl start blobfuse-proxy
1010
```
11-
> blobfuse-proxy start unix socket under `/var/lib/kubelet/blobfuse-proxy.sock` by default
11+
> blobfuse-proxy start unix socket under `/var/lib/kubelet/plugins/blob.csi.azure.com/blobfuse-proxy.sock` by default
1212
1313
- make sure all required [Protocol Buffers](https://github.com/protocolbuffers/protobuf) binaries are installed
1414
```console

pkg/blobfuse-proxy/init.sh

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,46 @@ then
3333
$HOST_CMD rm -f /etc/packages-microsoft-prod.deb
3434
fi
3535

36-
if [ ! -f "/host/usr/bin/blobfuse-proxy" ];then
36+
updateBlobfuseProxy="true"
37+
if [ -f "/host/usr/bin/blobfuse-proxy" ];then
38+
old=$(sha256sum /host/usr/bin/blobfuse-proxy | awk '{print $1}')
39+
new=$(sha256sum /blobfuse-proxy/blobfuse-proxy | awk '{print $1}')
40+
if [ "$old" = "$new" ];then
41+
updateBlobfuseProxy="false"
42+
echo "no need to update blobfuse-proxy"
43+
fi
44+
fi
45+
46+
if [ "$updateBlobfuseProxy" = "true" ];then
3747
echo "copy blobfuse-proxy...."
48+
rm -rf /host/var/lib/kubelet/plugins/blob.csi.azure.com/blobfuse-proxy.sock
3849
cp /blobfuse-proxy/blobfuse-proxy /host/usr/bin/blobfuse-proxy
3950
chmod 755 /host/usr/bin/blobfuse-proxy
4051
fi
4152

42-
if [ ! -f "/host/usr/lib/systemd/system/blobfuse-proxy.service" ];then
53+
updateService="true"
54+
if [ -f "/host/usr/lib/systemd/system/blobfuse-proxy.service" ];then
55+
old=$(sha256sum /host/usr/lib/systemd/system/blobfuse-proxy.service | awk '{print $1}')
56+
new=$(sha256sum /blobfuse-proxy/blobfuse-proxy.service | awk '{print $1}')
57+
if [ "$old" = "$new" ];then
58+
updateService="false"
59+
echo "no need to update blobfuse-proxy.service"
60+
fi
61+
fi
62+
63+
if [ "$updateService" = "true" ];then
4364
echo "copy blobfuse-proxy.service...."
4465
mkdir -p /host/usr/lib/systemd/system
4566
cp /blobfuse-proxy/blobfuse-proxy.service /host/usr/lib/systemd/system/blobfuse-proxy.service
4667
fi
4768

48-
if [ "${INSTALL_BLOBFUSE_PROXY}" = "true" ]
49-
then
50-
$HOST_CMD systemctl daemon-reload
51-
$HOST_CMD systemctl enable blobfuse-proxy.service
52-
# According to the issue https://github.com/kubernetes-sigs/blob-csi-driver/issues/693,
53-
# do NOT RESTART blobfuse-proxy, just start it at first time.
54-
$HOST_CMD systemctl start blobfuse-proxy.service
69+
if [ "${INSTALL_BLOBFUSE_PROXY}" = "true" ];then
70+
if [ "$updateBlobfuseProxy" = "true" ] || [ "$updateService" = "true" ];then
71+
echo "start blobfuse-proxy...."
72+
$HOST_CMD systemctl daemon-reload
73+
$HOST_CMD systemctl enable blobfuse-proxy.service
74+
$HOST_CMD systemctl restart blobfuse-proxy.service
75+
fi
5576
fi
5677

5778
if [ "${SET_MAX_OPEN_FILE_NUM}" = "true" ]

0 commit comments

Comments
 (0)