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

[BUG] Changing mongo server host has no effect #124

Open
1 task done
aporcupine opened this issue Dec 22, 2024 · 3 comments
Open
1 task done

[BUG] Changing mongo server host has no effect #124

aporcupine opened this issue Dec 22, 2024 · 3 comments

Comments

@aporcupine
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Even after updating MONGO_HOST and restarting, the container continues to connect to the old MongoDB host, ignoring the new host specified.

Expected Behavior

After changing MONGO_HOST, the container should connect to the newly defined MongoDB host upon restart, rather than continuing to use the old one.

Steps To Reproduce

  1. Set up the container according to the official documentation, using an external MongoDB instance.
  2. Confirm the container is running and using the specified MONGO_HOST.
  3. Update the MONGO_HOST environment variable to point to a different MongoDB host (with the same content database).
  4. Restart the container.

Environment

- OS: Ubuntu 24.04 
- How docker service was installed: k8s (bare metal, kubeadm)

CPU architecture

arm64

Docker creation

- image: lscr.io/linuxserver/unifi-network-application:latest
        name: unifi-v2
        env:
        - name: MONGO_HOST
          value: 127.0.0.1
        - name: MONGO_PORT
          value: "27017"
        - name: MONGO_DBNAME
          value: unifi
        - name: MONGO_AUTHSOURCE
          value: admin
        - name: MONGO_USER
          value: unifi
        - name: MONGO_PASS
          valueFrom:
            secretKeyRef:
              name: ####
              key: password
        volumeMounts:
        - mountPath: /config
          name: ####
          subPath: unifi-config

Container logs

Caused by: com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=unifi-mongo:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: Connect timed out}}]

NOTE: unifi-mongo is the old host
Copy link

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

@aporcupine
Copy link
Author

NOTE: the host is defined in system.properties, updating that fixes the issue. I wonder if it's worth having a script that'll update that when the env var changes?

@thespad
Copy link
Member

thespad commented Dec 22, 2024

-e MONGO_HOST=unifi-db Mongodb Hostname. Only evaluated on first run.

Trying to substitute values in a live system.properties on every start is not worth the risk of breaking installs where people have done something unexpected, which is why we don't do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Issues
Development

No branches or pull requests

2 participants