Closed j0ni closed 7 years ago
I think agent.yml and agent.conf should be added ot the list of config files. Is that something you do with fpm?
@mveytsman yes, we can do that, it just fucks with the slick packaging logic. Oh well :)
@mveytsman looks like listing them causes the packager to barf if they aren't present in the package. I'll see if there's another way.
I've been fiddling with this, and I don't see a way to deal with it correctly.
What we want to do is remove the leftover files plus the legit config file when purging, but leave them all in place if just removing the appcanary package.
conffiles
fails.before-removal
hook to remove the files will do so for both removal and purging.after-removal
hook could check for the existence of the agent.yml.sample
file and assume that if it's missing we're purging, but that would be unreliable.before-removal
hook could stash the files, then an after-removal
hook could put them back if the directory hasn't been removed (which happens if it's empty), but this would be unreliable if there are other artifacts in that directory which result in the directory not being removed.before-
and after-purge
hooks.So, I'm inclined to leave this as is, and allow the files to remain and prevent the directory being removed. The only thing that niggles is the fact that on purge, the .sample
file will be removed, but the regular .yml
version will not, which is slightly broken.
👍
In this PR we stop installing a broken (incomplete template) config file and instead install the template with a
.sample
extension. This allows the agent to successfully convert an old configuration if one exists, avoiding ignoring the old configuration and loading a broken configuration on restart.In addition, I've tweaked the config struct so it doesn't dump empty tag lists when it converts the configuration.
Finally, there is one possible gotcha - when you purge a package, it leaves in place files it doesn't know about; this includes
agent.conf.deprecated
, but also the actualagent.yml
, because the files now marked as config files in the package have the.sample
extension, e.g.,agent.yml.sample
. This is fairly minor, but I'm not sure if there are other consequences of this change. Would it be appropriate to add the.yml
files into the list of config files? Resulting in the following list:/etc/appcanary/agent.yml
/etc/appcanary/agent.yml.sample
/var/db/appcanary/server.yml
/var/db/appcanary/server.yml.sample
being treated as config files. Note that doing this would still leave
*.conf.deprecated
in place, unremoved.