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

[dhcp_relay]: Check whether device requires DHCP relay upon docker start #371

Closed
wants to merge 2 commits into from
Closed

Conversation

jleveque
Copy link
Contributor

@jleveque jleveque commented Mar 3, 2017

If not, log a message and exit docker. Other conditions can be added in the future as needed.

With OneImage, all dockers must be deployed, but DHCP relay may not be needed. It's cleaner to have docker exit than to continue running and serving no purpose. Log message is helpful to understand why.

Signed-off-by: Joe LeVeque jolevequ@microsoft.com

DEVICE_ROLE=`sonic-cfggen -m /etc/sonic/minigraph.xml -v "minigraph_devices['$MINIGRAPH_HOSTNAME']['type']"`

if [ $DEVICE_ROLE != "ToRRouter" ]; then
echo "Device does not require DHCP relay. docker-dhcp-relay exiting..."
Copy link
Contributor

Choose a reason for hiding this comment

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

if the script exits here, will the docker exits?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think if you return a nonzero value, it will.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Taoyu is correct. I have tested the behavior, and exiting with a nonzero value will cause the docker container to exit, whereas exiting with a return value of 0 will cause the container to keep running.

sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/dhcp_relay.yml -t /usr/share/sonic/templates/isc-dhcp-relay.j2 > /etc/default/isc-dhcp-relay
MINIGRAPH_HOSTNAME=`sonic-cfggen -m /etc/sonic/minigraph.xml -v "minigraph_hostname"`
DEVICE_ROLE=`sonic-cfggen -m /etc/sonic/minigraph.xml -v "minigraph_devices['$MINIGRAPH_HOSTNAME']['type']"`

Copy link
Contributor

Choose a reason for hiding this comment

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

you can directly use -v "minigraph_devices[minigraph_hostname]['type']", don't need to call it twice.

Copy link
Contributor Author

@jleveque jleveque Mar 6, 2017

Choose a reason for hiding this comment

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

Good to know. Simplified in 0fdd3c8. Thanks!

@lguohan
Copy link
Collaborator

lguohan commented Mar 7, 2017

should we do this in dhcprelay service unit file? if we detect it is not tor, we do not even start the container.

@jleveque
Copy link
Contributor Author

jleveque commented Mar 9, 2017

It would be cleaner to have this logic outside the container, but systemd provides a limited set of conditionals to work with in the unit files, none of which I'm aware of allow us to directly check the device type from the minigraph. Do you have an idea in mind?

@taoyl-ms
Copy link
Contributor

taoyl-ms commented Mar 17, 2017

How about doing it in /usr/bin/dhcp_relay.sh instead of in the service definition file? You can check minigraph there and if the switch is not ToR you just do nothing and tell systemd you succeeded to start the service.

@jleveque
Copy link
Contributor Author

Thanks for the idea, but after speaking with Guohan and Shuotian, we decided the service shouldn't even be started if not needed. This also applies to teamd, and may apply to other services in the future. I will soon submit another solution that disables the services on first boot.

@taoyl-ms
Copy link
Contributor

If you are going to disable the service on first boot, please make sure your disabling happens after update_graph service so we don't mistakenly disable it based on a default graph.

@jleveque
Copy link
Contributor Author

Thanks for the heads-up! :)

@stcheng stcheng force-pushed the master branch 2 times, most recently from b9ca7e2 to 42ae02b Compare March 22, 2017 20:29
@jleveque
Copy link
Contributor Author

Abandoning in favor of #427

@jleveque jleveque closed this Mar 23, 2017
@jleveque jleveque deleted the dhcp_relay branch March 30, 2017 01:28
lguohan added a commit to lguohan/sonic-buildimage that referenced this pull request Nov 12, 2018
sairedis

* 248a095 2018-11-07 | Add best candidate search for acl table (sonic-net#371) [Kamil Cudnik]
* d1e26c3 2018-11-07 | Ignore order when compare QOS MAP list entries (sonic-net#372) [Kamil Cudnik]
* e8df347 2018-11-05 | Add best candidate search for router interface using tunnel term tabl… (sonic-net#370) [Kamil Cudnik]
* 8ae173b 2018-11-01 | Refactor saidump graph generator (sonic-net#367) [Kamil Cudnik]

common

* 2a37c5c 2018-11-07 | Add system warm-reboot check in WarmRestart class (sonic-net#246) (HEAD, origin/master, origin/HEAD) [zhenggen-xu]
* fb082b5 2018-11-06 | Fix ProducerStateTable::clear() to clear StateHash properly (sonic-net#244) [Taoyu Li]
* 0ee636b 2018-11-05 | Remove local googletest submodule and link with system gtest (sonic-net#245) [Qi Luo]
* b56ffba 2018-10-31 | Add NEIGH_RESTORE_TABLE in stateDB (sonic-net#243) [zhenggen-xu]
* b58c69d 2018-10-28 | swss-common: add op 'create' case to avoid flush immediately (sonic-net#219) [Dong Zhang]

swss
* afdcf34 2018-11-12 | Support neighsyncd system warmreboot. (sonic-net#661) (HEAD, origin/master, origin/HEAD) [zhenggen-xu]
* f380685 2018-11-09 | Routing-stack warm-reboot feature. (sonic-net#602) [Rodny Molina]
* 9fbcb60 2018-11-09 | Add warm-reboot mode for teammgrd (sonic-net#678) [pavel-shirshov]
* 8c60787 2018-11-09 | Don't add loopback ip2me route again if already configured (sonic-net#656) [Jipan Yang]
* 6eb1613 2018-11-08 | [test]: Add interface IPv6 add/remove test case (sonic-net#677) [Shuotian Cheng]
* 5de5054 2018-11-07 | [vrfmgrd]: Support VNET setting (sonic-net#657) [Marian Pritsak]
* f666011 2018-11-06 | [teammgrd]: Add retry logic when enslaving member port into team (sonic-net#669) [Shuotian Cheng]
* 36e304d 2018-11-05 | [vstest]: print output when runcmd returns error (sonic-net#672) [lguohan]
* aede5d4 2018-11-05 | [test]: Fix clean up wrong interface IP (sonic-net#673) [Shuotian Cheng]
* aeceaca 2018-11-02 | [portmgrd]: portmgrd shall be responsible for all ports update (sonic-net#668) [Shuotian Cheng]
* 5796e54 2018-11-02 | Orchagent warm restart data restore requires three iterations (sonic-net#670) [Jipan Yang]
* 15a2299 2018-11-01 | [vlanmgrd]: Do not bring up VLAN members by default (sonic-net#667) [Shuotian Cheng]
* 44a4460 2018-11-01 | [test]: Clean up LAGs after finishing the test (sonic-net#666) [Shuotian Cheng]

Signed-off-by: Guohan Lu <gulv@microsoft.com>
lguohan added a commit that referenced this pull request Nov 12, 2018
sairedis

* 248a095 2018-11-07 | Add best candidate search for acl table (#371) [Kamil Cudnik]
* d1e26c3 2018-11-07 | Ignore order when compare QOS MAP list entries (#372) [Kamil Cudnik]
* e8df347 2018-11-05 | Add best candidate search for router interface using tunnel term tabl… (#370) [Kamil Cudnik]
* 8ae173b 2018-11-01 | Refactor saidump graph generator (#367) [Kamil Cudnik]

common

* 2a37c5c 2018-11-07 | Add system warm-reboot check in WarmRestart class (#246) (HEAD, origin/master, origin/HEAD) [zhenggen-xu]
* fb082b5 2018-11-06 | Fix ProducerStateTable::clear() to clear StateHash properly (#244) [Taoyu Li]
* 0ee636b 2018-11-05 | Remove local googletest submodule and link with system gtest (#245) [Qi Luo]
* b56ffba 2018-10-31 | Add NEIGH_RESTORE_TABLE in stateDB (#243) [zhenggen-xu]
* b58c69d 2018-10-28 | swss-common: add op 'create' case to avoid flush immediately (#219) [Dong Zhang]

swss
* afdcf34 2018-11-12 | Support neighsyncd system warmreboot. (#661) (HEAD, origin/master, origin/HEAD) [zhenggen-xu]
* f380685 2018-11-09 | Routing-stack warm-reboot feature. (#602) [Rodny Molina]
* 9fbcb60 2018-11-09 | Add warm-reboot mode for teammgrd (#678) [pavel-shirshov]
* 8c60787 2018-11-09 | Don't add loopback ip2me route again if already configured (#656) [Jipan Yang]
* 6eb1613 2018-11-08 | [test]: Add interface IPv6 add/remove test case (#677) [Shuotian Cheng]
* 5de5054 2018-11-07 | [vrfmgrd]: Support VNET setting (#657) [Marian Pritsak]
* f666011 2018-11-06 | [teammgrd]: Add retry logic when enslaving member port into team (#669) [Shuotian Cheng]
* 36e304d 2018-11-05 | [vstest]: print output when runcmd returns error (#672) [lguohan]
* aede5d4 2018-11-05 | [test]: Fix clean up wrong interface IP (#673) [Shuotian Cheng]
* aeceaca 2018-11-02 | [portmgrd]: portmgrd shall be responsible for all ports update (#668) [Shuotian Cheng]
* 5796e54 2018-11-02 | Orchagent warm restart data restore requires three iterations (#670) [Jipan Yang]
* 15a2299 2018-11-01 | [vlanmgrd]: Do not bring up VLAN members by default (#667) [Shuotian Cheng]
* 44a4460 2018-11-01 | [test]: Clean up LAGs after finishing the test (#666) [Shuotian Cheng]

Signed-off-by: Guohan Lu <gulv@microsoft.com>
madhanmellanox pushed a commit to madhanmellanox/sonic-buildimage that referenced this pull request Mar 23, 2020
madhanmellanox pushed a commit to madhanmellanox/sonic-buildimage that referenced this pull request Mar 23, 2020
dmytroxshevchuk pushed a commit to dmytroxshevchuk/sonic-buildimage that referenced this pull request Aug 31, 2020
yxieca pushed a commit that referenced this pull request May 18, 2023
… automatically (#15133)

src/sonic-platform-common

* ff72811 - (HEAD -> 202205, origin/202205) Fix issue '<' not supported between instances of 'NoneType' and 'int' (#371) (5 hours ago) [Junchao-Mellanox]
* f2a419d - Render Media lane and Media assignment options info from Application Code (#368) (8 hours ago) [rajann]
* d8bad10 - Retrieve FW version using CDB command for CMIS transceivers + handle single bank FW versioning (#372) (8 hours ago) [mihirpat1]
yxieca pushed a commit that referenced this pull request Jun 5, 2023
…D automatically (#15344)

src/sonic-platform-daemons

* 1537d6a - (HEAD -> 202205, origin/202205) [dualtor] Fix command `show mux status` (#371) (2 minutes ago) [Longxiang Lyu]
yxieca pushed a commit that referenced this pull request Jun 7, 2023
…D automatically (#15366)

src/sonic-platform-daemons

* 18815c7 - (HEAD -> 202205, origin/202205) Revert "[ycabled] refactor code for onboarding async client changes;refactor (#355)" (3 minutes ago) [Ying Xie]
* 5324554 - Revert "add async notification support in active-active topo; refactor code for ycable tasks for change events  (#327)" (3 minutes ago) [Ying Xie]
* cbbe2b5 - Revert "[ycabled] fix bug for `show mux status` delayed response (#364)" (3 minutes ago) [Ying Xie]
* 9746709 - Revert "[dualtor] Fix command `show mux status` (#371)" (3 minutes ago) [Ying Xie]
* 551ab3c - Revert "[ycabled] correct the wrong function call for 'config hwmode state' (#372)" (3 minutes ago) [Ying Xie]
yxieca pushed a commit that referenced this pull request Jul 8, 2023
…D automatically (#15749)

src/sonic-platform-daemons

* 112656c - (HEAD -> 202205, origin/202205) [ycabled][active-active] no initialize Async Client, when no active-active cable type; fix names for all ycabled threads (#373) (4 minutes ago) [vdahiya12]
* e325d5a - Revert "Revert "[ycabled] correct the wrong function call for 'config hwmode state' (#372)"" (4 minutes ago) [Ying Xie]
* ddabca1 - Revert "Revert "[dualtor] Fix command `show mux status` (#371)"" (4 minutes ago) [Ying Xie]
* 28918da - Revert "Revert "[ycabled] fix bug for `show mux status` delayed response (#364)"" (4 minutes ago) [Ying Xie]
* a849de9 - Revert "Revert "add async notification support in active-active topo; refactor code for ycable tasks for change events  (#327)"" (4 minutes ago) [Ying Xie]
* cf1e73a - Revert "Revert "[ycabled] refactor code for onboarding async client changes;refactor (#355)"" (4 minutes ago) [Ying Xie]
mssonicbld added a commit that referenced this pull request Mar 22, 2024
…tomatically (#18433)

#### Why I did it
src/sonic-linux-kernel
```
* 59e5ea1 - (HEAD -> 202311, origin/202311) Disable small sector erase size for UBIFS on flash (#382) (4 hours ago) [Mridul Bajpai]
* ed95e5d - [202311] Dynamic write timeout support for optoe driver (#371) (8 hours ago) [mihirpat1]
```
#### How I did it
#### How to verify it
#### Description for the changelog
mlok-nokia pushed a commit to mlok-nokia/sonic-buildimage that referenced this pull request Jun 5, 2024
[code sync] Merge code from sonic-net/sonic-buildimage:202205 to 202205
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