dokku / dokku-postgres

a postgres plugin for dokku
MIT License
491 stars 97 forks source link

`destroy` and `unlink` disagree on whether or not a database is linked to an app #315

Open cuducos opened 7 months ago

cuducos commented 7 months ago

Description of problem

Sometimes the command destroy says a database is linked when it is not linked (although it was in the past). When we try unlinking, we get a confusing message saying there is no link, but next, the destroy command works.

How reproducible

Every single time. We rotate a database monthly in an open-source project, and every single month, I see this bug.

Steps to Reproduce

  1. Link a database to an app (this creates a DATABASE_URL envvar on that app)
  2. Change the DATABASE_URL pointing elsewhere (maybe another PostgreSQL instance)
  3. Try to delete the database linked in step 1, and you get an error saying the database is linked to an app
  4. Try to unlink the database from the app, and you get a message saying the database actually is not linked to the app
  5. Try deleting once more, and this time it works

Actual Results

$ dokku postgres:destroy minhareceita202403
 !     Cannot delete linked service
$ dokku postgres:unlink minhareceita202403 minhareceita
 !     Not linked to app minhareceita
$ dokku postgres:destroy minhareceita202403

 !     WARNING: Potentially Destructive Action
 !     This command will destroy minhareceita202403 Postgres service.
 !     To proceed, type "minhareceita202403"

Expected Results

Environment Information

(not relevant)

dokku report APP_NAME output

(not relevant)

How (deb/make) and where (AWS, VirtualBox, physical, etc.) was Dokku installed?:

VPS via apt.

$ dokku version
dokku version 0.34.4

Additional information

(not relevant)

josegonzalez commented 7 months ago

Please post the output of: dokku report

I need it to know what versions of stuff you have running :)

cuducos commented 7 months ago

Oops… my bad : )

-----> uname: Linux vmi1019611.contaboserver.net 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux
-----> memory: 
                      total        used        free      shared  buff/cache   available
       Mem:           16008         521       14087         170        1399       15025
       Swap:              0           0           0
-----> disk utilization: 
       Filesystem      Size  Used Avail Use% Mounted on
       /dev/sda3       391G  147G  225G  40% /
       /dev/sda2       2.0G  147M  1.7G   8% /boot
-----> disk inode utilization: 
       Filesystem     Inodes IUsed IFree IUse% Mounted on
       /dev/sda3         25M  509K   25M    2% /
       /dev/sda2        128K   364  128K    1% /boot
-----> docker version: 
       Client: Docker Engine - Community
        Version:           26.1.0
        API version:       1.45
        Go version:        go1.21.9
        Git commit:        9714adc
        Built:             Mon Apr 22 17:07:06 2024
        OS/Arch:           linux/amd64
        Context:           default

       Server: Docker Engine - Community
        Engine:
         Version:          26.1.0
         API version:      1.45 (minimum version 1.24)
         Go version:       go1.21.9
         Git commit:       c8af8eb
         Built:            Mon Apr 22 17:07:06 2024
         OS/Arch:          linux/amd64
         Experimental:     false
        containerd:
         Version:          1.6.31
         GitCommit:        e377cd56a71523140ca6ae87e30244719194a521
        runc:
         Version:          1.1.12
         GitCommit:        v1.1.12-0-g51d5e94
        docker-init:
         Version:          0.19.0
         GitCommit:        de40ad0
-----> docker daemon info: 
       Client: Docker Engine - Community
        Version:    26.1.0
        Context:    default
        Debug Mode: true
        Plugins:
         buildx: Docker Buildx (Docker Inc.)
           Version:  v0.14.0
           Path:     /usr/libexec/docker/cli-plugins/docker-buildx
         compose: Docker Compose (Docker Inc.)
           Version:  v2.26.1
           Path:     /usr/libexec/docker/cli-plugins/docker-compose
         scan: Docker Scan (Docker Inc.)
           Version:  v0.23.0
           Path:     /usr/libexec/docker/cli-plugins/docker-scan

       Server:
        Containers: 15
         Running: 7
         Paused: 0
         Stopped: 8
        Images: 33
        Server Version: 26.1.0
        Storage Driver: overlay2
         Backing Filesystem: extfs
         Supports d_type: true
         Using metacopy: false
         Native Overlay Diff: true
         userxattr: false
        Logging Driver: json-file
        Cgroup Driver: systemd
        Cgroup Version: 2
        Plugins:
         Volume: local
         Network: bridge host ipvlan macvlan null overlay
         Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
        Swarm: inactive
        Runtimes: io.containerd.runc.v2 runc
        Default Runtime: runc
        Init Binary: docker-init
        containerd version: e377cd56a71523140ca6ae87e30244719194a521
        runc version: v1.1.12-0-g51d5e94
        init version: de40ad0
        Security Options:
         apparmor
         seccomp
          Profile: builtin
         cgroupns
        Kernel Version: 5.10.0-21-amd64
        Operating System: Debian GNU/Linux 11 (bullseye)
        OSType: linux
        Architecture: x86_64
        CPUs: 6
        Total Memory: 15.63GiB
        Name: vmi1019611.contaboserver.net
        ID: VZV2:OTIS:OPTV:IZGA:4NLN:J32J:5AJV:ZOHV:MOCB:UUFM:ZHTN:J3VW
        Docker Root Dir: /var/lib/docker
        Debug Mode: false
         File Descriptors: 69
         Goroutines: 73
         System Time: 2024-04-26T02:01:24.146671628+02:00
         EventsListeners: 1
        Experimental: false
        Insecure Registries:
         127.0.0.0/8
        Live Restore Enabled: false

-----> herokuish version: 
       herokuish: v0.9.1
       buildpacks:
         heroku-buildpack-multi     v1.2.0
         heroku-buildpack-ruby      v267
         heroku-buildpack-nodejs    v240
         heroku-buildpack-clojure   v91
         heroku-buildpack-python    v246
         heroku-buildpack-java      v73
         heroku-buildpack-gradle    v39
         heroku-buildpack-scala     v98
         heroku-buildpack-play      v26
         heroku-buildpack-php       v248
         heroku-buildpack-go        v189
         heroku-buildpack-nginx     v25
         buildpack-null             v3
-----> dokku version: dokku version 0.34.4
-----> dokku-event-listener version: 0.15.0build+5268732                                                             
-----> dokku-update version: dokku-update 0.8.0
-----> docker-container-healthchecker version: 0.9.0                                                                           
-----> docker-image-labeler version: 0.6.1build+c6e15a9                                                              
-----> git version: git version 2.30.2
-----> lambda-builder version:        0.6.0                                                                           
-----> netrc version: 0.8.0build+0751c1b
-----> plugn version: plugn: 0.13.0build+fd5297a
-----> sigil version: 0.10.1build+e443be0
-----> sshcommand version: sshcommand 0.17.1
-----> dokku plugins: 
         00_dokku-standard    0.34.4 enabled    dokku core standard plugin
         20_events            0.34.4 enabled    dokku core events logging plugin
         app-json             0.34.4 enabled    dokku core app-json plugin
         apps                 0.34.4 enabled    dokku core apps plugin
         builder              0.34.4 enabled    dokku core builder plugin
         builder-dockerfile   0.34.4 enabled    dokku core builder-dockerfile plugin
         builder-herokuish    0.34.4 enabled    dokku core builder-herokuish plugin
         builder-lambda       0.34.4 enabled    dokku core builder-lambda plugin
         builder-nixpacks     0.34.4 enabled    dokku core builder-nixpacks plugin
         builder-null         0.34.4 enabled    dokku core builder-null plugin
         builder-pack         0.34.4 enabled    dokku core builder-pack plugin
         buildpacks           0.34.4 enabled    dokku core buildpacks plugin
         caddy-vhosts         0.34.4 enabled    dokku core caddy-vhosts plugin
         certs                0.34.4 enabled    dokku core certificate management plugin
         checks               0.34.4 enabled    dokku core checks plugin
         common               0.34.4 enabled    dokku core common plugin
         config               0.34.4 enabled    dokku core config plugin
         cron                 0.34.4 enabled    dokku core cron plugin
         docker-options       0.34.4 enabled    dokku core docker-options plugin
         domains              0.34.4 enabled    dokku core domains plugin
         enter                0.34.4 enabled    dokku core enter plugin
         git                  0.34.4 enabled    dokku core git plugin
         haproxy-vhosts       0.34.4 enabled    dokku core haproxy-vhosts plugin
         letsencrypt          0.18.1 enabled    Automated installation of let's encrypt TLS certificates
         logs                 0.34.4 enabled    dokku core logs plugin
         network              0.34.4 enabled    dokku core network plugin
         nginx-vhosts         0.34.4 enabled    dokku core nginx-vhosts plugin
         openresty-vhosts     0.34.4 enabled    dokku core openresty-vhosts plugin
         plugin               0.34.4 enabled    dokku core plugin plugin
         ports                0.34.4 enabled    dokku core ports plugin
         postgres             1.24.0 enabled    dokku postgres service plugin
         proxy                0.34.4 enabled    dokku core proxy plugin
         ps                   0.34.4 enabled    dokku core ps plugin
         registry             0.34.4 enabled    dokku core registry plugin
         repo                 0.34.4 enabled    dokku core repo plugin
         resource             0.34.4 enabled    dokku core resource plugin
         run                  0.34.4 enabled    dokku core run plugin
         scheduler            0.34.4 enabled    dokku core scheduler plugin
         scheduler-docker-local 0.34.4 enabled    dokku core scheduler-docker-local plugin
         scheduler-k3s        0.34.4 enabled    dokku core scheduler-k3s plugin
         scheduler-null       0.34.4 enabled    dokku core scheduler-null plugin
         shell                0.34.4 enabled    dokku core shell plugin
         ssh-keys             0.34.4 enabled    dokku core ssh-keys plugin
         storage              0.34.4 enabled    dokku core storage plugin
         trace                0.34.4 enabled    dokku core trace plugin
         traefik-vhosts       0.34.4 enabled    dokku core traefik-vhosts plugin