Skip to content

Commit c622bd7

Browse files
author
Kailun Qin
committed
[Feature] Add SGX unix socket detection support
In the current implementation, a new kubelet instance deletes all the existing unix sockets under /var/lib/kubelet/device-plugins when it starts. Besides, the SGX unix socket can be accidentally removed during ops. To this end, we're proposing in this patch a detection mechanism for SGX device plugin that will monitor the deletion of SGX unix socket, re-start the device plugin grpc server and re-register itself with kubelet instance upon such an event. Signed-off-by: Kailun Qin <kailun.qkl@antfin.com>
1 parent b50f094 commit c622bd7

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

cmd/sgx-device-plugin/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ L:
5757
klog.Infof("Inotify: %s created, restarting ...", devicepluginapi.KubeletSocket)
5858
restart = true
5959
}
60+
if event.Name == deviceplugin.ServerSock && event.Op&fsnotify.Remove == fsnotify.Remove {
61+
klog.Infof("Inotify: %s removed, restarting ...", deviceplugin.ServerSock)
62+
restart = true
63+
}
6064

6165
case err := <-watcher.Errors:
6266
klog.Infof("inotify: %s", err)

pkg/device_plugin/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
// ResourceNameSGX is resource name registered to kubelet.
2222
ResourceNameSGX = vendor + "/sgx_epc_MiB"
2323

24-
serverSock = devicepluginapi.DevicePluginPath + "/sgx.sock"
24+
ServerSock = devicepluginapi.DevicePluginPath + "sgx.sock"
2525
envDisableHealthChecks = "DP_DISABLE_HEALTHCHECKS"
2626
allHealthChecks = "xids"
2727

@@ -42,7 +42,7 @@ func NewSGXDevicePlugin() (*SGXDevicePlugin, error) {
4242

4343
return &SGXDevicePlugin{
4444
devs: devs,
45-
socket: serverSock,
45+
socket: ServerSock,
4646

4747
stop: make(chan interface{}),
4848
health: make(chan *devicepluginapi.Device),

0 commit comments

Comments
 (0)