commit 88bbab963f11a71aae2f7cff224ce0f5038111a8 dracut-module-setup.sh: skip alias of localhost in get_pcs_fence_kdump_nodes() is not enough to handle host alias
-1. "host -A" does not provide alias name. -2. 'generic fence kdump' can also be protected by the same logic
Pingfan Liu (2): dracut-module-setup: get localhost alias by manual dracut-module-setup: filter out localhost for generic_fence_kdump
dracut-module-setup.sh | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
'hostname -A' can not get the alias, meanwhile 'hostname -a' is deprecated. So we should do it by ourselves.
The parsing is based on the format of /etc/hosts, i.e. IP_address canonical_hostname [aliases...]
Signed-off-by: Pingfan Liu piliu@redhat.com --- dracut-module-setup.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3fa696d..6745cff 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -689,12 +689,31 @@ kdump_check_iscsi_targets () { } }
+# hostname -a is deprecated, do it by ourself +get_alias() { + local ips + local entry + local alias_set + + ips=$(hostname -I) + for ip in $ips + do + entries=$(grep $ip /etc/hosts | awk '{ $1=$2=""; print $0 }') + if [ $? -eq 0 ]; then + alias_set="$alias_set $entries" + fi + done + + echo $alias_set +} + is_localhost() { local hostnames=$(hostname -A) local shortnames=$(hostname -A -s) + local aliasname=$(get_alias) local nodename=$1
- hostnames="$hostnames $shortnames" + hostnames="$hostnames $shortnames $aliasname"
for name in ${hostnames}; do if [ "$name" == "$nodename" ]; then
The localhost is filtered out in case of is_pcs_fence_kdump, do it too in case of is_generic_fence_kdump.
Signed-off-by: Pingfan Liu piliu@redhat.com --- dracut-module-setup.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 6745cff..70f3ab1 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -754,6 +754,21 @@ get_pcs_fence_kdump_args() { fi }
+get_generic_fence_kdump_nodes() { + local filtered + local nodes + + nodes=$(get_option_value "fence_kdump_nodes") + for node in ${nodes}; do + # Skip its own node name + if is_localhost $node; then + continue + fi + filtered="$filtered $node" + done + echo $filtered +} + # setup fence_kdump in cluster # setup proper network and install needed files kdump_configure_fence_kdump () { @@ -762,7 +777,7 @@ kdump_configure_fence_kdump () { local args
if is_generic_fence_kdump; then - nodes=$(get_option_value "fence_kdump_nodes") + nodes=$(get_generic_fence_kdump_nodes)
elif is_pcs_fence_kdump; then nodes=$(get_pcs_fence_kdump_nodes)