linuxserver / docker-unifi-network-application

GNU General Public License v3.0
657 stars 49 forks source link

check for mongodb reachability during init #23

Closed drizuid closed 11 months ago

drizuid commented 11 months ago

linuxserver.io



Description:

rather than blindly supporting people who have mongo and unifi in different bridges, check for reachability during init and flag in the container logs. exiting at this point will also avoid mucking up mongodb or settings

Benefits of this PR and context:

ease our support burden and help users self-identify issues (lol at unraid users actually reading logs though)

How Has This Been Tested?

it hasn't been tested aside from in bash, yolo.

root@9e424684da5a:/usr/lib/unifi# MONGO_HOST=purple
root@9e424684da5a:/usr/lib/unifi# if [[ -z  "${MONGO_HOST}" ]]; then echo not set; elif ! nc -w1 "${MONGO_HOST}" ${MONGO_PORT}; then echo $? -- not reached; else echo works; fi
nc: getaddrinfo for host "purple" port 27017: Name or service not known
0 -- not reached
root@9e424684da5a:/usr/lib/unifi# MONGO_HOST=mongodb
root@9e424684da5a:/usr/lib/unifi# MONGO_PORT=27018
root@9e424684da5a:/usr/lib/unifi# if [[ -z  "${MONGO_HOST}" ]]; then echo not set; elif ! nc -w1 "${MONGO_HOST}" ${MONGO_PORT}; then echo $? -- not reached; else echo works; fi
0 -- not reached
root@9e424684da5a:/usr/lib/unifi# MONGO_PORT=27017
root@9e424684da5a:/usr/lib/unifi# if [[ -z  "${MONGO_HOST}" ]]; then echo not set; elif ! nc -w1 "${MONGO_HOST}" ${MONGO_PORT}; then echo $? -- not reached; else echo works; fi
works
root@9e424684da5a:/usr/lib/unifi# unset MONGO_HOST
root@9e424684da5a:/usr/lib/unifi# if [[ -z  "${MONGO_HOST}" ]]; then echo not set; elif ! nc -w1 "${MONGO_HOST}" ${MONGO_PORT}; then echo $? -- not reached; else echo works; fi
not set

Source / References:

what prompted the thought is https://discord.com/channels/354974912613449730/1163422841161650227

LinuxServer-CI commented 11 months ago

I am a bot, here is the pushed image/manifest for this PR:

ghcr.io/linuxserver/lspipepr-unifi-network-application:7.5.176-pkg-22c0bf17-dev-b5696dc13f6b17d8a38f5acce86d2e957bf63ccf-pr-23

LinuxServer-CI commented 11 months ago

I am a bot, here is the pushed image/manifest for this PR:

ghcr.io/linuxserver/lspipepr-unifi-network-application:7.5.176-pkg-22c0bf17-dev-8f96e5dd7b5f7c08d62b50445a99ea5658122f58-pr-23

LinuxServer-CI commented 11 months ago

I am a bot, here is the pushed image/manifest for this PR:

ghcr.io/linuxserver/lspipepr-unifi-network-application:7.5.176-pkg-22c0bf17-dev-c15cb33cea2c24fab8b8a74fc013cc2bce77b20f-pr-23