Skip to content

Commit

Permalink
Use ctlplane ip from status.allIPs if ansibleHost isn't available
Browse files Browse the repository at this point in the history
This patch is a followup of
#49
since we can't access to hostname from must-gather container because it
doesn't have access to OSP controlplane DNS server.

Signed-off-by: Roberto Alfieri <ralfieri@redhat.com>
  • Loading branch information
rebtoor committed May 9, 2024
1 parent 08b35ee commit 65417e2
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions collection-scripts/gather_edpm_sos
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
# SOS_EDPM_PROFILES: list of sos report profiles to use. Empty string to run
# them all. Defaults to: system,storage,virt
#
# TODO: Confirm this can actually ssh into the EDPM nodes besides in the CRC
# case. Worst case we may have to define a Job/Pod with the right
# networks to do the work.
# TODO: Add openstack_edpm to the list once this PR merges and is released
# https://github.com/openstack-k8s-operators/openstack-must-gather/pull/18
set -eo pipefail

# When called from the shell directly
if [[ -z "$DIR_NAME" ]]; then
Expand All @@ -25,24 +21,24 @@ SOS_PATH="${BASE_COLLECTION_PATH}/sos-reports"
SOS_PATH_NODES="${BASE_COLLECTION_PATH}/sos-reports/_all_nodes"
TMPDIR=/var/tmp/sos-osp

if [[ -z "$SOS_EDPM" ]]; then
if [[ -z "${SOS_EDPM}" ]]; then
echo "Skipping SOS gathering for EDPM nodes"
[[ $CALLED -eq 1 ]] && exit 0
[[ ${CALLED} -eq 1 ]] && exit 0
return

else
IFS=',' read -r -a SOS_EDPM <<< "$SOS_EDPM"
fi

# Default to some profiles if SOS_EDPM_PROFILES is not set
SOS_EDPM_PROFILES="${SOS_EDPM_PROFILES-system,storage,virt}"
if [[ -n "$SOS_EDPM_PROFILES" ]]; then
SOS_LIMIT="-p $SOS_EDPM_PROFILES"
SOS_EDPM_PROFILES="${SOS_EDPM_PROFILES-system,storage,virt,openstack_edpm}"
if [[ -n "${SOS_EDPM_PROFILES}" ]]; then
SOS_LIMIT="-p ${SOS_EDPM_PROFILES}"
fi

# Add plugins if SOS_EDPM_PLUGINS is nonzero
if [[ -n "$SOS_EDPM_PLUGINS" ]]; then
SOS_LIMIT="$SOS_LIMIT -o $SOS_EDPM_PLUGINS"
if [[ -n "${SOS_EDPM_PLUGINS}" ]]; then
SOS_LIMIT="${SOS_LIMIT} -o ${SOS_EDPM_PLUGINS}"
fi

SSH () {
Expand Down Expand Up @@ -91,7 +87,7 @@ gather_edpm_sos () {
chmod +w -R "${SOS_PATH_NODES}/sosreport-$node/"

# Delete the tar.xz file from the remote node
SSH sudo "rm -rf \"$TMPDIR\""
SSH sudo "rm -rf \"${TMPDIR}\""

# Link the sos report in the nova directory
mkdir -p ${SOS_PATH}/nova
Expand All @@ -100,7 +96,7 @@ gather_edpm_sos () {
}


data=$(oc get openstackdataplanenodesets --all-namespaces -o go-template='{{range $indexns,$nodeset := .items}}{{range $index,$node := $nodeset.spec.nodes}}{{printf "%s " $node.hostName}}{{if $node.ansible.ansibleHost}}{{printf "%s " $node.ansible.ansibleHost}}{{else}}{{printf "%s " $node.hostName}}{{end}}{{printf "%s %s %s\n" $nodeset.spec.nodeTemplate.ansible.ansibleUser $nodeset.spec.nodeTemplate.ansibleSSHPrivateKeySecret $nodeset.metadata.namespace}}{{end}}{{end}}')
data=$(oc get openstackdataplanenodesets --all-namespaces -o go-template='{{range $indexns,$nodeset := .items}}{{range $index,$node := $nodeset.spec.nodes}}{{printf "%s " $node.hostName}}{{if $node.ansible.ansibleHost}}{{printf "%s " $node.ansible.ansibleHost}}{{else}}{{range $idxnet,$net := $nodeset.status.allIPs}}{{if eq $idxnet $node.hostName}}{{printf "%s " $net.ctlplane}}{{end}}{{end}}{{end}}{{printf "%s %s %s\n" $nodeset.spec.nodeTemplate.ansible.ansibleUser $nodeset.spec.nodeTemplate.ansibleSSHPrivateKeySecret $nodeset.metadata.namespace}}{{end}}{{end}}')

while read -r node address username secret namespace; do
[[ -z "$node" ]] && continue
Expand Down

0 comments on commit 65417e2

Please sign in to comment.