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

The hostname-config.sh script rewrites the hostname and appends #20394

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gord1306
Copy link

@gord1306 gord1306 commented Oct 1, 2024

Why I did it

The hostname-config.sh script rewrites the hostname and appends the 127.0.0.1 new hostname mapping to the /etc/hosts list. However, it does not handle the case where the file does not exist, resulting in the hostname not being updated in /etc/hosts.

When /etc/hosts is missing, it causes the sudo command to be blocked for a while and displays an "unable to resolve host" error message.

Work item tracking
  • Microsoft ADO (number only):

How I did it

This patch adds a workaround in hostname-config.sh to create a default /etc/hosts if it does not exist, ensuring the hostname is updated properly.

How to verify it

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

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

the 127.0.0.1 new hostname mapping to the /etc/hosts list. However,
it does not handle the case where the file does not exist, resulting
in the hostname not being updated in /etc/hosts.

When /etc/hosts is missing, it causes the sudo command to be blocked
for a while and displays an "unable to resolve host" error message.

This patch adds a workaround in hostname-config.sh to create a
default /etc/hosts if it does not exist, ensuring the hostname is
updated properly.

Signed-off-by: gord_chen <[email protected]>
@gord1306 gord1306 requested a review from lguohan as a code owner October 1, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant