From: Ferenc Tóth Date: Mon, 25 Nov 2019 10:47:35 +0000 (+0100) Subject: Fix SR-IOV VF counting in sriovdp init script X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ta%2Fcaas-danm.git;a=commitdiff_plain;h=e8fc0ecf1b3b3dd90d306fad208e2e2f7f243ba6 Fix SR-IOV VF counting in sriovdp init script - Fix SR-IOV VF counting in sriovdp init script - Move init.sh from configmap to docker image - Upgrade SR-IOV Network Device Plugin to v3.1 (instead of using commit hash) Signed-off-by: Ferenc Tóth Change-Id: Ic9c70ba74a6cc69c552487e1356ec6a9d0ad6356 --- diff --git a/SPECS/caas-sriovdp.spec b/SPECS/caas-sriovdp.spec index 90f8d83..74b102a 100644 --- a/SPECS/caas-sriovdp.spec +++ b/SPECS/caas-sriovdp.spec @@ -14,11 +14,11 @@ %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} @@ -50,8 +50,7 @@ docker build \ --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}/ diff --git a/docker-build/sriovdp/Dockerfile b/docker-build/sriovdp/Dockerfile index 65a54a6..59ef992 100644 --- a/docker-build/sriovdp/Dockerfile +++ b/docker-build/sriovdp/Dockerfile @@ -34,8 +34,9 @@ RUN apk add --no-cache gcc musl-dev git curl tar linux-headers \ 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" diff --git a/docker-build/sriovdp/init.sh b/docker-build/sriovdp/init.sh new file mode 100755 index 0000000..e19ce37 --- /dev/null +++ b/docker-build/sriovdp/init.sh @@ -0,0 +1,41 @@ +#!/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[] /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