mirror of
https://gitlab.com/arm-research/smarter/smarter-device-manager.git
synced 2024-11-21 18:23:34 +00:00
Fix removal of sockets files on shhutdown
This commit is contained in:
parent
879085aaed
commit
304807e48e
22
compile.sh
22
compile.sh
@ -5,6 +5,12 @@
|
|||||||
function printHelp() {
|
function printHelp() {
|
||||||
echo $(basename $0)" options:";
|
echo $(basename $0)" options:";
|
||||||
echo " -A <Architectures to use> # Compiling to ${ARCHS} now, examples: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64"
|
echo " -A <Architectures to use> # Compiling to ${ARCHS} now, examples: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64"
|
||||||
|
if [ ${FLAG_NOCACHE} -gt 0 ]
|
||||||
|
then
|
||||||
|
echo " -C # Do not use cache"
|
||||||
|
else
|
||||||
|
echo " -C # Use cache"
|
||||||
|
fi
|
||||||
if [ ${FLAG_UPLOADIMAGES} -gt 0 ]
|
if [ ${FLAG_UPLOADIMAGES} -gt 0 ]
|
||||||
then
|
then
|
||||||
echo " -U # Do not upload images - the default is upload the images to the registry"
|
echo " -U # Do not upload images - the default is upload the images to the registry"
|
||||||
@ -43,8 +49,9 @@ FLAG_UPLOADMANIFEST=1
|
|||||||
ADDITIONAL_TAG=""
|
ADDITIONAL_TAG=""
|
||||||
ADDITIONAL_IMAGE_NAME=""
|
ADDITIONAL_IMAGE_NAME=""
|
||||||
PUSH_OPTION=""
|
PUSH_OPTION=""
|
||||||
|
FLAG_NOCACHE=0
|
||||||
|
|
||||||
while getopts hA:B:MST:U name
|
while getopts hA:B:MST:UC name
|
||||||
do
|
do
|
||||||
case $name in
|
case $name in
|
||||||
h)
|
h)
|
||||||
@ -52,6 +59,10 @@ do
|
|||||||
exit 0;;
|
exit 0;;
|
||||||
A)
|
A)
|
||||||
ARCHS="$OPTARG";;
|
ARCHS="$OPTARG";;
|
||||||
|
C)
|
||||||
|
[ ${FLAG_NOCACHE} -gt 0 ] && FLAG_NOCACHE=0;
|
||||||
|
[ ${FLAG_NOCACHE} -eq 0 ] && FLAG_NOCACHE=1;
|
||||||
|
;;
|
||||||
U)
|
U)
|
||||||
[ ${FLAG_UPLOADIMAGES} -gt 0 ] && FLAG_UPLOADIMAGES=0;
|
[ ${FLAG_UPLOADIMAGES} -gt 0 ] && FLAG_UPLOADIMAGES=0;
|
||||||
[ ${FLAG_UPLOADIMAGES} -eq 0 ] && FLAG_UPLOADIMAGES=1;
|
[ ${FLAG_UPLOADIMAGES} -eq 0 ] && FLAG_UPLOADIMAGES=1;
|
||||||
@ -93,6 +104,13 @@ EOF
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $FLAG_NOCACHE -gt 0 ]
|
||||||
|
then
|
||||||
|
CACHE_OPTION="--no-cache"
|
||||||
|
else
|
||||||
|
CACHE_OPTION=""
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $FLAG_UPLOADIMAGES -gt 0 ]
|
if [ $FLAG_UPLOADIMAGES -gt 0 ]
|
||||||
then
|
then
|
||||||
PUSH_OPTION="--push"
|
PUSH_OPTION="--push"
|
||||||
@ -100,6 +118,6 @@ else
|
|||||||
PUSH_OPTION="--load"
|
PUSH_OPTION="--load"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker buildx build -t "${REPOSITORY_NAME}${IMAGE_NAME}${ADDITIONAL_IMAGE_NAME}:${BUILD_TAG}" --platform=${ARCHS} ${PUSH_OPTION} .
|
docker buildx build ${CACHE_OPTION} -t "${REPOSITORY_NAME}${IMAGE_NAME}${ADDITIONAL_IMAGE_NAME}:${BUILD_TAG}" --platform=${ARCHS} ${PUSH_OPTION} .
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
17
main.go
17
main.go
@ -193,17 +193,17 @@ L:
|
|||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
for _, devicesInUse := range listDevicesAvailable {
|
for id, _ := range listDevicesAvailable {
|
||||||
switch devicesInUse.deviceType {
|
switch listDevicesAvailable[id].deviceType {
|
||||||
case deviceFileType :
|
case deviceFileType :
|
||||||
devicesInUse.devicePluginSmarter = NewSmarterDevicePlugin(devicesInUse.numDevices, devicesInUse.deviceFile, devicesInUse.deviceName, devicesInUse.socketName)
|
listDevicesAvailable[id].devicePluginSmarter = NewSmarterDevicePlugin(listDevicesAvailable[id].numDevices, listDevicesAvailable[id].deviceFile, listDevicesAvailable[id].deviceName, listDevicesAvailable[id].socketName)
|
||||||
if err = devicesInUse.devicePluginSmarter.Serve(); err != nil {
|
if err = listDevicesAvailable[id].devicePluginSmarter.Serve(); err != nil {
|
||||||
glog.V(0).Info("Could not contact Kubelet, retrying. Did you enable the device plugin feature gate?")
|
glog.V(0).Info("Could not contact Kubelet, retrying. Did you enable the device plugin feature gate?")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case nvidiaSysType :
|
case nvidiaSysType :
|
||||||
devicesInUse.devicePluginNvidia = NewNvidiaDevicePlugin(devicesInUse.numDevices, devicesInUse.deviceName,"NVIDIA_VISIBLE_DEVICES", devicesInUse.socketName, devicesInUse.deviceId)
|
listDevicesAvailable[id].devicePluginNvidia = NewNvidiaDevicePlugin(listDevicesAvailable[id].numDevices, listDevicesAvailable[id].deviceName,"NVIDIA_VISIBLE_DEVICES", listDevicesAvailable[id].socketName, listDevicesAvailable[id].deviceId)
|
||||||
if err = devicesInUse.devicePluginNvidia.Serve(); err != nil {
|
if err = listDevicesAvailable[id].devicePluginNvidia.Serve(); err != nil {
|
||||||
glog.V(0).Info("Could not contact Kubelet, retrying. Did you enable the device plugin feature gate?")
|
glog.V(0).Info("Could not contact Kubelet, retrying. Did you enable the device plugin feature gate?")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -234,13 +234,18 @@ L:
|
|||||||
default:
|
default:
|
||||||
glog.V(0).Infof("Received signal \"%v\", shutting down.", s)
|
glog.V(0).Infof("Received signal \"%v\", shutting down.", s)
|
||||||
for _, devicesInUse := range listDevicesAvailable {
|
for _, devicesInUse := range listDevicesAvailable {
|
||||||
|
glog.V(0).Info("Stopping device ", devicesInUse.deviceName)
|
||||||
switch devicesInUse.deviceType {
|
switch devicesInUse.deviceType {
|
||||||
case deviceFileType :
|
case deviceFileType :
|
||||||
|
glog.V(0).Info("Smarter device type")
|
||||||
if devicesInUse.devicePluginSmarter != nil {
|
if devicesInUse.devicePluginSmarter != nil {
|
||||||
|
glog.V(0).Info("Stopping device")
|
||||||
devicesInUse.devicePluginSmarter.Stop()
|
devicesInUse.devicePluginSmarter.Stop()
|
||||||
}
|
}
|
||||||
case nvidiaSysType :
|
case nvidiaSysType :
|
||||||
|
glog.V(0).Info("Nvidia device type")
|
||||||
if devicesInUse.devicePluginNvidia != nil {
|
if devicesInUse.devicePluginNvidia != nil {
|
||||||
|
glog.V(0).Info("Stopping device")
|
||||||
devicesInUse.devicePluginNvidia.Stop()
|
devicesInUse.devicePluginNvidia.Stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ func (m *SmarterDevicePlugin) Start() error {
|
|||||||
|
|
||||||
// Stop the gRPC server
|
// Stop the gRPC server
|
||||||
func (m *SmarterDevicePlugin) Stop() error {
|
func (m *SmarterDevicePlugin) Stop() error {
|
||||||
|
glog.V(0).Infof("Stopping server with socket ",m.socket)
|
||||||
if m.server == nil {
|
if m.server == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -101,6 +102,7 @@ func (m *SmarterDevicePlugin) Stop() error {
|
|||||||
m.server.Stop()
|
m.server.Stop()
|
||||||
m.server = nil
|
m.server = nil
|
||||||
close(m.stop)
|
close(m.stop)
|
||||||
|
glog.V(0).Info("Server stopped with socket ",m.socket)
|
||||||
|
|
||||||
return m.cleanup()
|
return m.cleanup()
|
||||||
}
|
}
|
||||||
@ -179,6 +181,7 @@ func (m *SmarterDevicePlugin) PreStartContainer(context.Context, *pluginapi.PreS
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *SmarterDevicePlugin) cleanup() error {
|
func (m *SmarterDevicePlugin) cleanup() error {
|
||||||
|
glog.V(0).Info("Removing file ",m.socket)
|
||||||
if err := os.Remove(m.socket); err != nil && !os.IsNotExist(err) {
|
if err := os.Remove(m.socket); err != nil && !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
nodeName: smarter-jetson-xavier-4bcc2584
|
nodeName: smarter-jetson-xavier-4bcc2584
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.1
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.2
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
nodeName: <replace with node to run>
|
nodeName: <replace with node to run>
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.1
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.2
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
nodeName: <replace with node to run>
|
nodeName: <replace with node to run>
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.1
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.2
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.1
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.2
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.1
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.2
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.1
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.2
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.1
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.2
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.1
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.2
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.1
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.1.2
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
Loading…
Reference in New Issue
Block a user