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 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3fa696d..4187554 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -689,12 +689,33 @@ kdump_check_iscsi_targets () { } }
+# hostname -a is deprecated, do it by ourselves +get_alias() { + local ips + local entry + local _alias + local alias_set + + ips=$(hostname -I) + for ip in $ips + do + entry=$(grep $ip /etc/hosts) + if [ $? -eq 0 ]; then + _alias=$(echo $entry | awk '{ print $3 }') + alias_set="$alias_set $_alias" + 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
On Mon, Aug 26, 2019 at 1:56 PM Pingfan Liu piliu@redhat.com wrote:
'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 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3fa696d..4187554 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -689,12 +689,33 @@ kdump_check_iscsi_targets () { } }
+# hostname -a is deprecated, do it by ourselves +get_alias() {
- local ips
- local entry
- local _alias
- local alias_set
- ips=$(hostname -I)
- for ip in $ips
- do
entry=$(grep $ip /etc/hosts)
if [ $? -eq 0 ]; then
_alias=$(echo $entry | awk '{ print $3 }')
If there are multiple alias, this will only catch the first one? eg. in my /etc/hosts there is: 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
and: # echo 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 | awk '{ print $3 }' localhost.localdomain
alias_set="$alias_set $_alias"
fi
- done
- echo $alias_set
+}
is_localhost() { local hostnames=$(hostname -A) local shortnames=$(hostname -A -s)
- local aliasname=$(get_alias )
A redundant space?
local nodename=$1
- hostnames="$hostnames $shortnames"
hostnames="$hostnames $shortnames $aliasname"
for name in ${hostnames}; do if [ "$name" == "$nodename" ]; then
-- 2.7.5
On 08/26/2019 03:40 PM, Kairui Song wrote:
On Mon, Aug 26, 2019 at 1:56 PM Pingfan Liu piliu@redhat.com wrote:
'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 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 3fa696d..4187554 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -689,12 +689,33 @@ kdump_check_iscsi_targets () { } }
+# hostname -a is deprecated, do it by ourselves +get_alias() {
- local ips
- local entry
- local _alias
- local alias_set
- ips=$(hostname -I)
- for ip in $ips
- do
entry=$(grep $ip /etc/hosts)
if [ $? -eq 0 ]; then
_alias=$(echo $entry | awk '{ print $3 }')
If there are multiple alias, this will only catch the first one? eg. in my /etc/hosts there is: 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
and: # echo 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 | awk '{ print $3 }' localhost.localdomain
You are right, I will fix it in V2.
alias_set="$alias_set $_alias"
fi
- done
- echo $alias_set
+}
is_localhost() { local hostnames=$(hostname -A) local shortnames=$(hostname -A -s)
- local aliasname=$(get_alias )
A redundant space?
OK, I can strip it in V2.
Thanks, Pingfan
local nodename=$1
- hostnames="$hostnames $shortnames"
hostnames="$hostnames $shortnames $aliasname"
for name in ${hostnames}; do if [ "$name" == "$nodename" ]; then
-- 2.7.5
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 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4187554..b6f5d26 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -756,6 +756,22 @@ 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 + nodes=$filtered + echo "$nodes" +} + # setup fence_kdump in cluster # setup proper network and install needed files kdump_configure_fence_kdump () { @@ -764,7 +780,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)
On Mon, Aug 26, 2019 at 1:56 PM Pingfan Liu piliu@redhat.com wrote:
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 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4187554..b6f5d26 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -756,6 +756,22 @@ 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
- nodes=$filtered
- echo "$nodes"
Just echo "$filtered" may be better.
+}
# setup fence_kdump in cluster # setup proper network and install needed files kdump_configure_fence_kdump () { @@ -764,7 +780,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)
-- 2.7.5