diff --git a/.github/workflows/sc-client-server-deb10.yml b/.github/workflows/sc-client-server-deb10.yml index de4ca19f..7e3b4b73 100644 --- a/.github/workflows/sc-client-server-deb10.yml +++ b/.github/workflows/sc-client-server-deb10.yml @@ -25,8 +25,10 @@ env: DOCKER_CLIENT: 'dockerfiles/buster/Dockerfile.client' DOCKER_SERVER_BASE: 'dockerfiles/buster/Dockerfile.server' DOCKER_SERVER: 'npu/broadcom/BCM56850/saivs/Dockerfile.server' + DOCKER_THRIFT_SERVER: 'dockerfiles/buster/Dockerfile.saithrift-server' REDIS_CLIENT: 0 REDIS_SERVER: 0 + THRIFT_SERVER: 0 jobs: @@ -54,6 +56,11 @@ jobs: echo "REDIS_SERVER=1" >> $GITHUB_ENV fi done + for file in "$DOCKER_THRIFT_SERVER" "sai.env"; do + if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then + echo "THRIFT_SERVER=1" >> $GITHUB_ENV + fi + done - name: Build server Docker image run: ./build.sh -i server -o deb10 @@ -70,6 +77,10 @@ jobs: with: name: Server Image path: sc-server.tar + + - name: Build Thrift server Docker image + run: ./build.sh -i server -o deb10 -s thrift + if: ${{ env.THRIFT_SERVER == '1' }} build-sc-client: name: Build SAI Challenger client image diff --git a/.github/workflows/sc-client-server-deb11.yml b/.github/workflows/sc-client-server-deb11.yml index b6639c5b..04d1332d 100644 --- a/.github/workflows/sc-client-server-deb11.yml +++ b/.github/workflows/sc-client-server-deb11.yml @@ -25,8 +25,10 @@ env: DOCKER_CLIENT: 'dockerfiles/bullseye/Dockerfile.client' DOCKER_SERVER_BASE: 'dockerfiles/bullseye/Dockerfile.server' DOCKER_SERVER: 'npu/broadcom/BCM56850/saivs/Dockerfile.server' + DOCKER_THRIFT_SERVER: 'dockerfiles/buster/Dockerfile.saithrift-server' REDIS_CLIENT: 0 REDIS_SERVER: 0 + THRIFT_SERVER: 0 jobs: build-sc-server: @@ -53,6 +55,11 @@ jobs: echo "REDIS_SERVER=1" >> $GITHUB_ENV fi done + for file in "$DOCKER_THRIFT_SERVER" "sai.env"; do + if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then + echo "THRIFT_SERVER=1" >> $GITHUB_ENV + fi + done - name: Build server Docker image run: ./build.sh -i server -o deb11 @@ -70,6 +77,10 @@ jobs: name: Server Image path: sc-server.tar + - name: Build Thrift server Docker image + run: ./build.sh -i server -o deb11 -s thrift + if: ${{ env.THRIFT_SERVER == '1' }} + build-sc-client: name: Build SAI Challenger client image runs-on: ubuntu-20.04 diff --git a/build.sh b/build.sh index 4ac00093..ddfddbf8 100755 --- a/build.sh +++ b/build.sh @@ -149,13 +149,18 @@ if [ "${IMAGE_TYPE}" = "standalone" ]; then elif [ "${IMAGE_TYPE}" = "server" ]; then find ${ASIC_PATH}/../ -type f -name \*.py -exec install -D {} .build/{} \; find ${ASIC_PATH}/../ -type f -name \*.json -exec install -D {} .build/{} \; - docker build -f dockerfiles/${BASE_OS}/Dockerfile.server -t sc-server-base:${BASE_OS} . + if [ "${SAI_INTERFACE}" = "thrift" ]; then + docker build -f dockerfiles/${BASE_OS}/Dockerfile.saithrift-server -t sc-thrift-server-base:${BASE_OS} . + else + docker build -f dockerfiles/${BASE_OS}/Dockerfile.server -t sc-server-base:${BASE_OS} . + fi rm -rf .build/ else docker build -f dockerfiles/${BASE_OS}/Dockerfile.client --build-arg NOSNAPPI=${NOSNAPPI} -t sc-client:${BASE_OS} . if [ "${SAI_INTERFACE}" = "thrift" ]; then docker build -f dockerfiles/${BASE_OS}/Dockerfile.saithrift-client -t sc-thrift-client:${BASE_OS} . fi + exit 0 fi # Build target Docker image @@ -168,6 +173,10 @@ if [ "${IMAGE_TYPE}" = "standalone" ]; then docker build -f Dockerfile --build-arg BASE_OS=${BASE_OS} -t sc-${IMG_NAME}:${BASE_OS} . fi elif [ "${IMAGE_TYPE}" = "server" ]; then - docker build -f Dockerfile.server --build-arg BASE_OS=${BASE_OS} -t sc-server-${IMG_NAME}:${BASE_OS} . + if [ "${SAI_INTERFACE}" = "thrift" ]; then + docker build -f Dockerfile.saithrift-server --build-arg BASE_OS=${BASE_OS} -t sc-thrift-server-${IMG_NAME}:${BASE_OS} . + else + docker build -f Dockerfile.server --build-arg BASE_OS=${BASE_OS} -t sc-server-${IMG_NAME}:${BASE_OS} . + fi fi popd diff --git a/configs/server/supervisord.conf.thrift b/configs/server/supervisord.conf.thrift new file mode 100644 index 00000000..3cd2a363 --- /dev/null +++ b/configs/server/supervisord.conf.thrift @@ -0,0 +1,32 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[eventlistener:dependent-startup] +command=python3 -m supervisord_dependent_startup +autostart=true +autorestart=unexpected +startretries=0 +exitcodes=0,3 +events=PROCESS_STATE +buffer_size=1024 + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n -iNONE +priority=1 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true + +[program:saiserver] +command=/usr/sbin/saiserver -f /usr/share/sonic/hwsku/port_config.ini -p /usr/share/sonic/hwsku/sai.profile +priority=3 +autostart=true +autorestart=true +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup_wait_for=rsyslogd:running + diff --git a/dockerfiles/bullseye/Dockerfile.saithrift-server b/dockerfiles/bullseye/Dockerfile.saithrift-server new file mode 100644 index 00000000..83bfe034 --- /dev/null +++ b/dockerfiles/bullseye/Dockerfile.saithrift-server @@ -0,0 +1,79 @@ +FROM debian:buster-slim + +## Make apt-get non-interactive +ENV DEBIAN_FRONTEND=noninteractive + +COPY sai.env / + +# Install generic packages +RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \ + apt-utils \ + vim \ + curl \ + wget \ + iproute2 \ + unzip \ + git \ + procps \ + build-essential \ + graphviz \ + doxygen \ + aspell \ + python3-pip \ + rsyslog \ + supervisor + +# Add support for supervisord to handle startup dependencies +RUN pip3 install supervisord-dependent-startup==1.4.0 + +# Install generic packages +RUN apt-get install -y \ + libtemplate-perl \ + libconst-fast-perl \ + libmoosex-aliases-perl \ + libnamespace-autoclean-perl \ + libgetopt-long-descriptive-perl \ + aspell-en bison flex g++ \ + libboost-all-dev libevent-dev libssl-dev \ + libpython3-dev libpcap-dev + +WORKDIR /sai + +RUN apt-get install -y pkg-config \ + && wget "http://archive.apache.org/dist/thrift/0.11.0/thrift-0.11.0.tar.gz" \ + && tar -xf thrift-0.11.0.tar.gz \ + && cd thrift-0.11.0 \ + && ./bootstrap.sh \ + && ./configure --prefix=/usr --with-cpp --with-python \ + --with-qt4=no --with-qt5=no --with-csharp=no --with-java=no --with-erlang=no \ + --with-nodejs=no --with-lua=no --with-per=no --with-php=no --with-dart=no \ + --with-ruby=no --with-haskell=no --with-go=no --with-rs=no --with-haxe=no \ + --with-dotnetcore=no --with-d=no \ + && make && make install \ + && pip3 install ctypesgen lib/py \ + && cd /sai \ + && rm -rf thrift-0.11.0 thrift-0.11.0.tar.gz ; + +ENV SAITHRIFTV2=y +ENV GEN_SAIRPC_OPTS="-cve" +ENV SAIRPC_EXTRA_LIBS="-L/usr/local/lib/ -lpthread" + +RUN git clone https://github.com/opencomputeproject/SAI.git \ + && cd SAI && git fetch origin \ + && . /sai.env \ + && git checkout ${SAI_ID} \ + && cd meta \ + && make all libsaimetadata.so libsai.so \ + && cp libsaimetadata.so /usr/lib \ + && cp libsai.so /usr/lib \ + && cd .. \ + && mkdir /usr/include/sai/ \ + && cp ./inc/sai*.h /usr/include/sai/ \ + && cp ./experimental/sai*.h /usr/include/sai/ \ + && make saithrift-install + +WORKDIR /sai-challenger + +COPY configs/server/supervisord.conf.thrift /etc/supervisor/conf.d/supervisord.conf + +CMD ["/usr/bin/supervisord"] diff --git a/dockerfiles/buster/Dockerfile.saithrift-server b/dockerfiles/buster/Dockerfile.saithrift-server new file mode 100644 index 00000000..51c94506 --- /dev/null +++ b/dockerfiles/buster/Dockerfile.saithrift-server @@ -0,0 +1,73 @@ +FROM debian:buster-slim + +RUN echo "deb [arch=amd64] http://debian-archive.trafficmanager.net/debian/ buster main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src [arch=amd64] http://debian-archive.trafficmanager.net/debian/ buster main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb [arch=amd64] http://debian-archive.trafficmanager.net/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src [arch=amd64] http://debian-archive.trafficmanager.net/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb [arch=amd64] http://debian-archive.trafficmanager.net/debian buster-backports main" >> /etc/apt/sources.list + +## Make apt-get non-interactive +ENV DEBIAN_FRONTEND=noninteractive + +COPY sai.env / + +# Install generic packages +RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \ + apt-utils \ + vim \ + curl \ + wget \ + iproute2 \ + unzip \ + git \ + procps \ + build-essential \ + graphviz \ + doxygen \ + aspell \ + python3-pip \ + rsyslog \ + supervisor + +# Add support for supervisord to handle startup dependencies +RUN pip3 install supervisord-dependent-startup==1.4.0 + +# Install generic packages +RUN apt-get install -y \ + libtemplate-perl \ + libconst-fast-perl \ + libmoosex-aliases-perl \ + libnamespace-autoclean-perl \ + libgetopt-long-descriptive-perl \ + aspell-en bison flex g++ \ + libboost-all-dev libevent-dev libssl-dev \ + libpython3-dev libpcap-dev + +WORKDIR /sai + +RUN apt-get install -y thrift-compiler libthrift-dev libthrift-0.11.0 \ + && pip3 install ctypesgen thrift==0.11.0 ; + +ENV SAITHRIFTV2=y +ENV GEN_SAIRPC_OPTS="-cve" +ENV SAIRPC_EXTRA_LIBS="-L/usr/local/lib/ -lpthread" + +RUN git clone https://github.com/opencomputeproject/SAI.git \ + && cd SAI && git fetch origin \ + && . /sai.env \ + && git checkout ${SAI_ID} \ + && cd meta \ + && make all libsaimetadata.so libsai.so \ + && cp libsaimetadata.so /usr/lib \ + && cp libsai.so /usr/lib \ + && cd .. \ + && mkdir /usr/include/sai/ \ + && cp ./inc/sai*.h /usr/include/sai/ \ + && cp ./experimental/sai*.h /usr/include/sai/ \ + && make saithrift-install + +WORKDIR /sai-challenger + +COPY configs/server/supervisord.conf.thrift /etc/supervisor/conf.d/supervisord.conf + +CMD ["/usr/bin/supervisord"] diff --git a/npu/broadcom/BCM56850/saivs/Dockerfile.saithrift-server b/npu/broadcom/BCM56850/saivs/Dockerfile.saithrift-server new file mode 100644 index 00000000..cbbee09b --- /dev/null +++ b/npu/broadcom/BCM56850/saivs/Dockerfile.saithrift-server @@ -0,0 +1,10 @@ +ARG BASE_OS +FROM sc-thrift-server-base:$BASE_OS + +COPY configs/sai.profile /usr/share/sonic/hwsku/ +COPY configs/port_config.ini /usr/share/sonic/hwsku/ +COPY configs/lanemap.ini /usr/share/sonic/hwsku/ + +WORKDIR / + +CMD ["/usr/bin/supervisord"] \ No newline at end of file diff --git a/run.sh b/run.sh index 3d248752..64bb7101 100755 --- a/run.sh +++ b/run.sh @@ -186,7 +186,7 @@ if [ "${IMAGE_TYPE}" = "standalone" ]; then IMG_NAME=$(echo "${PREFIX}-${ASIC_TYPE}-${TARGET}" | tr '[:upper:]' '[:lower:]') OPTS="$OPTS -v $(pwd):/sai-challenger" elif [ "${IMAGE_TYPE}" = "server" ]; then - IMG_NAME=$(echo "sc-server-${ASIC_TYPE}-${TARGET}" | tr '[:upper:]' '[:lower:]') + IMG_NAME=$(echo "${PREFIX}-server-${ASIC_TYPE}-${TARGET}" | tr '[:upper:]' '[:lower:]') else IMG_NAME=${PREFIX}-client OPTS="$OPTS -v $(pwd):/sai-challenger"