-
Notifications
You must be signed in to change notification settings - Fork 294
(SDI-2475) Configure the TempDir where the API loads plugins. #1512
Conversation
docs/SNAPTELD.md
Outdated
@@ -52,6 +52,7 @@ $ snapteld [global options] command [command options] [arguments...] | |||
--rest-cert value A path to a certificate to use for HTTPS deployment of Snap's REST API | |||
--rest-key value A path to a key file to use for HTTPS deployment of Snap's REST API | |||
--rest-auth Enables Snap's REST API authentication | |||
--rest-load-path A configurable path from which the API loads plugins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider exposing this as top level (control) config. It could be called --temp-dir-path
. This will line up when we resolve #1502.
614fd84
to
b7a011d
Compare
91ed1c9
to
a4e63c9
Compare
|
||
func WriteFile(filename string, b []byte) (string, error) { | ||
// Create temporary directory | ||
dir, err := ioutil.TempDir(control.GetDefaultConfig().TempDirPath, "snap-plugin-") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the trailing -
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trailing isn't required. Each time a plugin loads, a tmp file is being generated with a random number. snap-plugin- would be the prefix with which the file is generated. It might as well just be snap-plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a prefix. The method will add a unique identifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so the path for the plugin that's written will be something like:
<TempDirPath>/snap-plugin-<unique identifier>/snap-plugin-<plugin-name>
? And the reason for separate directories per plugin is that multiple plugins might have the same binary name?
control/flags.go
Outdated
flTempDirPath = cli.StringFlag{ | ||
Name: "temp_dir_path", | ||
Usage: "Temporary path for loading plugins", | ||
EnvVar: "TEMP_DIR_PATH", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add SNAP_
to the EnvVar value.
docs/SNAPTELD.md
Outdated
@@ -43,6 +43,7 @@ $ snapteld [global options] command [command options] [arguments...] | |||
--cache-expiration value The time limit for which a metric cache entry is valid (default: 500ms) [$SNAP_CACHE_EXPIRATION] | |||
--control-listen-port value Listen port for control RPC server (default: 8082) [$SNAP_CONTROL_LISTEN_PORT] | |||
--control-listen-addr value Listen address for control RPC server [$SNAP_CONTROL_LISTEN_ADDR] | |||
--temp_dir_path value Temporary path for loading plugins [$TEMP_DIR_PATH] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add SNAP_ to $TEMP_DIR_PATH
a4e63c9
to
57158c8
Compare
57158c8
to
9b06cc8
Compare
LGTM |
Fixes #1494
Summary of changes:
@intelsdi-x/snap-maintainers