-
Notifications
You must be signed in to change notification settings - Fork 295
If auto_discover_path is set to /tmp/WHATEVER/.... plugins are erased when snapd stops #954
Comments
Slightly modified the instructions above for os x. Listed the instructions I used below. I was able to reproduce the behavior.
This seems to be related to this line where we check that the plugin path is in the tmp dir by comparing it with os.TempDir() and remove it if it is. I think this might have been done to remove files loaded over rest (that are written to the tmpdir). |
Thanks for this note Cody. This makes it even more dangerous because it also concerns paths were the $TMPDIR string is contained anywhere like for instance on Linux ~user/tmp/X/Y/Z |
Thanks for finding/posting the issue @obourdon. Looking into it a little more this morning I noticed when loading plugins from rest we actually use ioutil.TempDir() not os.TempDir(). The code is here but I copied the relevant lines below: // Create temporary directory
dir, err := ioutil.TempDir("", "")
if err != nil {
return "", err
}
f, err := os.Create(path.Join(dir, filename)) ioutil.TempDir() will create a new directory (that seems to be a set of numbers) and combine it with the result of os.TempDir() so for example you end up with This makes it a littler harder to correctly handle the removal. The ways to fix this that come to mind immediately are:
|
Very good catch, I did most of my investigations and testing on Linux systems so I guess my fix proposal might not be exhaustive in this respect. I also thought about implementing the second of your proposal (tagging plugins to remember how they were uploaded which seems to be the more reliable way to go) but the fix was unfortunately out of my current competencies so I focused on a quicker one |
I have just uploaded a new version of the pull request which, I think, implements the tagging of plugins at load time. I have successfully tested it on Linux and MacOS platforms. Feel free to make any comments |
Fix for issue #954 Adds IsAutoLoaded to pluginDetails in order to remove only non-autoloaded plugins.
To reproduce the issue:
go get github.com/intelsdi-x/snap
Please note that currently this should fail due to latest commits in https://github.com/appc/spec :-(
but once you fixed those, run:
cd $GOPATH/src/github.com/intelsdi-x/snap
make all
mkdir -p /tmp/X/Y/Z
rsync -a build/ /tmp/X/Y/Z
/tmp/X/Y/Z/bin/snapd -t 0 -l 1 -a /tmp/X/Y/Z/plugin
...
^C
DEBU[0004] stopped _block=start-plugin _module=control-runner DEBU[0004] Removing plugin _module=control-plugin-mgr plugin-name=mock plugin-path=/tmp/X/Y/Z/plugin/snap-collector-mock2 plugin-type=collector plugin-version=2 DEBU[0004] Removing plugin _module=control-plugin-mgr plugin-name=passthru plugin-path=/tmp/X/Y/Z/plugin/snap-processor-passthru plugin-type=processor plugin-version=1 DEBU[0004] Removing plugin _module=control-plugin-mgr plugin-name=file plugin-path=/tmp/X/Y/Z/plugin/snap-publisher-file plugin-type=publisher plugin-version=3 DEBU[0004] Removing plugin _module=control-plugin-mgr plugin-name=mock plugin-path=/tmp/X/Y/Z/plugin/snap-collector-mock1 plugin-type=collector plugin-version=1
ls /tmp/X/Y/Z
bin
Only plugins loaded via snapctl should be cleaned up not the one from auto discovery path
The text was updated successfully, but these errors were encountered: