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] Only attempt to start 'isc-dhcp-relay' group if it is not empty #1713

Merged
merged 1 commit into from
May 16, 2018
Merged

[dhcp_relay] Only attempt to start 'isc-dhcp-relay' group if it is not empty #1713

merged 1 commit into from
May 16, 2018

Conversation

jleveque
Copy link
Contributor

DHCP relay is only expected to run on T0 devices. On T1 devices, the "isc-dhcp-relay" group in the supervisor config file will not get populated. When Docker container is started, calling supervisorctl start isc-dhcp-relay:* with no entries in the "isc-dhcp-relay" group will generate an error message to the syslog (INFO supervisord: start.sh isc-dhcp-relay: ERROR (no such group)). This PR prevents us from receiving this erroneous error message.

@jleveque jleveque self-assigned this May 15, 2018
# of the process.
/usr/bin/wait_for_intf.sh
# If our supervisor config has entries in the "isc-dhcp-relay" group...
if [ $(supervisorctl status | grep -c "^isc-dhcp-relay:") -gt 0 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

if supervisorctl status | grep -q "^isc-dhcp-relay:"; then do the same, but faster

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... "grep -q" actually seems slower for me...

root@sonic:/# time supervisorctl status | grep -c "^isc-dhcp-relay:"
1

real    0m0.443s
user    0m0.348s
sys     0m0.088s
root@sonic:/# time supervisorctl status | grep -q "^isc-dhcp-relay:"

real    0m0.470s
user    0m0.384s
sys     0m0.068s

Copy link
Contributor

Choose a reason for hiding this comment

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

:) when you write [ you run an external command in the bash script

$ which [
/usr/bin/[

So bash must to run subprocess to calculate the boolean for your if
Executing the subprocess is not so fast.
Faster would be use [[ which is internal bash instruction.
Or just use error code from grep directly as I wrote in the first comment.

@qiluo-msft
Copy link
Collaborator

Should we not start the container on host, instead of starting it and keeping a rsyslogd running?

@jleveque
Copy link
Contributor Author

@qiluo-msft: I agree we shouldn't start the service at all, but we don't have a good mechanism for that. We need to think about that some more.

@jleveque jleveque merged commit 6b8e340 into sonic-net:master May 16, 2018
@jleveque jleveque deleted the eliminate_err_msg branch May 16, 2018 21:32
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.

3 participants