Skip to content

TLS storage maintenance causes spurious error messages on caddy admin API changes #7955

Description

@jum

Issue Details

When using a network based storage module for TLS certificates every once in a while a race condition produces a flurry of error messages due to failed network calls with context cancelled messages. A typical example:

{
  "insertId": "19jcz73egp0ed",
  "jsonPayload": {
    "error": "Unable to release lock for caddy/locks/storage_clean: redis: client is closed",
    "logger": "tls",
    "message": "unable to release lock",
    "container": {
      "imageName": "jumager/caddy:develop",
      "id": "0ac09e46fb29343ff57d9ccfea137538b386d8ff634b45139f2495faf346ce0d",
      "name": "/caddy",
      "imageId": "sha256:c7536d4b1e0059446272e1c4835b0e11234554f46ceff910a139ac5457f103be",
      "created": "2026-08-16T16:36:17.364258633Z"
    },
    "storage": "{\"client_type\":\"simple\",\"address\":[\"redacted:6379\"],\"host\":[],\"port\":[],\"db\":\"0\",\"timeout\":\"\",\"username\":\"\",\"password\":\"\",\"sentinel_password\":\"\",\"master_name\":\"\",\"key_prefix\":\"caddy\",\"encryption_key\":\"\",\"compression\":\"\",\"tls_enabled\":false,\"tls_insecure\":false,\"tls_server_certs_pem\":\"\",\"tls_server_certs_path\":\"\",\"route_by_latency\":false,\"route_randomly\":false}",
    "instance": {
      "id": "redacted",
      "zone": "redacted"
    }
  },
  "resource": {
    "type": "gce_instance",
    "labels": {
      "instance_id": "redacted",
      "zone": "europe-west3-a",
      "project_id": "hosting-349701"
    }
  },
  "timestamp": "2026-08-17T22:36:18.338979742Z",
  "severity": "ERROR",
  "logName": "projects/redacted/logs/ngcplogs-docker-driver",
  "receiveTimestamp": "2026-08-17T22:36:19.202080199Z"
}

I did use gemini to analyze the race condition and devise a fix pull request for caddy:

#7954

This also requires a change in certmagic:

caddyserver/certmagic#403

And also in caddy-storage-redis:

pberkel/caddy-storage-redis#43

I am currenty stress testing this fix in production with artificial load on the admin api with constantly changing the server config and thus forcing server reloads. All the PR's are marked as work in progress because I would like to hear some feedback from more experienced caddy developers.

Assistance Disclosure

AI used

If AI was used, describe the extent to which it was used.

Gemini analyzed the code for race conditions and pointed out the issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions