Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time

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.9) and install it on your system.
  2. Setup the GOPATH environment.
  3. Run $ go get -d
    This will just download the source and not build it. The downloaded source will be at $GOPATH/src/
  4. Fork the glusterd2 repo on Github.
  5. Add your fork as a git remote:
    $ git remote add fork<your-github-username>/glusterd2
  6. Run $ ./scripts/

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 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.

If you are planning on making a large set of changes or a major architectural change it is often desirable to first build a consensus in an issue discussion and/or create an initial design doc PR. Once the design has been agreed upon one or more PRs implementing the plan can be made.

Review Process: Once your PR has has been submitted for review the following critieria will need to be met before it will be merged:

  • Each PR needs reviews accepting the change from at least two developers for merging
    • It is common to request reviews from those reviewers automatically suggested by github
  • Each PR needs to have been open for at least 24 working hours to allow for community feedback
    • The 24 working hours counts hours occuring Mon-Fri in the local timezone of the submitter
  • Each PR must be fully updated to master and tests must have passed

When the criteria are met a project maintainer can merge your changes into the project's master branch.

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=""

Connecting to external etcd cluster:

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

etcdendpoints = ""
noembed = true

Generating REST API documentation:

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

You should commit the generated file doc/

Setup tracing:

Tracing glusterd2 operations is accomplished using OpenCensus Go, which is a Go implementation of OpenCensus. The tracing implementation uses Jaeger as the backend to export tracing data. The Jaeger UI can then be used to visualize the captured traces.

Run the following steps to setup and view tracing using Jaeger. Note that the steps outlined below is a quick way to setup and view traces for debugging GD2 without attaching a backing store to the Jaeger service.

  1. Prior to starting GD2 on any node, start the Jaeger service either on your local machine or on a server/VM. The Jaeger service can be started either as a standalone service or within a container using an available docker image.
  • Standalone service: See the "Running Individual Jaeger Components" section in the Getting Started page of Jaeger documentation.

  • Docker Image: For quick local testing, an all-in-one docker image can be used which launches the Jaeger UI, query and agent. This image comes with an in-memory storage component. For example, the following command starts the all-in-one docker image with the required services,

$ docker run -d -p 6831:6831/udp -p 6832:6832/udp -p 5778:5778 -p 16686:16686 -p 14268:14268 jaegertracing/all-in-one:latest

NOTE: The Jaeger agent runs on port 6831/6832. The Jaeger collector runs on port 14268. The Jaeger query service runs on port 16686 on which the UI can be accessed. Ensure that firewalld is configured (or stopped) to let traffic on the Jaeger specific ports.

  1. Start GD2 process on the gluster nodes and provide the Jaeger endpoints either within the config file using the --config option or pass the endpoints as separate options. For the Jaeger service to capture traces, the Jaeger agent endpoint and the Jaeger collector endpoint are necessary. The following outlines both the ways,
  • Config File: Add the following to your startup config (for e.g. conf.toml) file on each node.
...(existing options)
jaeger-endpoint = ""
jaeger-agent-endpoint = ""

Start GD2 as usual on each node. For e.g.,

$./glusterd2 --config conf.toml

NOTE: Change the IP address based on your configuration.

  • Start-up Option: Provide the Jaeger endpoints as options to glusterd2 start-up command in case you don't wish to provide it in the config file. For e.g., the example below shows the options passed to glusterd2. NOTE: Provide the options for all the nodes in your gluster cluster.
$./glusterd2 --config conf.toml --jaeger-endpoint --jaeger-agent-endpoint
  1. Verify that on start-up, GD2 was successfully able to connect to the Jaeger endpoints by looking for the following GD2 start-up log message,
INFO[2018-07-25 13:24:55.174171] tracing: Registered opencensus jaeger exporter for traces and stats  jaegerAgentEndpoint="" jaegerEndpoint="" source="[tracing.go:67:tracing.InitJaegerExporter]"

NOTE: In case of any warning or error message, verify firewalld settings and the status of Jaeger services.

  1. Execute the intended GD2 operation (for e.g. volume create) and view the traces on the Jaeger UI by navigating to the endpoint. For e.g. if the Jaeger service was started locally, then navigate to http://localhost:16686. An example of how a trace looks like for a replica 3 volume create transaction is shown in this github issue.