1
0
mirror of https://github.com/gluster/glusterd2.git synced 2026-02-05 21:45:43 +01:00
Files
glusterd2/doc/development-guide.md
Madhu Rajanna 45a6981d47 replace [] with "" in etcdctl command
Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
2018-05-04 16:40:54 +05:30

3.4 KiB

New to Go?

Glusterd2 is written in Go and if you are new to the language, it is highly encouraged to:

Development Workflow

Workspace and repository setup

  1. Download Go (>=1.8) and install it on your system.
  2. Setup the GOPATH environment.
  3. Run $ go get -d github.com/gluster/glusterd2
    This will just download the source and not build it. The downloaded source will be at $GOPATH/src/github.com/gluster/glusterd2
  4. Fork the glusterd2 repo on Github.
  5. Add your fork as a git remote:
    $ git remote add fork https://github.com/<your-github-username>/glusterd2
  6. Run $ ./scripts/install-reqs.sh

Editors: Our favorite editor is vim with the vim-go plugin, but there are many others like vscode.

Building Glusterd2

To build Glusterd2 run:
$ make

The built binary will be present under build/ directory.

or to install run:
$ make install

The built binary will be installed under $GOPATH/bin/ directory.

Code contribution workflow

Glusterd2 repository currently follows GitHub's Fork & Pull workflow for code contributions.

Please read the coding guidelines document before submitting a PR.

Here is a short guide on how to work on a new patch. In this example, we will work on a patch called hellopatch:

  1. $ git checkout master
  2. $ git pull
  3. $ git checkout -b hellopatch

Do your work here and commit.

Run the test suite, which includes linting checks, static code check, and unit tests:

$ make tests

You will need to provide unit tests and functional tests for your changes wherever applicable. Ensure that the tests pass with your changes. The functional tests needs to be run as root user. To run the functional tests:

# make functest

Once you are ready to push, you will type the following:

$ git push fork hellopatch

Creating A Pull Request:
When you are satisfied with your changes, you will then need to go to your repo in GitHub.com and create a pull request for your branch. Automated tests will be run against the pull request. Your pull request will be reviewed and merged.

Troubleshooting and Debugging

Dumping etcd key and values:

Download etcdctl binary from etcd releases. Run the following command to dump all keys and values in etcd to stdout. Replace endpoints argument to point to etcd client URL if etcd is running on a different ip and port.

ETCDCTL_API=3 etcdctl get --prefix=true "" --endpoints="127.0.0.1:2379"

Connecting to external etcd cluster:

Edit glusterd2.toml config option and add noembed option with specifying the etcd endpoint:

etcdendpoints = "http://127.0.0.1:2379"
noembed = true

Generating REST API documentation:

$ curl -o endpoints.json -s -X GET http://127.0.0.1:24007/endpoints
$ go build pkg/tools/generate-doc.go
$ ./generate-doc

You should commit the generated file doc/endpoints.md