remilapeyre / vault-acme

Mozilla Public License 2.0
94 stars 24 forks source link

Cache entry corrupted #3

Closed heri16 closed 4 years ago

heri16 commented 4 years ago

I encountered an issue of this plugin being broken.

This seems to happen when a nomad group with count = 100 is run, which causes multiple nomad tasks writing to acme/certs/alpha.proofofparticipation.network common_name=*.alpha.proofofparticipation.network at the same, resulting in this plugin being broken.

Error Message

bash-3.2$ vault write acme/certs/alpha.proofofparticipation.network common_name=*.alpha.proofofparticipation.network
Error writing data to acme/certs/alpha.proofofparticipation.network: Error making API request.

URL: PUT http://139.162.27.172:8200/v1/acme/certs/alpha.proofofparticipation.network
Code: 500. Errors:

* 1 error occurred:
    * failed to save cache entry: put failed due to value being too large: Unexpected response code: 413 (Value exceeds 524288 byte limit)

Excerpt of Nomad job

template {
        destination   = "local/_.alpha.proofofparticipation.network.crt"
        change_mode   = "restart"
        data          = <<EOH
{{ with secret "acme/certs/alpha.proofofparticipation.network" "common_name=*.alpha.proofofparticipation.network" }}
{{- .Data.cert -}}
{{ end }}
EOH
}

template {
        destination   = "local/_.alpha.proofofparticipation.network.key"
        change_mode   = "restart"
        data          = <<EOH
{{ with secret "acme/certs/alpha.proofofparticipation.network" "common_name=*.alpha.proofofparticipation.network" }}
{{- .Data.private_key -}}
{{ end }}
EOH
}

Is there anyway to clear/delete the data in the vault storage/cache?

remilapeyre commented 4 years ago

I will add en endpoint to do manage the cache. What storage are you using? It seems the put failed due to value being too large might be dependent on the storage used and I will need to look into it if this can happen during normal operation.

remilapeyre commented 4 years ago

Hi @heri16, 8bf92d9c3c5ce03bcce66ac949256d8cf7727500 adds what you need, you can now do vault delete acme/cache to clear the cache.

remilapeyre commented 4 years ago

I'll close this issue at it should be fixed now. Feel free to reopen it if needed :)