Skip to content

Commit

Permalink
Add warm migration resources
Browse files Browse the repository at this point in the history
When importing using CDI in warm migrations we may have multiple PVCs
(scratch) and multiple importer pods to the migration.
This patch adds the logs of these relevant resources.

Signed-off-by: Liran Rotenberg <[email protected]>
  • Loading branch information
liranr23 committed Sep 27, 2023
1 parent 571f19e commit 9db90b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
17 changes: 12 additions & 5 deletions collection-scripts/targeted_crs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,18 @@ if [ ! -z "${vm_resources}" ]; then

# Gather VMs PersistentVolumeClaims
for pvc_name in $(echo $vm_data | jq -r '.spec.template.spec.volumes[] .persistentVolumeClaim.claimName'); do
log_filter_query="$log_filter_query|$pvc_name"
dump_resource "persistentvolumeclaim" $pvc_name $target_ns

# Store PVC in list to allow populator pod logs gathering
echo "${target_ns},${pvc_name}" >> /tmp/pvcs
# 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
continue
fi
name=$(echo $pvc | jq -r 'metadata.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
done
done

target_vm_id=($(echo $vm_data | jq -r '.metadata.labels.vmID'))
Expand Down
16 changes: 9 additions & 7 deletions collection-scripts/targeted_logs
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,17 @@ for nspvc in ${target_pvcs[@]}; do
continue
fi

pod=$(oc get pods --no-headers -n $ns --selector cdi.kubevirt.io=importer -o go-template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | grep $pvc | head -1)
if [[ -z $pod ]]; then
pods=$(oc get pods --no-headers -n $ns --selector cdi.kubevirt.io=importer -o go-template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | grep $pvc)
if [[ -z $pods ]]; then
echo "Importer Pod for $nspvc doesn't exist, skipping."
else
object_collection_path="/must-gather/namespaces/${ns}/logs/${pod}"
mkdir -p ${object_collection_path}
echo "[ns=${ns}][pod=${pod}] Collecting CDI Importer Pod logs..."
/usr/bin/oc logs --all-containers --namespace ${ns} ${pod} &> "${object_collection_path}/current.log" &
pwait $max_parallelism
for pod in ${pods[@]}; do
object_collection_path="/must-gather/namespaces/${ns}/logs/${pod}"
mkdir -p ${object_collection_path}
echo "[ns=${ns}][pod=${pod}] Collecting CDI Importer Pod logs..."
/usr/bin/oc logs --all-containers --namespace ${ns} ${pod} &> "${object_collection_path}/current.log" &
pwait $max_parallelism
done
fi
done

Expand Down

0 comments on commit 9db90b1

Please sign in to comment.