Skip to content

[portsyncd]: Add default catch block in portsyncd#1033

Merged
stcheng merged 4 commits intosonic-net:masterfrom
SuvarnaMeenakshi:portsyncd_catch
Aug 22, 2019
Merged

[portsyncd]: Add default catch block in portsyncd#1033
stcheng merged 4 commits intosonic-net:masterfrom
SuvarnaMeenakshi:portsyncd_catch

Conversation

@SuvarnaMeenakshi
Copy link
Contributor

What I did
Added a default catch block in portsyncd code as current catch block only accepts parameter of type Exception. In the throw currently, a const char * is passed which leads to a core dumped scenario.

Why I did it
Added a default catch block.

How I verified it
To test, Build a sonic-Broadcom image.
Loaded the image in a DUT, rebooted the DUT without a minigraph.xml or config_db.json in /etc/sonic.
While booting up, when systemd tries to start portsyncd process, it passes the parameter port_config.ini. The right port_config.ini is selected and placed in the right directory in swss docker before starting portsyncd process. The right port_config.ini is selected based HW SKU and platform type which is obtained from DEVICE_METADATA. If the device configuration is not loaded correctly, then DEVICE_METADATA will not be read, and port_config.ini is not picked up. With this, if portsyncd is started without the right port_config.ini, the portsyncd process will throw and exception.

Before the fix error looked like:

<14>Aug 5 22:20:40 MWH01-0101-0334-13T0 supervisord: portsyncd terminate called after throwing an instance of 'char const*'
<30>Aug 5 22:20:40 MWH01-0101-0334-13T0 swss.sh[1901]: 2019-08-05 22:20:40,806 INFO exited: portsyncd (terminated by SIGABRT (core dumped); not expected)

After fix the error will look like:
Aug 14 23:24:55.845720 sonic INFO supervisord: portsyncd Exception had been thrown in deamon

Details if related

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.

As comments

@renukamanavalan
Copy link
Contributor

Can we also fix the code that does not seem to throw appropriately?
Else we miss the root cause of the throw.

@stcheng stcheng changed the title Add default catch block in portsyncd [portsyncd]: Add default catch block in portsyncd Aug 21, 2019
@stcheng stcheng merged commit 34915de into sonic-net:master Aug 22, 2019
yxieca pushed a commit that referenced this pull request Aug 26, 2019
* Add default catch block in portsyncd
* Updated error message with the right spelling
* Update try block to throw exception of type runtime_error
* Remove additional paranthesis in throw statement
EdenGri pushed a commit to EdenGri/sonic-swss that referenced this pull request Feb 28, 2022
)

`sonic_installer` has been renamed `sonic-installer`. Update the application name everywhere it is used.
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
* Add default catch block in portsyncd
* Updated error message with the right spelling
* Update try block to throw exception of type runtime_error
* Remove additional paranthesis in throw statement
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.

6 participants