Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid removing localhost entry from /etc/hosts file #2452

Merged
merged 1 commit into from
Jan 18, 2019
Merged

Avoid removing localhost entry from /etc/hosts file #2452

merged 1 commit into from
Jan 18, 2019

Conversation

PrabhuSreenivasan
Copy link
Contributor

- What I did
This fix removes the possibility of 'localhost' entry getting removed from /etc/hosts file by hostname-config service.

Without this change, whenever we change the hostname from 'localhost' to any other name on the config_db.json and reload the config, /etc/hosts file will only have the new hostname on it. But there are multiple sonic utilities (eg: swssconfig) which relies on the hard coded 'localhost' name and they tend to stop working.

- How I did it
Added a new check on hostname-config.sh script to avid blindly deleting the line containing the old hostname from /etc/hosts file. Now it will delete the old hostname only if its not localhost or when the hostname is not changing.

- How to verify it

  1. Bring up SONiC on a device with hostname as localhost
  2. Edit /etc/sonic/config_db.json to update the 'hostname' filed under DEVICE_METADATA from "hostname" : "localhost" --> "hostname" : "sonic"
  3. run config reload -y to reflect the hostname change done on config_db.json file.
  4. cat /etc/hosts and check whether both 127.0.0.1 localhost and 127.0.0.1 sonic entry are present on the file.
  5. ping localhost should work fine.

- Description for the changelog
Make hostname-config service more robust in handling SONiC hostname change from localhost to anything else.

- A picture of a cute animal (not mandatory but encouraged)

@lguohan
Copy link
Collaborator

lguohan commented Jan 18, 2019

thank you for this fix!

@lguohan lguohan merged commit f28a670 into sonic-net:master Jan 18, 2019
seiferteric pushed a commit to project-arlo/sonic-buildimage that referenced this pull request Oct 14, 2019
…ic-net#2452)

- What I did
This fix removes the possibility of 'localhost' entry getting removed from /etc/hosts file by hostname-config service.

Without this change, whenever we change the hostname from 'localhost' to any other name on the config_db.json and reload the config, /etc/hosts file will only have the new hostname on it. But there are multiple sonic utilities (eg: swssconfig) which relies on the hard coded 'localhost' name and they tend to stop working.

- How I did it
Added a new check on hostname-config.sh script to avid blindly deleting the line containing the old hostname from /etc/hosts file. Now it will delete the old hostname only if its not localhost or when the hostname is not changing.

- How to verify it

Bring up SONiC on a device with hostname as localhost
Edit /etc/sonic/config_db.json to update the 'hostname' filed under DEVICE_METADATA from "hostname" : "localhost" --> "hostname" : "sonic"
run config reload -y to reflect the hostname change done on config_db.json file.
cat /etc/hosts and check whether both 127.0.0.1 localhost and 127.0.0.1 sonic entry are present on the file.
ping localhost should work fine.
- Description for the changelog
Make hostname-config service more robust in handling SONiC hostname change from localhost to anything else.

Change-Id: I4599bcaade05331d737f3e70f449dd51f7c636bb
seiferteric pushed a commit to project-arlo/sonic-buildimage that referenced this pull request Oct 14, 2019
zhenggen-xu pushed a commit to zhenggen-xu/sonic-buildimage that referenced this pull request Oct 17, 2019
…ic-net#2452)

- What I did
This fix removes the possibility of 'localhost' entry getting removed from /etc/hosts file by hostname-config service.

Without this change, whenever we change the hostname from 'localhost' to any other name on the config_db.json and reload the config, /etc/hosts file will only have the new hostname on it. But there are multiple sonic utilities (eg: swssconfig) which relies on the hard coded 'localhost' name and they tend to stop working.

- How I did it
Added a new check on hostname-config.sh script to avid blindly deleting the line containing the old hostname from /etc/hosts file. Now it will delete the old hostname only if its not localhost or when the hostname is not changing.

- How to verify it

Bring up SONiC on a device with hostname as localhost
Edit /etc/sonic/config_db.json to update the 'hostname' filed under DEVICE_METADATA from "hostname" : "localhost" --> "hostname" : "sonic"
run config reload -y to reflect the hostname change done on config_db.json file.
cat /etc/hosts and check whether both 127.0.0.1 localhost and 127.0.0.1 sonic entry are present on the file.
ping localhost should work fine.
- Description for the changelog
Make hostname-config service more robust in handling SONiC hostname change from localhost to anything else.

RB=1534557
G=lnos-reviewers
R=pchaudhary,pmao,rmolina,samaity,sfardeen,zxu
A=
yxieca pushed a commit that referenced this pull request Oct 29, 2019
- What I did
This fix removes the possibility of 'localhost' entry getting removed from /etc/hosts file by hostname-config service.

Without this change, whenever we change the hostname from 'localhost' to any other name on the config_db.json and reload the config, /etc/hosts file will only have the new hostname on it. But there are multiple sonic utilities (eg: swssconfig) which relies on the hard coded 'localhost' name and they tend to stop working.

- How I did it
Added a new check on hostname-config.sh script to avid blindly deleting the line containing the old hostname from /etc/hosts file. Now it will delete the old hostname only if its not localhost or when the hostname is not changing.

- How to verify it

Bring up SONiC on a device with hostname as localhost
Edit /etc/sonic/config_db.json to update the 'hostname' filed under DEVICE_METADATA from "hostname" : "localhost" --> "hostname" : "sonic"
run config reload -y to reflect the hostname change done on config_db.json file.
cat /etc/hosts and check whether both 127.0.0.1 localhost and 127.0.0.1 sonic entry are present on the file.
ping localhost should work fine.
- Description for the changelog
Make hostname-config service more robust in handling SONiC hostname change from localhost to anything else.
stephenxs added a commit to stephenxs/sonic-buildimage that referenced this pull request Nov 8, 2022
d5a6da31 Do not configure physical attributes on port channels in portconfig (sonic-net#2456)
48ee7722 Change db_migrator major version on master branch from version 3 to 4 (sonic-net#2470)
f3746163 [GCU] Fix JsonPointerFilter bug (sonic-net#2477)
58dbb3e6 YANG Validation for ConfigDB Updates: TACPLUS, TACPLUS_SERVER, AAA, VLAN_SUB_INTERFACE tables + decorated validated_mod_entry (sonic-net#2452)
062f18a0 fix show interface neighbor expected empty issue (sonic-net#2465)
569edf3b Fix display disorder problem of show mirror_session (sonic-net#2447)
daaf0ffc Disable "tag as local" when reboot (sonic-net#2451)
6621120b Fix sudo sfputil show error-status on a multiasic platform issue (sonic-net#2373)
e8b1dcdf Add IP remove warnings for VRF commands (sonic-net#2351)
40cc8e11 [scripts/generate_dump] add information to tech-support file (sonic-net#2357)
8473517e Revert "[config reload]: On dual ToR systems, cache ARP and FDB table (sonic-net#2460)

Signed-off-by: Stephen Sun <stephens@nvidia.com>
yxieca pushed a commit that referenced this pull request Nov 11, 2022
#12639)

* Advance submodule sonic-utilities

d5a6da31 Do not configure physical attributes on port channels in portconfig (#2456)
48ee7722 Change db_migrator major version on master branch from version 3 to 4 (#2470)
f3746163 [GCU] Fix JsonPointerFilter bug (#2477)
58dbb3e6 YANG Validation for ConfigDB Updates: TACPLUS, TACPLUS_SERVER, AAA, VLAN_SUB_INTERFACE tables + decorated validated_mod_entry (#2452)
062f18a0 fix show interface neighbor expected empty issue (#2465)
569edf3b Fix display disorder problem of show mirror_session (#2447)
daaf0ffc Disable "tag as local" when reboot (#2451)
6621120b Fix sudo sfputil show error-status on a multiasic platform issue (#2373)
e8b1dcdf Add IP remove warnings for VRF commands (#2351)
40cc8e11 [scripts/generate_dump] add information to tech-support file (#2357)
8473517e Revert "[config reload]: On dual ToR systems, cache ARP and FDB table (#2460)

Signed-off-by: Stephen Sun <stephens@nvidia.com>

* Advance sonic-platform-common

aa86083 Fix issue: rounding float value for txpower and rxpower (#320)
2052a63 Fix issue: copper cable should not display DOM information (#318)
cf4c6af CmisApi::get_application_advertisement catch AttributeError as well (#316)

Signed-off-by: Stephen Sun <stephens@nvidia.com>

Signed-off-by: Stephen Sun <stephens@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants