Skip to content

Commit

Permalink
api: put default socket in nri-specific directory.
Browse files Browse the repository at this point in the history
Change default socket path to /var/run/nri/nri.sock. This
should work better for plugins which are run as Kubernetes
daemonsets. With the socket directory bind-mounted instead
of the socket itself, plugins should be able to reconnect
if the runtime is ever restarted.

Additionally, create any missing NRI/socket directory with
0700 rights (rwx for owner only) instead of 0755.

Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub committed Feb 14, 2023
1 parent 807de1e commit d4f68f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/adaptation/adaptation.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func (r *Adaptation) startListener() error {
}

os.Remove(r.socketPath)
if err := os.MkdirAll(filepath.Dir(r.socketPath), 0755); err != nil {
if err := os.MkdirAll(filepath.Dir(r.socketPath), 0700); err != nil {
return fmt.Errorf("failed to create socket %q: %w", r.socketPath, err)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

const (
// DefaultSocketPath is the default socket path for external plugins.
DefaultSocketPath = "/var/run/nri.sock"
DefaultSocketPath = "/var/run/nri/nri.sock"
// PluginSocketEnvVar is used to inform plugins about pre-connected sockets.
PluginSocketEnvVar = "NRI_PLUGIN_SOCKET"
// PluginNameEnvVar is used to inform NRI-launched plugins about their name.
Expand Down

0 comments on commit d4f68f0

Please sign in to comment.