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

Configure dhcp_relay container hostname from config DB #2820

Closed
wants to merge 2 commits into from
Closed

Configure dhcp_relay container hostname from config DB #2820

wants to merge 2 commits into from

Conversation

pyadvichuk
Copy link

- What I did
Implemented as a result of discussion in #2806.

  • Configure dhcp_relay docker hostname with the value received from the config DB in order to fix dhcp_relay CT which failed because the "sonic" hostname was always received.
  • fixed sed introduced in #2773 as inline operation can't be applied to /etc/hosts inside docker container
admin@bfn-switch-l1:~$ docker exec -it dhcp_relay bash
root@sonic-switch-l1:/# cat /etc/hosts
127.0.0.1       localhost
127.0.0.1 sonic-switch-l1
root@sonic-switch-l1:/# sed -i '/\ssonic-switch-l1$/d' /etc/hosts
sed: cannot rename /etc/sedJugNFO: Device or resource busy

- How I did it
Configure dhcp_relay docker hostname in the same way as this is done in hostname-config.sh

- How to verify it
1) Run dhcp_relay CT and verify it will pass
2)
2.1) manually change 'hostname' in config_db.json
2.2) run sudo config reload -y
2.3) check hostname inside dhcp_relay container

- Description for the changelog
Set proper hostname for dhcp_relay container on startup

@qiluo-msft please review and merge this.

tempfile=`mktemp -q -t hosts.XXXX`
sed "/\s$CURRENT_HOSTNAME$/d" /etc/hosts > $tempfile
echo "127.0.0.1 $HOSTNAME" >> $tempfile
cat $tempfile > /etc/hosts && rm $tempfile
Copy link
Collaborator

@qiluo-msft qiluo-msft Apr 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& [](start = 31, length = 2)

Better use ; #Closed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@qiluo-msft qiluo-msft requested a review from lguohan April 24, 2019 17:55
Copy link
Contributor

@jleveque jleveque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is truly an issue, we should find a global way to set the hostname in all Docker containers. I'm not a fan of treating certain containers differently regarding their hostname.

@pyadvichuk pyadvichuk closed this May 2, 2019
@pyadvichuk pyadvichuk deleted the pyadvychuk/set-dhcp-relay-hostname branch June 19, 2019 12:19
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.

3 participants