Skip to content

Commit

Permalink
Merge pull request #897 from ywc689/new-tools
Browse files Browse the repository at this point in the history
new-tools: dpvs-agent & healthcheck
  • Loading branch information
ywc689 authored Aug 21, 2023
2 parents 0dd5120 + b1cdb7c commit eaa67b9
Show file tree
Hide file tree
Showing 292 changed files with 38,610 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
- name: make
run: make -j

build-debug:
build-all:
runs-on: self-hosted
env:
PKG_CONFIG_PATH: /data/dpdk/dpdklib/lib64/pkgconfig
steps:
- uses: actions/checkout@v2
- name: config
run: sed -i 's/#CFLAGS +=/CFLAGS +=/' src/config.mk && sed -i 's/^#DEBUG := 1/DEBUG := 1/' src/Makefile
run: sed -i 's/=n$/=y/' config.mk
- name: make
run: make -j
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
MAKE = make
CC = gcc
LD = ld
RM = rm

SUBDIRS = src tools

Expand All @@ -29,6 +30,8 @@ export INSDIR

export KERNEL = $(shell /bin/uname -r)

include $(CURDIR)/config.mk

all:
for i in $(SUBDIRS); do $(MAKE) -C $$i || exit 1; done

Expand All @@ -43,3 +46,6 @@ distclean:
install:all
-mkdir -p $(INSDIR)
for i in $(SUBDIRS); do $(MAKE) -C $$i install || exit 1; done

uninstall:
-$(RM) -f $(TARGET) $(INSDIR)/*
33 changes: 33 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# configs
export CONFIG_DPVS_MAX_SOCKET=2
export CONFIG_DPVS_MAX_LCORE=64

## modules
export CONFIG_DPVS_AGENT=n
export CONFIG_IXGEB_PMD=y
export CONFIG_DPVS_LOG=y
export CONFIG_PDUMP=y
export CONFIG_ICMP_REDIRECT_CORE=n

# debugging and logging
export CONFIG_DEBUG=n
export CONFIG_DPVS_NEIGH_DEBUG=n
export CONFIG_RECORD_BIG_LOOP=n
export CONFIG_DPVS_SAPOOL_DEBUG=n
export CONFIG_DPVS_IPVS_DEBUG=n
export CONFIG_DPVS_SERVICE_DEBUG=n
export CONFIG_SYNPROXY_DEBUG=n
export CONFIG_TIMER_MEASURE=n
export CONFIG_TIMER_DEBUG=n
export CONFIG_DPVS_CFG_PARSER_DEBUG=n
export CONFIG_NETIF_BONDING_DEBUG=n
export CONFIG_TC_DEBUG=n
export CONFIG_DPVS_IPVS_STATS_DEBUG=n
export CONFIG_DPVS_IP_HEADER_DEBUG=n
export CONFIG_DPVS_MBUF_DEBUG=n
export CONFIG_DPVS_IPSET_DEBUG=n
export CONFIG_NDISC_DEBUG=n
export CONFIG_MSG_DEBUG=n
export CONFIG_DPVS_MP_DEBUG=n
export CONFIG_DPVS_NETIF_DEBUG=n
export CONFIG_DPVS_ICMP_DEBUG=n
2 changes: 1 addition & 1 deletion doc/Worker-Performance-Tuning.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ In case of the following situations, you should consider this performance tuning
* There exists big worker loops.

> To observe worker loop time, you should uncomment the macro "CONFIG_RECORD_BIG_LOOP" in src/config.mk,recompile DPVS program and run it.
> To observe worker loop time, you should set "CONFIG_RECORD_BIG_LOOP=y" in `config.mk`,recompile DPVS program and run it.
>
> Besides, macros "BIG_LOOP_THRESH_SLAVE" and "BIG_LOOP_THRESH_MASTER" define the threshold time of worker loop. Modify them if needed.
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ Firstly, DPVS runs with `WARNING` log level by default. You can change it in `/e
Use low level log such as "INFO" or "DEBUG" may help find more clues to your problem.
Secondly, some modules support more detailed debug log only if you enable it when compile DPVS. The supported flags are defined but commented in [src/config.mk](../src/config.mk), some of which are listed below. Uncomment it and recompile DPVS if you need to debug the corresponding module.
Secondly, some modules support more detailed debug log only if you enable it when compile DPVS. The modular debug options are available in [config.mk](../config.mk), some of which are listed below. Change the value to "y" and recompile DPVS if you want to debug a module.
```
- CONFIG_DPVS_IPVS_DEBUG # for ipvs forwarding debug
Expand Down
2 changes: 1 addition & 1 deletion include/ipvs/dest.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ int dp_vs_dest_edit_health(struct dp_vs_service *svc, struct dp_vs_dest_conf *ud
void dp_vs_dest_unlink(struct dp_vs_service *svc,
struct dp_vs_dest *dest, int svcupd);

void dp_vs_dest_put(struct dp_vs_dest *dest);
void dp_vs_dest_put(struct dp_vs_dest *dest, bool timerlock);

int dp_vs_dest_del(struct dp_vs_service *svc, struct dp_vs_dest_conf *udest);

Expand Down
138 changes: 138 additions & 0 deletions scripts/dpvs_log_rotate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/bin/env bash

# Set target directory for cleaning
TARGET_DIR="/var/log/healthcheck"

# Set log file name pattern
LOG_FILENAME_PATTERN="*\.log\.*"

# Set the maximum usage percentage and the target usage percentage
MAX_USAGE=80
TARGET_USAGE=40

# Set the minimum number of log files to keep
MIN_FILES=12

# Set the maximum number of files to delete in one run
MAX_DELETE=10000

OPTS=`getopt -o d:p:u:l:K:D:h --long \
log-directory:,filename-pattern:,disk-usage-high:,\
disk-usage-low:,min-files-kept:,max-deletions:,help,\
-n "$0" -- "$@"`
eval set -- "$OPTS"
while true
do
case "$1" in
-d|--log-directory)
TARGET_DIR="$2"
shift 2
;;
-p|--filename-pattern)
LOG_FILENAME_PATTERN="$2"
shift 2
;;
-u|--disk-usage-high)
MAX_USAGE="$2"
shift 2
;;
-l|--disk-usage-low)
TARGET_USAGE="$2"
shift 2
;;
-K|--min-files-kept)
MIN_FILES="$2"
shift 2
;;
-D|--max-deletions)
MAX_DELETE="$2"
shift 2
;;
-h|--help)
echo "[usage] $0 [ OPTS ]"
echo "OPTS:"
echo " -d|--log-directory DIRECTORY"
echo " -p|--filename-pattern REGEXPR"
echo " -u|--disk-usage-high 0-100"
echo " -l|--disk-usage-low 0-100"
echo " -K|--min-files-kept NUM"
echo " -D|--max-deletions NUM"
echo " -h|--help"
exit 0
;;
--)
shift
break
;;
*)
echo "Param Error!"
exit 1
;;
esac
done

NotRecognized=$(for arg do printf "$arg " ; done)
[ ! -z "$NotRecognized" ] && echo "Unrecognized Opts: ${NotRecognized}" && exit 1

echo "CONFIGS:"
echo " log-directory: ${TARGET_DIR}"
echo " filename-pattern: ${LOG_FILENAME_PATTERN}"
echo " disk-usage-high: ${MAX_USAGE}"
echo " disk-usage-low: ${TARGET_USAGE}"
echo " min-files-kept: ${MIN_FILES}"
echo " max-deletions: ${MAX_DELETE}"

[ ! -d ${TARGET_DIR} ] && echo "invalid --log-directory \"${TARGET_DIR}\", not found!" && exit 1
echo ${MAX_USAGE} | egrep ^[0-9]+$ >/dev/null; [ $? -ne 0 ] && echo "invalid --disk-usage-high" && exit 1
echo ${TARGET_USAGE} | egrep ^[0-9]+$ >/dev/null; [ $? -ne 0 ] && echo "invalid --disk-usage-low" && exit 1
echo ${MIN_FILES} | egrep ^[0-9]+$ >/dev/null; [ $? -ne 0 ] && echo "invalid --min-files-kept" && exit 1
echo ${MAX_DELETE} | egrep ^[0-9]+$ >/dev/null; [ $? -ne 0 ] && echo "invalid --max-deletions" && exit 1
res=$(echo "${MAX_USAGE} < 100" | bc); [ "$res" -ne 1 ] && echo "--disk-usage-high must less than 100" && exit 1
res=$(echo "${MAX_USAGE} > ${TARGET_USAGE}" | bc); [ "$res" -ne 1 ] && echo "--disk-usage-high must greater than --disk-usage-low" && exit 1

# Get the current disk usage
CURRENT_USAGE=$(df -P ${TARGET_DIR} | awk 'NR==2 {printf "%d", $5}')

# Initialize a counter for deleted files
DELETED_FILES=0

# Start the cleaning process if the disk usage is higher than the defined MAX_USAGE
if [ "${CURRENT_USAGE}" -gt "${MAX_USAGE}" ]; then
echo "Disk usage is ${CURRENT_USAGE}%, starting cleaning process."

# Find and delete logs until disk usage reaches TARGET_USAGE or MAX_DELETE files are deleted
while [ "${CURRENT_USAGE}" -gt "${TARGET_USAGE}" ] && [ "${DELETED_FILES}" -lt "${MAX_DELETE}" ]; do
# Check the number of log files
NUM_FILES=$(find ${TARGET_DIR} -type f -name ${LOG_FILENAME_PATTERN} | wc -l)

# Ensure that at least MIN_FILES log files remain
if [ "${NUM_FILES}" -le "${MIN_FILES}" ]; then
echo "Reached minimum number of log files (${MIN_FILES}), aborting."
exit 1
fi

# Find the oldest log file
OLDEST_LOG=$(find ${TARGET_DIR} -type f -name ${LOG_FILENAME_PATTERN} -printf '%T+ %p\n' | sort | head -n1 | cut -d' ' -f2)

echo "Deleting ${OLDEST_LOG}..."
rm -f "${OLDEST_LOG}"
DELETED_FILES=$((DELETED_FILES+1))

# Update current disk usage
CURRENT_USAGE=$(df -P ${TARGET_DIR} | awk 'NR==2 {printf "%d", $5}')
done

if [ "${DELETED_FILES}" -eq "${MAX_DELETE}" ]; then
echo "Reached the maximum number of deletions (${MAX_DELETE}), aborting."
else
echo "Cleaning process completed. Disk usage is now ${CURRENT_USAGE}%."
fi

else
echo "Disk usage is ${CURRENT_USAGE}%, no cleaning needed."
fi

echo "Remaining Files in ${TARGET_DIR} (only show 30 entries):"
ls -lh ${TARGET_DIR} | head -n 30

exit 0
4 changes: 1 addition & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# Makefile for dpvs (DPVS main program).
#

#DEBUG := 1 # enable for debug

TARGET := dpvs

ifneq ("$(wildcard VERSION)","")
Expand Down Expand Up @@ -59,7 +57,7 @@ ifeq ($(shell test $(GCC_VERSION) -ge 70 && echo 1), 1)
CFLAGS += -Wstringop-overflow=0
endif

ifeq ($(DEBUG),)
ifneq ($(CONFIG_DEBUG), y)
CFLAGS += -O3
else
CFLAGS += -g -O0 -D DEBUG
Expand Down
25 changes: 7 additions & 18 deletions src/VERSION
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
#!/bin/sh
# program: dpvs
# Apr 20, 2023
# Jul 13, 2023
#
# Features
# - Dpvs: Multiple instance deployment support.
# - Dpvs: IPC improvements between keepalived/ipvsadm and dpvs by combining data structs.
# - Add new tools: dpvs-agent and healthcheck.
#
# Bugfixes
# - Dpvs: Fix memory problem when setting MATCH service.
# - Ipvsadm: Fix service list problem when dpvs lcore ids are not continuous.
# - Ipvsadm: Fix the problem that service/dest/laddr cannot be listed per-lcore.
# - Ipvsadm: Support version info.
# - Fix several spelling mistakes.
# - Fix compiling errors on RHEL 9, Ubuntu 22.04 and microsoft standard WSL2.
# - Keepalived: Fix service deletion by mistake problem caused by uninitialized local variable.
# - Dpvs: Do not increase service num unless it's hashed sucessfully.
# - Dpvs: Fix sa_entry leak when flushing snat connections.
# - Keepalived: Fix ipvs allow/deny list config problem caused by incorrect parameters.
# - Dpvs: Fix dead lock problem of eal-mem show and rte_free.
# - Dpvs: Fix crash problem caused by msg_destroy when msg->refcnt==0.
# - Dpvs: Fix eal-mem module uninitialized problem.
# - Dpvs: Fix memory leak problem in ipvs allow list.
# - Dpvs: Improve config of adding/removing multicast ether addresses.
# - Dpvs: Fix synproxy config problems.
# - Keepalived: Fix session disturbance problem when vs/rs updated and reloaded.
#

export VERSION=1.9
export RELEASE=4
export RELEASE=5

echo $VERSION-$RELEASE
Loading

0 comments on commit eaa67b9

Please sign in to comment.