Sensu-go: Default agent cache directory doesn't exist on macOS

Created on 27 Sep 2018  路  5Comments  路  Source: sensu/sensu-go

Expected Behavior

Sensu agent uses a reasonable default cache directory for each platform

Current Behavior

Sensu agent uses /var/cache/sensu, but fails to create the directory on macOS because /var/cache doesn't exist.

Possible Solution

Create a macOS specific default path in path.go e.g. /Library/Caches/sensu.

Steps to Reproduce (for bugs)

  1. Start sensu-agent on macOS with the default cache directory (omit --cache-dir from CLI and cache-dir from agent config.
  2. Attempt to run a check on the agent with an asset.

Context

Brought up by a user in #sensu2 community slack.

Your Environment

  • macOS 10.13.6
  • Latest sensu nightly as of September 18th.
bug

Most helpful comment

This will happen on all platforms when trying to run the binary as a non-root user without installing sensu-agent via packages.

@grepory has previously suggested making path defaults relative to the directory in which sensu-agent is run from. For example:

Running sensu-agent from ~/test/ would create ~/test/cache/sensu.

System-level path defaults can instead be specified in config files and loaded with the -c flag.

All 5 comments

This will happen on all platforms when trying to run the binary as a non-root user without installing sensu-agent via packages.

@grepory has previously suggested making path defaults relative to the directory in which sensu-agent is run from. For example:

Running sensu-agent from ~/test/ would create ~/test/cache/sensu.

System-level path defaults can instead be specified in config files and loaded with the -c flag.

That please.

Is there an issue already created for switching to relative paths? If not, I can create one.

I've added the macOS specific cache directory (/Library/Caches) as part of #2132. It may not be the full solution we want, but it does make sensu-agent on macOS less broken. Would you be willing to accept this PR as a step in the right direction?

I don't believe that an issue has been created yet.

I'd like to hold off on changing the defaults until we have a finalized solution. The reason being that it's an additional location to worry about manually cleaning up when we implement relative paths.

You should be able to specify the cache dir when you start sensu-agent (e.g. sensu-agent start --cache-dir /tmp). Will this work for you for the interim?

That's a fair point from the cleanup perspective. Manually specifying a --cache-dir is what I suggested to our user in #sensu2. I'll remove the path change from the PR.

Was this page helpful?
0 / 5 - 0 ratings