gregtwallace / certwarden

Cert Warden is a centralized ACME Client. It provides an API for certificate consumers to fetch their individual keys and certs with API keys.
https://www.certwarden.com/
Other
176 stars 6 forks source link

Error when updating - Cannot move config file to new directory #36

Closed KodySalak closed 6 months ago

KodySalak commented 6 months ago

Hi.

New issue when updating to newest release... (0.17.0)

2023-12-21T06:27:13.033Z    info    app/logger.go:138   init logging started (log level: debug)
2023-12-21T06:27:13.033Z    info    app/app_create.go:39    starting LeGo CertHub v0.17.0
2023-12-21T06:27:13.033Z    error   app/configure.go:88 failed to move config file from old location to new location (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T06:27:13.033Z    error   app/app_create.go:69    failed to read app config file (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T06:27:13.033Z    error   app/run.go:64   failed to create app (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)

repeats over and over in the docker log.

My compose:

version: "3"

services:
  legocerthub:
    container_name: legocerthub
    image: ghcr.io/gregtwallace/legocerthub:latest
    restart: unless-stopped
    ports:
      - 10.0.10.32:4055:4055   # server interface (https)
    volumes:
      - /opt/KSContainers/certhub/:/app/data
      - /opt/KSContainers/certhub/config.yaml:/app/data/config.yaml

Do I need to manually move the config file on my filesystem? If so, where to?

gregtwallace commented 6 months ago

Strange and not a super helpful error message either. Grr.

Manual fix is to move the config and db file from ./data to ./data/app

I’ll have to ponder why the automatic rename isn’t working.

gregtwallace commented 6 months ago

Can you send me the rest of your log from whenever you tried to start the new version the first time (aka the first instance of starting LeGo CertHub v0.17.0) through the first couple of repeats of the error loop?

KodySalak commented 6 months ago

This is what I see when I do the update:

2023-12-21T23:45:52.354Z    info    app/logger.go:138   init logging started (log level: debug)
2023-12-21T23:45:52.355Z    info    app/app_create.go:39    starting LeGo CertHub v0.17.0
2023-12-21T23:45:52.355Z    error   app/configure.go:88 failed to move config file from old location to new location (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T23:45:52.355Z    error   app/app_create.go:69    failed to read app config file (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T23:45:52.355Z    error   app/run.go:64   failed to create app (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T23:45:53.342Z    info    app/logger.go:138   init logging started (log level: debug)
2023-12-21T23:45:53.342Z    info    app/app_create.go:39    starting LeGo CertHub v0.17.0
2023-12-21T23:45:53.343Z    error   app/configure.go:88 failed to move config file from old location to new location (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T23:45:53.343Z    error   app/app_create.go:69    failed to read app config file (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T23:45:53.343Z    error   app/run.go:64   failed to create app (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T23:45:54.269Z    info    app/logger.go:138   init logging started (log level: debug)
2023-12-21T23:45:54.269Z    info    app/app_create.go:39    starting LeGo CertHub v0.17.0
2023-12-21T23:45:54.270Z    error   app/configure.go:88 failed to move config file from old location to new location (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T23:45:54.270Z    error   app/app_create.go:69    failed to read app config file (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T23:45:54.270Z    error   app/run.go:64   failed to create app (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T23:45:55.370Z    info    app/logger.go:138   init logging started (log level: debug)
2023-12-21T23:45:55.371Z    info    app/app_create.go:39    starting LeGo CertHub v0.17.0
2023-12-21T23:45:55.371Z    error   app/configure.go:88 failed to move config file from old location to new location (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T23:45:55.372Z    error   app/app_create.go:69    failed to read app config file (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)
2023-12-21T23:45:55.372Z    error   app/run.go:64   failed to create app (rename ./data/config.yaml ./data/app/config.yaml: device or resource busy)

The first line here is the first line of the log

gregtwallace commented 6 months ago

Strange. I tried to reproduce (and found a different problem) but wasn’t able to reproduce this in or out of docker.

I’ll leave this open for a bit to see if anyone else encounters the same thing.

KodySalak commented 6 months ago

If it helps - not sure if it made a difference because I tried to get it to do the upgrade again:

Watchtower is running and auto-updating the containers, and I noticed that root was the owner on all of the files that were mentioned (and them more). I changed ownership to the user I sign in with, and that didn't change the outcome, but food for thought since my docker engine is running as root

gregtwallace commented 6 months ago

It could be permissions. I kind of figured it would throw a different more descriptive error for that but I didn’t dive into the code. Resource busy sounds more like the file was already in use somehow, which also doesn’t really make any sense. Even more confusing one file moved fine but not the other.

The real lesson is I should have reverted the file move change. The original reason I did it wasn’t particularly pertinent anymore by the time I finished the feature update.

Lesson learned.

gregtwallace commented 6 months ago

Thankfully no other reports of this. Presumably some weird permissions thing happened and I won't move files again in the future.