%define COMPONENT sriovdp
%define RPM_NAME caas-%{COMPONENT}
-%define RPM_MAJOR_VERSION 3.0.0
-%define RPM_MINOR_VERSION 2
+%define RPM_MAJOR_VERSION 3.1.0
+%define RPM_MINOR_VERSION 0
%define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
%define go_version 1.12.10
-%define SRIOVDP_HASH a015e56ae715e2b6dae15e42827e4e8f43eeceac
+%define SRIOVDP 3.1
Name: %{RPM_NAME}
Version: %{RPM_MAJOR_VERSION}
--build-arg http_proxy="${http_proxy}" \
--build-arg https_proxy="${https_proxy}" \
--build-arg no_proxy="${no_proxy}" \
- --build-arg SRIOVDP="%{RPM_MAJOR_VERSION}" \
- --build-arg SRIOVDP_HASH="%{SRIOVDP_HASH}" \
+ --build-arg SRIOVDP="%{SRIOVDP}" \
--build-arg go_version="%{go_version}" \
--tag %{COMPONENT}:%{IMAGE_TAG} \
%{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-build/%{COMPONENT}/
FROM alpine:3.9
RUN apk add --no-cache hwdata-pci jq
-COPY --from=builder /go/bin/sriovdp /usr/local/bin/
-RUN chmod 700 /usr/local/bin/sriovdp
+COPY init.sh /usr/local/bin/
+COPY --from=builder /go/bin/* /usr/local/bin/
+RUN chmod 700 /usr/local/bin/*
WORKDIR /
LABEL io.k8s.display-name="SRIOV Network Device Plugin"
--- /dev/null
+#!/bin/sh
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+while true; do
+ date
+ err=0
+
+ rootdevs=`jq -r .resourceList[].rootDevices[] </etc/pcidp/config.json 2>/dev/null`
+ if [[ -n "$rootdevs" ]]; then
+ for pci in $rootdevs; do
+ vf=`cat /sys/bus/pci/devices/0000:$pci/sriov_numvfs`
+ echo "$pci: $vf VFs"
+ if [[ -z "$vf" || "$vf" == "0" ]]; then
+ echo "No VFs found -> SR-IOV DP cannot be started"
+ err=1
+ fi
+ done
+ else
+ echo "No SR-IOV designated PF found -> SR-IOV DP cannot be started"
+ err=1
+ fi
+
+ if [ $err -eq 0 ]; then
+ exit 0
+ else
+ echo "Error happened -> sleep 10 -> retry"
+ sleep 10
+ fi
+done