linuxserver / docker-unifi-network-application

GNU General Public License v3.0
551 stars 40 forks source link

[BUG] <title> #54

Closed zpqrtbnk closed 2 months ago

zpqrtbnk commented 5 months ago

Is there an existing issue for this?

Current Behavior

Using the MongoDB initialization script from README or from "various sources" to initialize MondoDB, the application fails to connect to MongoDB properly and completely. Getting errors about permission denied for some operations, and eventually a Java crash, and the application exits.

Expected Behavior

It all works :)

Steps To Reproduce

Use the script from README:

db.getSiblingDB("unifi").createUser({user: "unifi", pwd: "****", roles: [{role: "dbOwner", db: "unifi"}]});
db.getSiblingDB("unifi_stat").createUser({user: "unifi", pwd: "****", roles: [{role: "dbOwner", db: "unifi_stat"}]});

Start the MondoDB container (version 4.4), start Unifi container (latest), getting errors about not being able to access unifi_stat and the app does not run.

Environment

- OS: QNAP
- How docker service was installed: QNAP

CPU architecture

x86-64

Docker creation

db:

unifi-db:
    image: docker.io/mongo:4.4
    container_name: unifi-db
    restart: unless-stopped
    env_file: secrets/unifi-db.secrets
    volumes:
      - /share/Container/unifi/mongodb:/data/db
      - /share/Container/unifi/js/init.js:/docker-entrypoint-initdb.d/init.js:ro
    networks:
      - unifi-internal

### Container logs

```bash
n/a
github-actions[bot] commented 5 months ago

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

zpqrtbnk commented 5 months ago

And... I have traced the issue to the script creating two unifi users, one in unifi database and one in unifi_stat database, which cannot access each other's database. I see errors in the MongoDB logs (which I have erased and don't have anymore and I know it would have been better to still have them) that say: successfully connected (user unifi database unifi) then permission denied (database unifi_stat).

So I believe that Unifi uses one user to access the two databases. I have changed the script as such:

const dbname = 'unifi';
const dbuser = 'unifi';
const dbpass = _getEnv('MONGO_UNIFI_PASSWORD');

db
    .getSiblingDB(dbname)
    .createUser({
        user:dbuser, 
        pwd:dbpass, 
        roles:[
            {role:'dbOwner', db:dbname},
            {role:'dbOwner', db:dbname+'_stat'}
        ]
    });
db
    .getSiblingDB(dbname+'_stat')
    .createUser({
        user:dbuser, 
        userSource:dbname, 
        roles:[
            {role:'dbOwner', db:dbname},
            {role:'dbOwner', db:dbname+'_stat'}
        ]
    });

Which essentially creates a user on both databases, each having access to both databases. And all my problems were gone.

Happy to discuss.

zpqrtbnk commented 5 months ago

And while we're at it, I am not even sure we need the user on unifi_stat - will test.

derfel1989 commented 5 months ago

@zpqrtbnk I've been trying many tutorials without success.

I tried your script without success as well; below is my docker-compose. I would be happy with any help provided.

By the way, I don't think the issue is with MongoDB ( versions 6=<). It appears to be a problem with the Application container. When I attempt to manually run the command on the MongoDB bash container, it gives a warning that the user and database unifi already exist.

---
version: "2.1"

services:
  unifi-db:
    image: docker.io/mongo:4.4
    container_name: unifi-db
    volumes:
      - /usr/docker/unifi-network-application/db/data:/data/db
      - /usr/docker/unifi-network-application/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
    ports:
      - 27017:27017
    restart: always
unifi-network-application: 
    image: lscr.io/linuxserver/unifi-network-application:latest
    container_name: unifi-network-application
    environment: 
      - PUID=1000 
      - PGID=1000
      - TZ=America/New_York 
      - MONGO_HOST=unifi-db 
      - MONGO_USER=unifi 
      - MONGO_PASS=********
      - MONGO_PORT=27017 
      - MONGO_DBNAME=unifi 
      - MEM_LIMIT=1024
      - MEM_STARTUP=1024
      - MONGO_TLS=
      - MONGO_AUTHSOURCE=
    volumes:
      - /usr/docker/unifi-network-application/config:/config
    ports:
      - 8443:8443
      - 3478:3478/udp
      - 10001:10001/udp
      - 8080:8080 
      - 1900:1900/udp
      - 8843:8843 
      - 8880:8880
      - 6789:6789
      - 5514:5514/udp
    restart: always
    depends_on:
      - unifi-db

Logs Mongo-DB

t={"$date":"2024-01-13T05:48:47.455+00:00"} s=I c=CONTROL id=23285 ctx=main msg=Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
t={"$date":"2024-01-13T05:48:47.457+00:00"} s=I c=NETWORK id=4648601 ctx=main msg=Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize.
t={"$date":"2024-01-13T05:48:47.458+00:00"} s=I c=STORAGE id=4615611 ctx=initandlisten msg=MongoDB starting attr={"pid":1,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"d6a1566f9220"}
t={"$date":"2024-01-13T05:48:47.458+00:00"} s=I c=CONTROL id=23403 ctx=initandlisten msg=Build Info attr={"buildInfo":{"version":"4.4.27","gitVersion":"2da9e4437d8c792c2b3c3aea62e284f801172a6b","openSSLVersion":"OpenSSL 1.1.1f  31 Mar 2020","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu2004","distarch":"x86_64","target_arch":"x86_64"}}}
t={"$date":"2024-01-13T05:48:47.458+00:00"} s=I c=CONTROL id=51765 ctx=initandlisten msg=Operating System attr={"os":{"name":"Ubuntu","version":"20.04"}}
t={"$date":"2024-01-13T05:48:47.458+00:00"} s=I c=CONTROL id=21951 ctx=initandlisten msg=Options set by command line attr={"options":{"net":{"bindIp":"*"}}}
t={"$date":"2024-01-13T05:48:47.458+00:00"} s=W c=STORAGE id=22271 ctx=initandlisten msg=Detected unclean shutdown - Lock file is not empty attr={"lockFile":"/data/db/mongod.lock"}
t={"$date":"2024-01-13T05:48:47.458+00:00"} s=I c=STORAGE id=22270 ctx=initandlisten msg=Storage engine to use detected by data files attr={"dbpath":"/data/db","storageEngine":"wiredTiger"}
t={"$date":"2024-01-13T05:48:47.458+00:00"} s=W c=STORAGE id=22302 ctx=initandlisten msg=Recovering data from the last clean checkpoint.
t={"$date":"2024-01-13T05:48:47.458+00:00"} s=I c=STORAGE id=22297 ctx=initandlisten msg=Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem tags=["startupWarnings"]
t={"$date":"2024-01-13T05:48:47.459+00:00"} s=I c=STORAGE id=22315 ctx=initandlisten msg=Opening WiredTiger attr={"config":"create,cache_size=7436M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress,compact_progress],"}

{"t":{"$date":"2024-01-13T05:48:48.110+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1705124928:110291][1:0x7f9bbe6cecc0], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 127 through 128"}}

{"t":{"$date":"2024-01-13T05:48:48.166+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1705124928:165997][1:0x7f9bbe6cecc0], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 128 through 128"}}
t={"$date":"2024-01-13T05:48:48.266+00:00"} s=I c=STORAGE id=22430 ctx=initandlisten msg=WiredTiger message attr={"message":"[1705124928:266875][1:0x7f9bbe6cecc0], txn-recover: [WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS] Main recovery loop: starting at 127/256 to 128/256"}

{"t":{"$date":"2024-01-13T05:48:48.384+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1705124928:384939][1:0x7f9bbe6cecc0], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 127 through 128"}}

{"t":{"$date":"2024-01-13T05:48:48.454+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1705124928:454790][1:0x7f9bbe6cecc0], txn-recover: [WT_VERB_RECOVERY_PROGRESS] Recovering log 128 through 128"}}
t={"$date":"2024-01-13T05:48:48.508+00:00"} s=I c=STORAGE id=22430 ctx=initandlisten msg=WiredTiger message attr={"message":"[1705124928:508416][1:0x7f9bbe6cecc0], txn-recover: [WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS] Set global recovery timestamp: (0, 0)"}
t={"$date":"2024-01-13T05:48:48.508+00:00"} s=I c=STORAGE id=22430 ctx=initandlisten msg=WiredTiger message attr={"message":"[1705124928:508491][1:0x7f9bbe6cecc0], txn-recover: [WT_VERB_RECOVERY | WT_VERB_RECOVERY_PROGRESS] Set global oldest timestamp: (0, 0)"}
t={"$date":"2024-01-13T05:48:48.511+00:00"} s=I c=STORAGE id=22430 ctx=initandlisten msg=WiredTiger message attr={"message":"[1705124928:511650][1:0x7f9bbe6cecc0], WT_SESSION.checkpoint: [WT_VERB_CHECKPOINT_PROGRESS] saving checkpoint snapshot min: 1, snapshot max: 1 snapshot count: 0, oldest timestamp: (0, 0) , meta checkpoint timestamp: (0, 0) base write gen: 9797"}
t={"$date":"2024-01-13T05:48:48.519+00:00"} s=I c=STORAGE id=4795906 ctx=initandlisten msg=WiredTiger opened attr={"durationMillis":1060}
t={"$date":"2024-01-13T05:48:48.519+00:00"} s=I c=RECOVERY id=23987 ctx=initandlisten msg=WiredTiger recoveryTimestamp attr={"recoveryTimestamp":{"$timestamp":{"t":0,"i":0}}}
t={"$date":"2024-01-13T05:48:48.524+00:00"} s=I c=STORAGE id=22262 ctx=initandlisten msg=Timestamp monitor starting
t={"$date":"2024-01-13T05:48:48.526+00:00"} s=W c=CONTROL id=22120 ctx=initandlisten msg=Access control is not enabled for the database. Read and write access to data and configuration is unrestricted tags=["startupWarnings"]
t={"$date":"2024-01-13T05:48:48.528+00:00"} s=F c=- id=23095 ctx=initandlisten msg=Fatal assertion attr={"msgid":28579,"error":"UnsupportedFormat: Application metadata for table:index-2--6619936185680685091 has unsupported format version: 14. Index: {name: user_1_db_1, ns: admin.system.users} - version either too old or too new for this mongod.","file":"src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp","line":537}
t={"$date":"2024-01-13T05:48:48.528+00:00"} s=F c=- id=23096 ctx=initandlisten msg=

***aborting after fassert() failure

MongoDB 4.4 bash issue

Running MongoDB 4.4, it's crashed since the start.

image

LinuxServer-CI commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 month ago

This issue is locked due to inactivity