Skip to content

Commit

Permalink
Gather all populator PVCs
Browse files Browse the repository at this point in the history
Gather the PVCs from populator flow, including the prime PVC if exists.

Signed-off-by: Liran Rotenberg <[email protected]>
  • Loading branch information
liranr23 committed Oct 26, 2023
1 parent 1f8c57b commit 5a8e6ea
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions collection-scripts/targeted_crs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,25 @@ if [ ! -z "${vm_resources}" ]; then

# Gather VMs PersistentVolumeClaims
for pvc_name in $(echo $vm_data | jq -r '.spec.template.spec.volumes[] .persistentVolumeClaim.claimName'); do
# In order to gather the scratch PVCs in warm migrations
for pvc in $(/usr/bin/oc get pvc -n ${target_ns} -o json | jq -c '.items | .[]'); do
if [ $(echo $pvc | jq -r '.spec.volumeName') != $pvc_name ]; then
pvcs=$(/usr/bin/oc get pvc -n ${target_ns} -o json | jq -c '.items | .[] | {name: .metadata.name, volumeName: .spec.volumeName}')
pop_volume_name=""
for pvc_info in ${pvcs[@]}; do
# When a disk is populated using a volume populator, the PVC's spec.volumeName is different from
# pvc_name and we'll have another PVC (prime PVC) that has the same value of spec.volumeName
if [ $(echo "$pvc_info" | jq -r '.name') = "$pvc_name" ]; then
pop_volume_name=$(echo $pvc | jq -r '.volumeName')
fi
done
for pvc_info in ${pvcs[@]}; do
volume_name=$(echo $pvc_info | jq -r '.volumeName')
# In order to gather the scratch PVCs in warm migrations $volume_name == $pvc_name
# As for populator PVCs we check $volume_name == $pop_volume_name
if [ "$volume_name" != "$pvc_name" ] && [ "$volume_name" != "$pop_volume_name" ]; then
continue
fi
name=$(echo $pvc | jq -r 'metadata.name')
log_filter_query="$log_filter_query|name"
dump_resource "persistentvolumeclaim" name $target_ns
name=$(echo $pvc_info | jq -r '.name')
log_filter_query="$log_filter_query|$name"
dump_resource "persistentvolumeclaim" $name $target_ns

# Store PVC in list to allow populator pod logs gathering
echo "${target_ns},${name}" >> /tmp/pvcs
Expand Down

0 comments on commit 5a8e6ea

Please sign in to comment.