Fix get_logs() to get logs from all nodes
This command will show the same hostname cfg01
for all minions because "$(hostname -f)" is interpolated
on the cfg01 *before* the command is executed on minions:
salt '*' cmd.run "echo $(hostname -f)"
This lead to overwrite the artifacts with the same name from
all nodes.
- add escapes before '$' to disable early interpolation
- fix FORWARD command in cookied-mcp-pike-dvr/openstack.yaml
Closes-Bug: PROD-18695
Change-Id: Iad4d92a1736abacbff2a39da6b8f27e2dc70758f
diff --git a/tcp_tests/managers/underlay_ssh_manager.py b/tcp_tests/managers/underlay_ssh_manager.py
index 54984ae..55ccbbe 100644
--- a/tcp_tests/managers/underlay_ssh_manager.py
+++ b/tcp_tests/managers/underlay_ssh_manager.py
@@ -414,64 +414,68 @@
def get_logs(self, artifact_name,
node_role=ext.UNDERLAY_NODE_ROLES.salt_master):
+
+ # Prefix each '$' symbol with backslash '\' to disable
+ # early interpolation of environment variables on cfg01 node only
dump_commands = (
- "mkdir /root/$(hostname -f)/;"
- "rsync -aruv /var/log/ /root/$(hostname -f)/;"
- "dpkg -l > /root/$(hostname -f)/dump_dpkg_l.txt;"
- "df -h > /root/$(hostname -f)/dump_df.txt;"
- "mount > /root/$(hostname -f)/dump_mount.txt;"
- "blkid -o list > /root/$(hostname -f)/dump_blkid_o_list.txt;"
- "iptables -t nat -S > /root/$(hostname -f)/dump_iptables_nat.txt;"
- "iptables -S > /root/$(hostname -f)/dump_iptables.txt;"
- "ps auxwwf > /root/$(hostname -f)/dump_ps.txt;"
- "docker images > /root/$(hostname -f)/dump_docker_images.txt;"
- "docker ps > /root/$(hostname -f)/dump_docker_ps.txt;"
+ "mkdir /root/\$(hostname -f)/;"
+ "rsync -aruv /var/log/ /root/\$(hostname -f)/;"
+ "dpkg -l > /root/\$(hostname -f)/dump_dpkg_l.txt;"
+ "df -h > /root/\$(hostname -f)/dump_df.txt;"
+ "mount > /root/\$(hostname -f)/dump_mount.txt;"
+ "blkid -o list > /root/\$(hostname -f)/dump_blkid_o_list.txt;"
+ "iptables -t nat -S > /root/\$(hostname -f)/dump_iptables_nat.txt;"
+ "iptables -S > /root/\$(hostname -f)/dump_iptables.txt;"
+ "ps auxwwf > /root/\$(hostname -f)/dump_ps.txt;"
+ "docker images > /root/\$(hostname -f)/dump_docker_images.txt;"
+ "docker ps > /root/\$(hostname -f)/dump_docker_ps.txt;"
"docker service ls > "
- " /root/$(hostname -f)/dump_docker_services_ls.txt;"
- "for SERVICE in $(docker service ls | awk '{ print $2 }'); "
- " do docker service ps --no-trunc 2>&1 $SERVICE >> "
- " /root/$(hostname -f)/dump_docker_service_ps.txt;"
+ " /root/\$(hostname -f)/dump_docker_services_ls.txt;"
+ "for SERVICE in \$(docker service ls | awk '{ print $2 }'); "
+ " do docker service ps --no-trunc 2>&1 \$SERVICE >> "
+ " /root/\$(hostname -f)/dump_docker_service_ps.txt;"
" done;"
- "for SERVICE in $(docker service ls | awk '{ print $2 }'); "
- " do docker service logs 2>&1 $SERVICE > "
- " /root/$(hostname -f)/dump_docker_service_${SERVICE}_logs;"
+ "for SERVICE in \$(docker service ls | awk '{ print $2 }'); "
+ " do docker service logs 2>&1 \$SERVICE > "
+ " /root/\$(hostname -f)/dump_docker_service_\${SERVICE}_logs;"
" done;"
- "vgdisplay > /root/$(hostname -f)/dump_vgdisplay.txt;"
- "lvdisplay > /root/$(hostname -f)/dump_lvdisplay.txt;"
- "ip a > /root/$(hostname -f)/dump_ip_a.txt;"
- "ip r > /root/$(hostname -f)/dump_ip_r.txt;"
- "netstat -anp > /root/$(hostname -f)/dump_netstat.txt;"
- "brctl show > /root/$(hostname -f)/dump_brctl_show.txt;"
- "arp -an > /root/$(hostname -f)/dump_arp.txt;"
- "uname -a > /root/$(hostname -f)/dump_uname_a.txt;"
- "lsmod > /root/$(hostname -f)/dump_lsmod.txt;"
- "cat /proc/interrupts > /root/$(hostname -f)/dump_interrupts.txt;"
- "cat /etc/*-release > /root/$(hostname -f)/dump_release.txt;"
+ "vgdisplay > /root/\$(hostname -f)/dump_vgdisplay.txt;"
+ "lvdisplay > /root/\$(hostname -f)/dump_lvdisplay.txt;"
+ "ip a > /root/\$(hostname -f)/dump_ip_a.txt;"
+ "ip r > /root/\$(hostname -f)/dump_ip_r.txt;"
+ "netstat -anp > /root/\$(hostname -f)/dump_netstat.txt;"
+ "brctl show > /root/\$(hostname -f)/dump_brctl_show.txt;"
+ "arp -an > /root/\$(hostname -f)/dump_arp.txt;"
+ "uname -a > /root/\$(hostname -f)/dump_uname_a.txt;"
+ "lsmod > /root/\$(hostname -f)/dump_lsmod.txt;"
+ "cat /proc/interrupts > /root/\$(hostname -f)/dump_interrupts.txt;"
+ "cat /etc/*-release > /root/\$(hostname -f)/dump_release.txt;"
# OpenStack specific, will fail on other nodes
- # "rabbitmqctl report > /root/$(hostname -f)/dump_rabbitmqctl.txt;"
+ # "rabbitmqctl report > "
+ # " /root/\$(hostname -f)/dump_rabbitmqctl.txt;"
- # "ceph health > /root/$(hostname -f)/dump_ceph_health.txt;"
- # "ceph -s > /root/$(hostname -f)/dump_ceph_s.txt;"
- # "ceph osd tree > /root/$(hostname -f)/dump_ceph_osd_tree.txt;"
+ # "ceph health > /root/\$(hostname -f)/dump_ceph_health.txt;"
+ # "ceph -s > /root/\$(hostname -f)/dump_ceph_s.txt;"
+ # "ceph osd tree > /root/\$(hostname -f)/dump_ceph_osd_tree.txt;"
- # "for ns in $(ip netns list);"
- # " do echo Namespace: ${ns}; ip netns exec ${ns} ip a;"
- # "done > /root/$(hostname -f)/dump_ip_a_ns.txt;"
+ # "for ns in \$(ip netns list);"
+ # " do echo Namespace: \${ns}; ip netns exec \${ns} ip a;"
+ # "done > /root/\$(hostname -f)/dump_ip_a_ns.txt;"
- # "for ns in $(ip netns list);"
- # " do echo Namespace: ${ns}; ip netns exec ${ns} ip r;"
- # "done > /root/$(hostname -f)/dump_ip_r_ns.txt;"
+ # "for ns in \$(ip netns list);"
+ # " do echo Namespace: \${ns}; ip netns exec \${ns} ip r;"
+ # "done > /root/\$(hostname -f)/dump_ip_r_ns.txt;"
- # "for ns in $(ip netns list);"
- # " do echo Namespace: ${ns}; ip netns exec ${ns} netstat -anp;"
- # "done > /root/$(hostname -f)/dump_netstat_ns.txt;"
+ # "for ns in \$(ip netns list);"
+ # " do echo Namespace: \${ns}; ip netns exec \${ns} netstat -anp;"
+ # "done > /root/\$(hostname -f)/dump_netstat_ns.txt;"
"/usr/bin/haproxy-status.sh > "
- " /root/$(hostname -f)/dump_haproxy.txt;"
+ " /root/\$(hostname -f)/dump_haproxy.txt;"
# Archive the files
"cd /root/; tar --absolute-names --warning=no-file-changed "
- " -czf $(hostname -f).tar.gz ./$(hostname -f)/;"
+ " -czf \$(hostname -f).tar.gz ./\$(hostname -f)/;"
)
master_host = self.__config.salt.salt_master_host
diff --git a/tcp_tests/templates/cookied-mcp-pike-dvr/openstack.yaml b/tcp_tests/templates/cookied-mcp-pike-dvr/openstack.yaml
index 61d4a8f..3509982 100644
--- a/tcp_tests/templates/cookied-mcp-pike-dvr/openstack.yaml
+++ b/tcp_tests/templates/cookied-mcp-pike-dvr/openstack.yaml
@@ -376,7 +376,7 @@
skip_fail: false
- description: Enable forward policy
- cmd: salt iptables --policy FORWARD ACCEPT
+ cmd: iptables --policy FORWARD ACCEPT
node_name: {{ HOSTNAME_GTW01 }}
retry: {count: 1, delay: 30}
skip_fail: false