Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyring option to vault program to set the CEPH_KEYRING envvar #80

Merged
merged 6 commits into from
Feb 23, 2015
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# 2.6.2

## User interface

* The `CEPH_KEYRING` environment variable no longer needs to be manually
specified; it can be passed in as the `--ceph-keyring` command-line
Copy link
Owner

Choose a reason for hiding this comment

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

Does it need ceph-? We don't make the "user" specify --ceph-username and --ceph-pool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps not. I had it like that originally, can't remember why I changed it. Will update.

option to the `vault` program.

* The unused `Event` type has been removed from the `Vaultaire.Writer`
module.

# 2.6.1

## User interface

To disable profiling, run ``vault --no-profiling``. By default,
profiling is enabled with a period of 1s and an accuracy bound of 2048
telemetric stats per second.
Expand Down
8 changes: 5 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ you want to make the broker highly-available, use a TCP load-balancer).

The defaults assume your Rados pool is called `vaultaire`, and you're
connecting with the username `vaultaire`; if this isn't the case,
override with `-p` and `-u` respectively. In either case, you'll need to
have the environment variable `CEPH_KEYRING` pointing to the correct
place.
override with `-p` and `-u` respectively.

Additionally, if your Ceph keyring is not at the default path used by
librados (`/etc/ceph/keyring` as of Feburary 2015) you'll need to
override it with `-k /path/to/your/keyring/file`.

```
vault -d broker # Start broker in debug mode
Expand Down
40 changes: 29 additions & 11 deletions src/Vault.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Data.Word (Word64)
import Options.Applicative hiding (Parser, option)
import qualified Options.Applicative as O
import System.Directory
import System.Environment
import System.Log.Logger
import Text.Read
import Text.Trifecta
Expand All @@ -30,16 +31,17 @@ import Vaultaire.Program


data Options = Options
{ pool :: String
, user :: String
, broker :: String
, debug :: Bool
, quiet :: Bool
, noprofile :: Bool
, period :: Int
, bound :: Int
, name :: String
, component :: Component }
{ pool :: String
, user :: String
, broker :: String
, debug :: Bool
, quiet :: Bool
, noprofile :: Bool
, period :: Int
, bound :: Int
, name :: String
, ceph_keyring :: String
, component :: Component }

data Component = Broker
| Reader
Expand All @@ -61,6 +63,7 @@ optionsParser Options{..} = Options <$> parsePool
<*> parsePeriod
<*> parseBound
<*> parseName
<*> parseKeyring
<*> parseComponents
where
parsePool = strOption $
Expand Down Expand Up @@ -123,6 +126,13 @@ optionsParser Options{..} = Options <$> parsePool
<> showDefault
<> help "Identifiable name for the daemon. Useful for telemetrics."

parseKeyring = strOption $
long "ceph-keyring"
<> short 'k'
<> metavar "CEPH-KEYRING"
<> value ""
<> help "Path to Ceph keyring file. If set, this will override the CEPH_KEYRING environment variable."

parseComponents = subparser
( parseBrokerComponent
<> parseReaderComponent
Expand Down Expand Up @@ -169,7 +179,7 @@ parseConfig fp = do
else return defaultConfig
where
defaultConfig = Options "vaultaire" "vaultaire" "localhost"
False False False 1000 2048 "" Broker
False False False 1000 2048 "" "" Broker
Copy link
Owner

Choose a reason for hiding this comment

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

That type starts to get ugly in a real program, doesn't it? Oh well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, hard to avoid. Maybe it'd be better split in to one option per line, allowing for inline comments?

mergeConfig ls Options{..} = fromJust $
Options <$> lookup "pool" ls `mplus` pure pool
<*> lookup "user" ls `mplus` pure user
Expand All @@ -180,6 +190,7 @@ parseConfig fp = do
<*> (join $ readMaybe <$> lookup "period" ls) `mplus` pure period
<*> (join $ readMaybe <$> lookup "bound" ls) `mplus` pure period
<*> lookup "name" ls `mplus` pure name
<*> lookup "ceph_keyring" ls `mplus` pure ceph_keyring
<*> pure Broker

configParser :: Parser [(String, String)]
Expand All @@ -196,6 +207,11 @@ possibleKeys =
parseArgsWithConfig :: FilePath -> IO Options
parseArgsWithConfig = parseConfig >=> execParser . helpfulParser

-- If set, override CEPH_KEYRING envvar (used by librados).
updateCephKeyring :: String -> IO ()
updateCephKeyring "" = return ()
updateCephKeyring k = setEnv "CEPH_KEYRING" k

--
-- Main program entry point
--
Expand All @@ -208,6 +224,8 @@ main = do
| quiet = Quiet
| otherwise = Normal

updateCephKeyring ceph_keyring

quit <- initializeProgram (package ++ "-" ++ version) level

-- Run daemon(s, at present just one). These are all expected to fork
Expand Down
2 changes: 1 addition & 1 deletion vaultaire.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: >= 1.10
name: vaultaire
version: 2.6.1.4
version: 2.6.2.0
synopsis: Data vault for metrics
description: Data vault for metrics
license: BSD3
Expand Down