diff --git a/doc/quick-start-user-guide.md b/doc/quick-start-user-guide.md index 0eb85dc70..cf369d38a 100644 --- a/doc/quick-start-user-guide.md +++ b/doc/quick-start-user-guide.md @@ -51,15 +51,15 @@ $ mkdir -p /var/lib/gd2 ``` **Create a config file:** This is optional but if your VM/machine has multiple network interfaces, it is recommended to create a config file. The config file location can be passed to Glusterd2 using the `--config` option. -Glusterd2 will also pick up conf files named `glusterd.{yaml|json|toml}` if available in `/etc/glusterd2/` or the current directory. - -```yaml -$ cat conf.yaml -workdir: "/var/lib/gd2" -peeraddress: "192.168.56.101:24008" -clientaddress: "192.168.56.101:24007" -etcdcurls: "http://192.168.56.101:2379" -etcdpurls: "http://192.168.56.101:2380" +Glusterd2 will also pick up conf file named `glusterd2.toml` if available in `/etc/glusterd2/` or the current directory. + +```toml +$ cat conf.toml +workdir = "/var/lib/gd2" +peeraddress = "192.168.56.101:24008" +clientaddress = "192.168.56.101:24007" +etcdcurls = "http://192.168.56.101:2379" +etcdpurls = "http://192.168.56.101:2380" ``` Replace the IP address accordingly on each node. @@ -67,13 +67,13 @@ Replace the IP address accordingly on each node. **Start glusterd2 process:** Glusterd2 is not a daemon and currently can run only in the foreground. ```sh -# ./glusterd2 --config conf.yaml +# ./glusterd2 --config conf.toml ``` You will see an output similar to the following: ```log INFO[2017-08-28T16:03:58+05:30] Starting GlusterD pid=1650 -INFO[2017-08-28T16:03:58+05:30] loaded configuration from file file=conf.yaml +INFO[2017-08-28T16:03:58+05:30] loaded configuration from file file=conf.toml INFO[2017-08-28T16:03:58+05:30] Generated new UUID uuid=19db62df-799b-47f1-80e4-0f5400896e05 INFO[2017-08-28T16:03:58+05:30] started muxsrv listener INFO[2017-08-28T16:03:58+05:30] Started GlusterD ReST server ip:port=192.168.56.101:24007 diff --git a/e2e/config/1.toml b/e2e/config/1.toml new file mode 100644 index 000000000..8fc57e142 --- /dev/null +++ b/e2e/config/1.toml @@ -0,0 +1,6 @@ +workdir = "/tmp/gd2_func_test/w1" +logfile = "w1.log" +peeraddress = "127.0.0.1:24008" +clientaddress = "127.0.0.1:24007" +etcdcurls = "http://127.0.0.1:2479" +etcdpurls = "http://127.0.0.1:2480" diff --git a/e2e/config/1.yaml b/e2e/config/1.yaml deleted file mode 100644 index c169d7b2a..000000000 --- a/e2e/config/1.yaml +++ /dev/null @@ -1,6 +0,0 @@ -workdir: "/tmp/gd2_func_test/w1" -logfile: "w1.log" -peeraddress: "127.0.0.1:24008" -clientaddress: "127.0.0.1:24007" -etcdcurls: "http://127.0.0.1:2479" -etcdpurls: "http://127.0.0.1:2480" diff --git a/e2e/config/2.toml b/e2e/config/2.toml new file mode 100644 index 000000000..4d855d1a0 --- /dev/null +++ b/e2e/config/2.toml @@ -0,0 +1,6 @@ +workdir = "/tmp/gd2_func_test/w2" +logfile = "w2.log" +peeraddress = "127.0.0.1:23008" +clientaddress = "127.0.0.1:23007" +etcdcurls = "http://127.0.0.1:2379" +etcdpurls = "http://127.0.0.1:2380" diff --git a/e2e/config/2.yaml b/e2e/config/2.yaml deleted file mode 100644 index a501ddd98..000000000 --- a/e2e/config/2.yaml +++ /dev/null @@ -1,6 +0,0 @@ -workdir: "/tmp/gd2_func_test/w2" -logfile: "w2.log" -peeraddress: "127.0.0.1:23008" -clientaddress: "127.0.0.1:23007" -etcdcurls: "http://127.0.0.1:2379" -etcdpurls: "http://127.0.0.1:2380" diff --git a/e2e/config/3.toml b/e2e/config/3.toml new file mode 100644 index 000000000..b81b2274b --- /dev/null +++ b/e2e/config/3.toml @@ -0,0 +1,6 @@ +workdir = "/tmp/gd2_func_test/w3" +logfile = "w3.log" +peeraddress = "127.0.0.1:22008" +clientaddress = "127.0.0.1:22007" +etcdcurls = "http://127.0.0.1:2279" +etcdpurls = "http://127.0.0.1:2280" diff --git a/e2e/config/3.yaml b/e2e/config/3.yaml deleted file mode 100644 index 304af145e..000000000 --- a/e2e/config/3.yaml +++ /dev/null @@ -1,6 +0,0 @@ -workdir: "/tmp/gd2_func_test/w3" -logfile: "w3.log" -peeraddress: "127.0.0.1:22008" -clientaddress: "127.0.0.1:22007" -etcdcurls: "http://127.0.0.1:2279" -etcdpurls: "http://127.0.0.1:2280" diff --git a/e2e/config/4.toml b/e2e/config/4.toml new file mode 100644 index 000000000..1ff40e84b --- /dev/null +++ b/e2e/config/4.toml @@ -0,0 +1,7 @@ +workdir = "/tmp/gd2_func_test/w4" +logfile = "w4.log" +peeraddress = "127.0.0.1:21008" +clientaddress = "127.0.0.1:21007" +etcdcurls = "http://127.0.0.1:2179" +etcdpurls = "http://127.0.0.1:2180" +restauth = true diff --git a/e2e/config/4.yaml b/e2e/config/4.yaml deleted file mode 100644 index 45b43d756..000000000 --- a/e2e/config/4.yaml +++ /dev/null @@ -1,7 +0,0 @@ -workdir: "/tmp/gd2_func_test/w4" -logfile: "w4.log" -peeraddress: "127.0.0.1:21008" -clientaddress: "127.0.0.1:21007" -etcdcurls: "http://127.0.0.1:2179" -etcdpurls: "http://127.0.0.1:2180" -restauth: true diff --git a/e2e/georep_test.go b/e2e/georep_test.go index 8ad4309e5..c5eaaba33 100644 --- a/e2e/georep_test.go +++ b/e2e/georep_test.go @@ -13,7 +13,7 @@ import ( func TestGeorepCreateDelete(t *testing.T) { r := require.New(t) - gds, err := setupCluster("./config/1.yaml", "./config/2.yaml") + gds, err := setupCluster("./config/1.toml", "./config/2.toml") r.Nil(err) defer teardownCluster(gds) diff --git a/e2e/glustershd_test.go b/e2e/glustershd_test.go index 90d2356af..e8dcc0734 100644 --- a/e2e/glustershd_test.go +++ b/e2e/glustershd_test.go @@ -13,7 +13,7 @@ func TestGlusterShd(t *testing.T) { r := require.New(t) - gds, err := setupCluster("./config/1.yaml", "./config/2.yaml") + gds, err := setupCluster("./config/1.toml", "./config/2.toml") r.Nil(err) defer teardownCluster(gds) diff --git a/e2e/peer_ops_test.go b/e2e/peer_ops_test.go index 69d2011f0..4d55864dd 100644 --- a/e2e/peer_ops_test.go +++ b/e2e/peer_ops_test.go @@ -10,19 +10,19 @@ import ( func TestAddRemovePeer(t *testing.T) { r := require.New(t) - g1, err := spawnGlusterd("./config/1.yaml", true) + g1, err := spawnGlusterd("./config/1.toml", true) r.Nil(err) defer g1.Stop() defer g1.EraseWorkdir() r.True(g1.IsRunning()) - g2, err := spawnGlusterd("./config/2.yaml", true) + g2, err := spawnGlusterd("./config/2.toml", true) r.Nil(err) defer g2.Stop() defer g2.EraseWorkdir() r.True(g2.IsRunning()) - g3, err := spawnGlusterd("./config/3.yaml", true) + g3, err := spawnGlusterd("./config/3.toml", true) r.Nil(err) defer g3.Stop() defer g3.EraseWorkdir() diff --git a/e2e/quota_enable.go b/e2e/quota_enable.go index 2dcf50752..1490dced8 100644 --- a/e2e/quota_enable.go +++ b/e2e/quota_enable.go @@ -16,7 +16,7 @@ func testQuotaEnable(t *testing.T) { var err error r := require.New(t) - gds, err := setupCluster("./config/1.yaml", "./config/2.yaml") + gds, err := setupCluster("./config/1.toml", "./config/2.toml") r.Nil(err) defer teardownCluster(gds) diff --git a/e2e/restapi_auth_test.go b/e2e/restapi_auth_test.go index daf8e556c..9851e933e 100644 --- a/e2e/restapi_auth_test.go +++ b/e2e/restapi_auth_test.go @@ -12,7 +12,7 @@ import ( func TestRESTAPIAuth(t *testing.T) { r := require.New(t) - g1, err := spawnGlusterd("./config/4.yaml", true) + g1, err := spawnGlusterd("./config/4.toml", true) r.Nil(err) defer g1.Stop() defer g1.EraseWorkdir() diff --git a/e2e/restart_test.go b/e2e/restart_test.go index 1331201b7..3761dc393 100644 --- a/e2e/restart_test.go +++ b/e2e/restart_test.go @@ -13,7 +13,7 @@ import ( func TestRestart(t *testing.T) { r := require.New(t) - gd, err := spawnGlusterd("./config/1.yaml", true) + gd, err := spawnGlusterd("./config/1.toml", true) r.Nil(err) r.True(gd.IsRunning()) @@ -42,7 +42,7 @@ func TestRestart(t *testing.T) { r.Nil(gd.Stop()) - gd, err = spawnGlusterd("./config/1.yaml", false) + gd, err = spawnGlusterd("./config/1.toml", false) r.Nil(err) r.True(gd.IsRunning()) diff --git a/e2e/utils_test.go b/e2e/utils_test.go index cdd52820a..de8092844 100644 --- a/e2e/utils_test.go +++ b/e2e/utils_test.go @@ -15,14 +15,15 @@ import ( "github.com/gluster/glusterd2/pkg/api" "github.com/gluster/glusterd2/pkg/restclient" - "gopkg.in/yaml.v2" + + toml "github.com/pelletier/go-toml" ) type gdProcess struct { Cmd *exec.Cmd - ClientAddress string `yaml:"clientaddress"` - PeerAddress string `yaml:"peeraddress"` - Workdir string `yaml:"workdir"` + ClientAddress string `toml:"clientaddress"` + PeerAddress string `toml:"peeraddress"` + Workdir string `toml:"workdir"` uuid string } @@ -98,7 +99,7 @@ func spawnGlusterd(configFilePath string, cleanStart bool) (*gdProcess, error) { } g := gdProcess{} - if err = yaml.Unmarshal(fContent, &g); err != nil { + if err = toml.Unmarshal(fContent, &g); err != nil { return nil, err } diff --git a/e2e/volume_ops_test.go b/e2e/volume_ops_test.go index 564cc0db4..467a526f3 100644 --- a/e2e/volume_ops_test.go +++ b/e2e/volume_ops_test.go @@ -31,7 +31,7 @@ func TestVolume(t *testing.T) { r := require.New(t) - gds, err = setupCluster("./config/1.yaml", "./config/2.yaml") + gds, err = setupCluster("./config/1.toml", "./config/2.toml") r.Nil(err) defer teardownCluster(gds) @@ -192,7 +192,7 @@ func TestVolumeOptions(t *testing.T) { r := require.New(t) - gds, err := setupCluster("./config/1.yaml") + gds, err := setupCluster("./config/1.toml") r.Nil(err) defer teardownCluster(gds) diff --git a/extras/systemd/glusterd2.service b/extras/systemd/glusterd2.service index 8287d68fd..962278e39 100644 --- a/extras/systemd/glusterd2.service +++ b/extras/systemd/glusterd2.service @@ -6,7 +6,7 @@ Before=network-online.target Conflicts=glusterd.service [Service] -ExecStart=/usr/sbin/glusterd2 +ExecStart=/usr/sbin/glusterd2 --config=/etc/glusterd2/glusterd2.toml KillMode=process [Install] diff --git a/glusterd2/config.go b/glusterd2/config.go index bd4829175..209b6ddb2 100644 --- a/glusterd2/config.go +++ b/glusterd2/config.go @@ -44,7 +44,7 @@ func parseFlags() { flag.String("workdir", "", "Working directory for GlusterD. (default: current directory)") flag.String("localstatedir", "", "Directory to store local state information. (default: workdir)") flag.String("rundir", "", "Directory to store runtime data. (default: workdir/run)") - flag.String("config", "", "Configuration file for GlusterD. By default looks for glusterd2.(yaml|toml|json) in [/usr/local]/etc/glusterd2 and current working directory.") + flag.String("config", "", "Configuration file for GlusterD. By default looks for glusterd2.toml in [/usr/local]/etc/glusterd2 and current working directory.") flag.String(logging.DirFlag, "", logging.DirHelp+" (default: workdir/log)") flag.String(logging.FileFlag, "STDOUT", logging.FileHelp) @@ -135,6 +135,9 @@ func initConfig(confFile string) error { // If a config file was given, read in configration from that file. // If the file is not present panic. + // Limit config to toml only to avoid confusion with multiple config types + config.SetConfigType("toml") + if confFile == "" { config.SetConfigName(defaultConfName) for _, p := range defaultConfPaths { @@ -148,7 +151,7 @@ func initConfig(confFile string) error { if confFile == "" { log.WithFields(log.Fields{ "paths": defaultConfPaths, - "config": defaultConfName + ".(toml|yaml|json)", + "config": defaultConfName + ".toml", "error": err, }).Debug("failed to read any config files, continuing with defaults") } else { diff --git a/scripts/gen-gd2conf.sh b/scripts/gen-gd2conf.sh index df2abe3b0..0da6990fd 100755 --- a/scripts/gen-gd2conf.sh +++ b/scripts/gen-gd2conf.sh @@ -4,10 +4,12 @@ PREFIX=${PREFIX:-/usr/local} DATADIR=${DATADIR:-$PREFIX/share} LOCALSTATEDIR=${LOCALSTATEDIR:-$PREFIX/var/lib} LOGDIR=${LOGDIR:-$PREFIX/var/log} +RUNDIR=${RUNDIR:-$PREFIX/var/run} GD2="glusterd2" GD2STATEDIR=${GD2STATEDIR:-$LOCALSTATEDIR/$GD2} GD2LOGDIR=${GD2LOGDIR:-$LOGDIR/$GD2} +GD2RUNDIR=${GD2RUNDIR:-$RUNDIR/$GD2} OUTDIR=${1:-build} mkdir -p $OUTDIR @@ -19,4 +21,5 @@ cat >$OUTPUT <