Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce NDT plugin size by removing MOFED. #178

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 51 additions & 10 deletions plugins/UFM_NDT_Plugin/.ci/ci_matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ kubernetes:

credentials:
- {credentialsId: '2c8fd3fe-df05-4f6f-9d1f-f1896d611434', usernameVariable: 'REST_USER', passwordVariable: 'PASSWORD'}
- {credentialsId: 'e4ba8d7a-d304-4c01-aff9-90de67d97efc', usernameVariable: 'GH_USER', passwordVariable: 'GH_TOKEN'}

volumes:
- {mountPath: /var/run/docker.sock, hostPath: /var/run/docker.sock}
Expand Down Expand Up @@ -55,7 +56,7 @@ steps:
agentSelector: "{nodeLabel: 'UFM-POC'}"
run: |
cd plugins/UFM_NDT_Plugin/build
bash -x ./docker_build.sh
sudo bash -x ./docker_build.sh
cp ufm-plugin-ndt* /auto/UFM/tmp/${JOB_NAME}/${BUILD_ID}/
parallel: false

Expand Down Expand Up @@ -88,24 +89,63 @@ steps:
run: plugins/UFM_NDT_Plugin/.ci/do_add_plugin.sh
parallel: false


- name: start simulation
- name: start simulator
agentSelector: "{nodeLabel: 'UFM-POC'}"
run: |
cd /auto/UFM/tmp/ufm_verification/tests/test_with_sim/performance
IP_SERVER=$(ping $SERVER_HOST -c 1 -s 16 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1)
python run_simulator.py -s $IP_SERVER --topology_path ibnetdiscover_director.txt
credentialsId: 'e4ba8d7a-d304-4c01-aff9-90de67d97efc'
run: |
if [ -z "${GH_TOKEN}" ]; then
echo "GH_TOKEN env variable is not set wont be able to retrieve simulator from UFM repo, exiting..."
exit 1
fi
[ -e /tmp/sim_temp ] && rm -rf /tmp/sim_temp
mkdir -p /tmp/sim_temp
cp plugins/UFM_NDT_Plugin/.ci/simulator/simulator.sh /tmp/sim_temp
pushd /tmp/sim_temp
# get the latest ibnetdiscover_director.txt file
curl -H "Authorization: token ${GH_TOKEN}" \
-H 'Accept: application/vnd.github.v3.raw' \
https://api.github.com/repos/Mellanox/UFM/contents/simulation/ibnetdiscover_files/ibnetdiscover_director.txt -O
if [ ! -e ./ibnetdiscover_director.txt ] || [ ! -e ./simulator.sh ]; then
echo "runsim.sh or ibnetdiscover_director.txt are missing, exiting..."
exit 1
fi
# the server SERVER_HOST should have password-less access no need to set password, use -4 flag to force ipv4
ssh -4 root@${SERVER_HOST} 'rm -rf /root/simulation'
ssh -4 root@${SERVER_HOST} 'mkdir -p /root/simulation'
scp -4 simulator.sh ibnetdiscover_director.txt root@${SERVER_HOST}:/root/simulation/
popd
rm -rf /tmp/sim_temp
# start the simulator in background on remote all FD must be redirected so that ssh wont hang
ssh -4 root@${SERVER_HOST} 'cd /root/simulation; chmod +x /root/simulation/simulator.sh; /root/simulation/simulator.sh -s /root/simulation/ibnetdiscover_director.txt &>/tmp/simulator.log < /dev/null &'
if [ $? -ne 0 ]; then
echo "Something went wrong while starting teh simulator on ${SERVER_HOST}, exiting..."
ssh -4 root@${SERVER_HOST} 'cat /tmp/simulator.log ; rm -rf /tmp/simulator.log'
exit 1
fi
parallel: false

- name: restart ndt plugin
agentSelector: "{nodeLabel: 'UFM-POC'}"
run: |
# restart ufm plugin after simulator start
# verify container is down
ssh -4 root@${SERVER_HOST} '/opt/ufm/scripts/manage_ufm_plugins.sh stop -p ndt'
ssh -4 root@${SERVER_HOST} '/opt/ufm/scripts/manage_ufm_plugins.sh show'
sleep 10
ssh -4 root@${SERVER_HOST} '/opt/ufm/scripts/manage_ufm_plugins.sh start -p ndt'
ssh -4 root@${SERVER_HOST} '/opt/ufm/scripts/manage_ufm_plugins.sh show'
parallel: false

- name: run client tests
agentSelector: "{nodeLabel: 'UFM-POC'}"
run: |
service rsyslog restart
sleep 30
export SERVER_HOST=$SERVER_HOST
# for some reason some hostnames default to faulty ipv6 forcing script to use ipv4
SERVER_IP=$(ping -4 $SERVER_HOST -c 1 -s 16 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1)
export SERVER_HOST=$SERVER_IP
cd plugins/UFM_NDT_Plugin/tests
python3 ndt_plugin_test.py --host $SERVER_HOST
python3 ndt_plugin_test.py --host $SERVER_IP
parallel: false


Expand All @@ -127,9 +167,10 @@ steps:
agentSelector: "{nodeLabel: 'UFM-POC'}"
run: |
plugins/UFM_NDT_Plugin/.ci/finish_simulation.sh
# clean simulator files
ssh -4 root@${SERVER_HOST} 'rm -rf /root/simulation; rm -rf /tmp/simulator.log'
parallel: false


pipeline_start:
run: |
mkdir -p /auto/UFM/tmp/${JOB_NAME}/${BUILD_ID}
Expand Down
2 changes: 1 addition & 1 deletion plugins/UFM_NDT_Plugin/.ci/do_add_plugin.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -x
export SERVER_HOST=$SERVER_HOST
expect << EOF
spawn ssh admin@${SERVER_HOST}
spawn ssh -4 admin@${SERVER_HOST}
expect "Password:*"
send -- "admin\r"
expect "> "
Expand Down
2 changes: 1 addition & 1 deletion plugins/UFM_NDT_Plugin/.ci/do_get_logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ echo "node name : $NODE_NAME"
export WORKSPACE=$WORKSPACE
export SERVER_HOST=$SERVER_HOST
expect << EOF
spawn ssh admin@$SERVER_HOST
spawn ssh -4 admin@$SERVER_HOST
expect "Password:*"
send -- "admin\r"
expect "> "
Expand Down
2 changes: 1 addition & 1 deletion plugins/UFM_NDT_Plugin/.ci/do_install_plugin_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namehost=$(echo $HOSTNAME)
export SERVER_HOST=$SERVER_HOST
export PASSWORD=$PASSWORD
expect << EOF
spawn ssh admin@${SERVER_HOST}
spawn ssh -4 admin@${SERVER_HOST}
expect "Password:*"
send -- "admin\r"
expect "> "
Expand Down
2 changes: 1 addition & 1 deletion plugins/UFM_NDT_Plugin/.ci/do_load_plugin.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -x
export SERVER_HOST=$SERVER_HOST
expect << EOF
spawn ssh admin@${SERVER_HOST}
spawn ssh -4 admin@${SERVER_HOST}
expect "Password:*"
send -- "admin\r"
expect "> "
Expand Down
2 changes: 1 addition & 1 deletion plugins/UFM_NDT_Plugin/.ci/do_remove_plugin.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -x
export SERVER_HOST=$SERVER_HOST
expect << EOF
spawn ssh admin@${SERVER_HOST}
spawn ssh -4 admin@${SERVER_HOST}
expect "Password:*"
send -- "admin\r"
expect "> "
Expand Down
60 changes: 60 additions & 0 deletions plugins/UFM_NDT_Plugin/.ci/simulator/simulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
#This script allows run UFM simulator

GetOpts() {
while getopts :s: op; do
case "$op" in
s) export SIMULATION_FILE="$OPTARG"
;;
*) usage;;
esac
opt="$opt $op"
done
}

usage () {
echo -e " $basename -s <simulation file> "
exit 1
}


COMMON=/opt/ufm/scripts/common
test ! -f $COMMON && echo "missing $COMMON" && exit 1
. $COMMON
basename=`basename $0`

GetOpts $*
test -z "$SIMULATION_FILE" && usage

is_ha=`isHA`
if [ "$is_ha" == "yes" ];then
/etc/init.d/ufmha stop
hamode=hamode
elif [ -f $IS_APPLIANCE_INDICATOR ]; then
/etc/init.d/ufmd stop
hamode=""
else
systemctl stop ufm-enterprise
hamode=""
fi
#run ibsim
export LD_LIBRARY_PATH=/opt/ufm/opensm/lib/
nohup /opt/ufm/opensm/bin/ibsim -S 100000 -P 500000 -N 100000 -s $SIMULATION_FILE &
export LD_PRELOAD=/opt/ufm/opensm/lib/umad2sim/libumad2sim.so
export SIM_HOST=`grep "H-0c" $SIMULATION_FILE | grep Ca | tail -1 | awk -F' ' '{print $3}' | tr -d '\"#'`
if [ -z "$SIM_HOST" ];then
echo "Failed define SIM_HOST value"
exit 1
fi

echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
echo "LD_PRELOAD=${LD_PRELOAD}"
echo "SIM_HOST=${SIM_HOST}"

status=0
/etc/init.d/ufmd $hamode simstart > /dev/null || status=$((status + 1 ))
/etc/init.d/ufmd $hamode mhrestart_without_health > /dev/null || status=$((status + 1 ))
/etc/init.d/ufmd $hamode health_stop > /dev/null || status=$((status + 1 ))
/etc/init.d/ufmd $hamode ufmprd_start > /dev/null || status=$((status + 1 ))
/opt/ufm/opensm/sbin/ibpm -t 50 -m 5 -c /opt/ufm/data/records.conf -n 40000 -l /opt/ufm/files/log/ibpm.log || status=$((status + 1 ))
exit $status
35 changes: 19 additions & 16 deletions plugins/UFM_NDT_Plugin/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
FROM ubuntu:20.04 AS ndt_base_ubuntu20

ENV TZ=Europe/Moscow
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ARG MOFED_VER=5.9-0.5.6.0
ARG MOFED_DIR=MLNX_OFED_LINUX-${MOFED_VER}-ubuntu20.04-x86_64

LABEL maintainer="[email protected]"
ARG _ARCH=x86_64
ARG _DIST=ubuntu20.04
ARG _OFED_VER=5.9-0.5.6.0
ARG OFED_URL=http://nbu-nfs.mellanox.com/auto/sw/release/mlnx_ofed/MLNX_OFED/MLNX_OFED_LINUX-${_OFED_VER}/MLNX_OFED_LINUX-${_OFED_VER}-${_DIST}-${_ARCH}/DEBS
ARG NDT_OFED_DEP="libibumad3 libibverbs1 ibverbs-providers ibutils2 "
ARG BASE_PATH=/opt/ufm/ufm_plugin_ndt

LABEL maintainer="[email protected]"
SHELL ["/bin/bash", "-c"]
ENV TZ=Europe/Moscow
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt upgrade -y && apt-get -y install supervisor python3 python3-pip rsyslog mc wget cron logrotate vim libcap2 curl sudo

Expand All @@ -24,14 +26,15 @@ COPY config/ndt_httpd_proxy.conf config/ndt.conf config/ufm_plugin_ndt_httpd.con

RUN /ui_build.sh

RUN echo "wget -q https://content.mellanox.com/ofed/MLNX_OFED-${MOFED_VER}/${MOFED_DIR}.tgz"
# Install OFED
RUN wget -q https://content.mellanox.com/ofed/MLNX_OFED-${MOFED_VER}/${MOFED_DIR}.tgz && \
tar xf ${MOFED_DIR}.tgz && \
rm -f ${MOFED_DIR}.tgz && \
cd ${MOFED_DIR} && \
./mlnxofedinstall --without-fw-update --user-space-only --skip-distro-check --skip-unsupported-devices-check --force && \
cd ../ && \
rm -rf ${MOFED_DIR}
RUN echo "Download ibdiagnet (${NDT_OFED_DEP}}) from mofed (${_OFED_VER}}) repo" && \
mkdir /tmp/ofed_temp && pushd /tmp/ofed_temp && \
# mofed deb is not a proper repository so cannot be added as a repo but needs to be downloaded and installed manually \
for pkg in ${NDT_OFED_DEP}; do \
full_pkg_name=$(curl ${OFED_URL}/ 2>&1| sed -n "s/.*>\s*\(${pkg}_.*deb\)<.*/\1/p" ); \
curl ${OFED_URL}/${full_pkg_name} -O; \
done && \
apt-get install -y ./* && \
popd && \
rm -rf /tmp/ofed_temp

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]