Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

(SDI-2475) Configure the TempDir where the API loads plugins. #1512

Merged
merged 1 commit into from
Feb 10, 2017

Conversation

rashmigottipati
Copy link
Contributor

Fixes #1494

Summary of changes:

  • Added a configurable flag in snapteld for loading plugins

@intelsdi-x/snap-maintainers

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
Copy link
Collaborator

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.


func WriteFile(filename string, b []byte) (string, error) {
// Create temporary directory
dir, err := ioutil.TempDir(control.GetDefaultConfig().TempDirPath, "snap-plugin-")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the trailing -?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor

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",
Copy link
Collaborator

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]
Copy link
Collaborator

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

@jcooklin
Copy link
Collaborator

LGTM

@rashmigottipati rashmigottipati merged commit 74029be into intelsdi-x:master Feb 10, 2017
@rashmigottipati rashmigottipati deleted the sdi2475 branch February 10, 2017 02:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants