Skip to content

Commit 5815b06

Browse files
jlevequesanthosh-kt
authored andcommitted
[docker-platform-monitor] Check if sonic_platform is available before installed (sonic-net#5764)
On Arista platforms, sonic_platform packages are not installed in the PMon container, but are rather mounted into the container from the host OS. Therefore, pip show sonic_platform will fail in the PMon container. This change will first check if we can import sonic_platform. If this fails, it will then fall back to checking if the package is installed. If both fail, it will attempt to install the package.
1 parent b7c4a1a commit 5815b06

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

dockers/docker-platform-monitor/start.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if [ -e /usr/share/sonic/platform/platform_wait ]; then
1616
fi
1717

1818
# If the Python 2 sonic-platform package is not installed, try to install it
19-
pip2 show sonic-platform > /dev/null 2>&1
19+
python2 -c "import sonic_platform" > /dev/null 2>&1 || pip2 show sonic-platform > /dev/null 2>&1
2020
if [ $? -ne 0 ]; then
2121
SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py2-none-any.whl"
2222
echo "sonic-platform package not installed, attempting to install..."
@@ -33,7 +33,7 @@ if [ $? -ne 0 ]; then
3333
fi
3434

3535
# If the Python 3 sonic-platform package is not installed, try to install it
36-
pip3 show sonic-platform > /dev/null 2>&1
36+
python3 -c "import sonic_platform" > /dev/null 2>&1 || pip3 show sonic-platform > /dev/null 2>&1
3737
if [ $? -ne 0 ]; then
3838
SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py3-none-any.whl"
3939
echo "sonic-platform package not installed, attempting to install..."

0 commit comments

Comments
 (0)