Skip to content

RFE-7515: Add support for gathering node resources requests, limits, ovn subnets and resource consumption #488

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

Open
wants to merge 4 commits into
base: master
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
4 changes: 4 additions & 0 deletions collection-scripts/gather
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ pids+=($!)
/usr/bin/gather_osus &
pids+=($!)

# Gather node resource allocation information
/usr/bin/gather_resource_allocation &
pids+=($!)

# Check if PID array has any values, if so, wait for them to finish
if [ ${#pids[@]} -ne 0 ]; then
echo "Waiting on subprocesses to finish execution."
Expand Down
69 changes: 69 additions & 0 deletions collection-scripts/gather_resource_allocation
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

BASE_COLLECTION_PATH="must-gather"
RESOURCE_ALLOCATION_PATH=${BASE_COLLECTION_PATH}/resource_allocation

mkdir -p "${RESOURCE_ALLOCATION_PATH}"/

# Extract all the resource limits, alocations and node subnets and store it in a json
oc describe nodes | awk '
BEGIN {
printf "{\"items\":["
} {
if ($1 == "Name:") {
name=$2
}
if ($1 == "k8s.ovn.org/node-subnets:") {
$1=""
gsub("\"","\\\"",$0)
ovnsubnet=$0
}
if ($1 ~ "Allocatable:") {
while ($1 != "System") {
if ($1 == "cpu:") {
Alloc_cpu=$2
}
if ($1 == "memory:") {
Alloc_mem=$2
}
if ($1 == "pods:") {
Alloc_pod=$2
}
getline
}
}
if ($1 == "Namespace") {
getline
getline
pods_count=0
while ($1 != "Allocated") {
pods_count++
getline
}
}
if ($1 == "Resource") {
while ($1 != "Events:") {
if ($1 == "cpu") {
req_cpu=$2
preq_cpu=$3
lim_cpu=$4
plim_cpu=$5
}
if ($1 == "memory") {
req_mem=$2
preq_mem=$3
lim_mem=$4
plim_mem=$5
}
getline
}
printf "%s{\"node_name\":\"%s\",\"cpu\":{\"allocatable\":\"%s\",\"request\":\"%s\",\"request_percent\":\"%s\",\"limit\":\"%s\",\"limit_percent\":\"%s\"},\"memory\":{\"allocatable\":\"%s\",\"request\":\"%s\",\"request_percent\":\"%s\",\"limit\":\"%s\",\"limit_percent\":\"%s\"},\"pods\":{\"allocatable\":%s,\"running\":%s},\"node_subnet\":\"%s\"}",comma,name,Alloc_cpu,req_cpu,preq_cpu,lim_cpu,plim_cpu,Alloc_mem,req_mem,preq_mem,lim_mem,plim_mem,Alloc_pod,pods_count,ovnsubnet;comma=","
}
}
END {
printf "]}\n"
}' | jq -c > ${RESOURCE_ALLOCATION_PATH}/node_resources.json

# Extract the output of "oc adm top nodes" in json format
oc adm top nodes | column -J -n "top_nodes" --table-columns "node_name","cpu_cores","cpu_%","mem_bytes","mem_%" | jq -c > ${RESOURCE_ALLOCATION_PATH}/top_nodes.json