This is an automated email from the ASF dual-hosted git repository.
ddanielr pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push:
new da8f475d5b address accumulo-service issues (#5750)
da8f475d5b is described below
commit da8f475d5b68f064f33e0b8c7d5b019e5ff38fab
Author: Daniel Roberts <[email protected]>
AuthorDate: Wed Jul 30 11:49:19 2025 -0400
address accumulo-service issues (#5750)
* Switches from netstat to ss for port ids
* Address feedback from #5502
Reverts all_flag logic change.
Switches to using bash's regex vs `expr`.
Removed unnecessary curly braces.
Added comment for reading pid file contents.
Cleaned up port var assignment piping logic.
Addressed issue with IF statement. Removed the comment about more than
one port as metric exporters will most likely have a port open along
with the thrift port. So multiple ports are an expected and valid state.
restrict regex
grep on word boundary
Throw an exit code of `1` after the loop if the port check fails.
---------
Co-authored-by: Christopher Tubbs <[email protected]>
---
assemble/bin/accumulo-service | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/assemble/bin/accumulo-service b/assemble/bin/accumulo-service
index e21e977286..c04424819c 100755
--- a/assemble/bin/accumulo-service
+++ b/assemble/bin/accumulo-service
@@ -152,7 +152,8 @@ function find_processes() {
local expected_pid
local found_pid
for filepath in "$ACCUMULO_PID_DIR"/*; do
- if file=$(expr "$filepath" :
'^.*/accumulo-\('"$service_type"'.*\)[.]pid$'); then
+ if [[ $filepath =~ ^.*/accumulo-("$service_type".*)[.]pid$ ]]; then
+ file="${BASH_REMATCH[1]}"
expected_pid=$(<"$filepath")
found_pid=$(pgrep -F "$filepath" -f "$file")
if [[ $found_pid != "$expected_pid" ]]; then
@@ -169,7 +170,7 @@ function stop_service() {
local service_type=$1
local service_name=$2
local all_flag=$3
- if $all_flag; then
+ if [[ $all_flag == 'true' ]]; then
find_processes "$service_type"
for process in "${RUNNING_PROCESSES[@]}"; do
local pid_file="${ACCUMULO_PID_DIR}/accumulo-${process}.pid"
@@ -198,7 +199,7 @@ function kill_service() {
local service_type=$1
local service_name=$2
local all_flag=$3
- if $all_flag; then
+ if [[ $all_flag == 'true' ]]; then
find_processes "$service_type"
for process in "${RUNNING_PROCESSES[@]}"; do
local pid_file="${ACCUMULO_PID_DIR}/accumulo-${process}.pid"
@@ -230,16 +231,19 @@ function list_processes() {
local pid_file
local pid
local port
- pid_file="${ACCUMULO_PID_DIR}/accumulo-${process}.pid"
- pid=$(<"$pid_file")
- port=$(netstat -tnlp 2>/dev/null | grep "$pid" | awk '{print $4}' | awk -F
':' '{print $NF}' | paste -sd "," -)
- # check that only a single port was seen
- if (($(echo "$port" | grep -c -E '^[0-9]+(,[0-9]+)*$') != 1)); then
- echo "ERROR unexpected ports $(hostname) process:$process pid:$pid
ports:$port" >&2
- else
+ local loop_err
+ pid_file="$ACCUMULO_PID_DIR/accumulo-$process.pid"
+ pid=$(<"$pid_file") # read the contents of the file into the $pid variable
+ port=$(ss -tnlp 2>/dev/null | grep -wF "pid=$pid" | awk '{print $4}' | awk
-F : '{print $NF}' | paste -sd,)
+
+ if [[ $port =~ ^[1-9][0-9]{1,4}(,[1-9][0-9]{1,4})*$ ]]; then
echo "$process $pid $port"
+ else
+ echo "ERROR unexpected port format $(hostname) process:$process pid:$pid
ports:$port" >&2
+ loop_err=1
fi
done
+ [[ -z $loop_err ]] # return non-zero if any errors occurred during the loop
}
function main() {