Skip to content

Commit

Permalink
NO-JIRA: Running gather scripts in background (#399)
Browse files Browse the repository at this point in the history
* Running gather scripts in background

Signed-off-by: oviner <oviner@redhat.com>

* fix code

Signed-off-by: oviner <oviner@redhat.com>

---------

Signed-off-by: oviner <oviner@redhat.com>
  • Loading branch information
OdedViner committed Jan 2, 2024
1 parent be633ca commit 4c685e0
Showing 1 changed file with 49 additions and 20 deletions.
69 changes: 49 additions & 20 deletions collection-scripts/gather
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
echo "openshift/must-gather"> /must-gather/version
version >> /must-gather/version

# Store PIDs of all the subprocesses
pids=()

# Named resource list, eg. ns/openshift-config
named_resources=()

Expand Down Expand Up @@ -48,7 +51,8 @@ all_ns_resources+=(leases)

# Run the Collection of Resources using inspect
# running across all-namespaces for the few "Autoscaler" resources.
oc adm inspect --dest-dir must-gather --rotated-pod-logs "${named_resources[@]}"
oc adm inspect --dest-dir must-gather --rotated-pod-logs "${named_resources[@]}" &
pids+=($!)

filtered_group_resources=()
for gr in "${group_resources[@]}"
Expand All @@ -59,60 +63,85 @@ do
fi
done
group_resources_text=$(IFS=, ; echo "${filtered_group_resources[*]}")
oc adm inspect --dest-dir must-gather --rotated-pod-logs "${group_resources_text}"
oc adm inspect --dest-dir must-gather --rotated-pod-logs "${group_resources_text}" &
pids+=($!)

oc adm inspect --dest-dir must-gather --rotated-pod-logs "${all_ns_resources[@]}" --all-namespaces
oc adm inspect --dest-dir must-gather --rotated-pod-logs "${all_ns_resources[@]}" --all-namespaces &
pids+=($!)

# Gather Insights Operator Archives
/usr/bin/gather_insights
/usr/bin/gather_insights &
pids+=($!)

# Gather monitoring data from the cluster
/usr/bin/gather_monitoring
/usr/bin/gather_monitoring &
pids+=($!)

# Gather optional operator resources from all namespaces
/usr/bin/gather_olm
/usr/bin/gather_olm &
pids+=($!)

# Gather API Priority and Fairness Endpoints
/usr/bin/gather_priority_and_fairness
/usr/bin/gather_priority_and_fairness &
pids+=($!)

# Gather etcd information
/usr/bin/gather_etcd
/usr/bin/gather_etcd &
pids+=($!)

# Gather Service Logs (using a supplemental Script); Scoped to Masters.
/usr/bin/gather_service_logs master
/usr/bin/gather_service_logs master &
pids+=($!)

# Gather Windows Kubernetes component logs
/usr/bin/gather_windows_node_logs
/usr/bin/gather_windows_node_logs &
pids+=($!)

# Gather HAProxy config files
/usr/bin/gather_haproxy_config
/usr/bin/gather_haproxy_config &
pids+=($!)

# Gather kas startup and termination logs
/usr/bin/gather_kas_startup_termination_logs
/usr/bin/gather_kas_startup_termination_logs &
pids+=($!)

# Gather network logs
/usr/bin/gather_network_logs_basics
/usr/bin/gather_network_logs_basics &
pids+=($!)

# Gather metallb logs
/usr/bin/gather_metallb
/usr/bin/gather_metallb &
pids+=($!)

# Gather NMState
/usr/bin/gather_nmstate
/usr/bin/gather_nmstate &
pids+=($!)

# Gather SR-IOV resources
/usr/bin/gather_sriov
/usr/bin/gather_sriov &
pids+=($!)

# Gather PodNetworkConnectivityCheck
/usr/bin/gather_podnetworkconnectivitycheck
/usr/bin/gather_podnetworkconnectivitycheck &
pids+=($!)

# Gather On-Disk MachineConfig files
/usr/bin/gather_machineconfig_ondisk
/usr/bin/gather_machineconfig_ondisk &
pids+=($!)

# Gather vSphere resources. This is NOOP on non-vSphere platform.
/usr/bin/gather_vsphere
/usr/bin/gather_vsphere &
pids+=($!)

# Gather Performance profile information
/usr/bin/gather_ppc
/usr/bin/gather_ppc &
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."
wait "${pids[@]}"
fi

# force disk flush to ensure that all data gathered is accessible in the copy container
sync

0 comments on commit 4c685e0

Please sign in to comment.