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

Commit

Permalink
Merge branch 'master' of https://github.com/gluster/glusterd2 into group
Browse files Browse the repository at this point in the history
  • Loading branch information
rishubhjain committed May 23, 2018
2 parents 62273e4 + 7dd66b8 commit 8ad368d
Show file tree
Hide file tree
Showing 28 changed files with 255 additions and 73 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ endpoints.json
generate-doc
# Ignore vi backup files
*~
# Generated by Make
glusterd2/paths_config.go
22 changes: 15 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DEPENV ?=
PLUGINS ?= yes
FASTBUILD ?= yes

.PHONY: all build check check-go check-reqs install vendor-update vendor-install verify release check-protoc $(GD2_BIN) $(GD2_BUILD) $(CLI_BIN) $(CLI_BUILD) cli $(GD2_CONF) gd2conf test dist dist-vendor functest
.PHONY: all build check check-go check-reqs install vendor-update vendor-install verify release check-protoc $(GD2_BIN) $(GD2_BUILD) $(CLI_BIN) $(CLI_BUILD) cli $(GD2_CONF) gd2conf test dist dist-vendor functest generated

all: build

Expand All @@ -49,8 +49,16 @@ check-reqs:
@./scripts/check-reqs.sh
@echo

$(GD2_BIN): $(GD2_BUILD)
$(GD2_BUILD):
generated:
@echo "Generating sources..."
@PREFIX=$(PREFIX) BASE_PREFIX=$(BASE_PREFIX) EXEC_PREFIX=$(EXEC_PREFIX) \
BINDIR=$(BINDIR) SBINDIR=$(SBINDIR) DATADIR=$(DATADIR) \
LOCALSTATEDIR=$(LOCALSTATEDIR) LOGDIR=$(LOGDIR) \
SYSCONFDIR=$(SYSCONFDIR) ./scripts/prepare_path_config.sh glusterd2


$(GD2_BIN): $(GD2_BUILD) gd2conf generated
$(GD2_BUILD): generated
@PLUGINS=$(PLUGINS) FASTBUILD=$(FASTBUILD) ./scripts/build.sh glusterd2
@echo

Expand Down Expand Up @@ -82,17 +90,17 @@ vendor-install:
@$(DEPENV) dep ensure
@echo

test: check-reqs
test: check-reqs generated
@./test.sh $(TESTOPTIONS)

functest: check-reqs
functest: check-reqs generated
@go test ./e2e -v -functest

release: build
@./scripts/release.sh

dist:
@./scripts/dist.sh
@DISTDIR=$(DISTDIR) SIGN=$(SIGN) ./scripts/dist.sh

dist-vendor: vendor-install
@VENDOR=yes ./scripts/dist.sh
@VENDOR=yes DISTDIR=$(DISTDIR) SIGN=$(SIGN) ./scripts/dist.sh
3 changes: 2 additions & 1 deletion doc/endpoints.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions e2e/config/1.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
workdir = "w1"
localstatedir = "w1"
logdir = "w1/log"
loglevel = "DEBUG"
rundir = "w1/run/gluster"
logfile = "w1.log"
peeraddress = "127.0.0.1:24008"
Expand Down
3 changes: 3 additions & 0 deletions e2e/config/2.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
workdir = "w2"
localstatedir = "w2"
logdir = "w2/log"
loglevel = "DEBUG"
rundir = "w2/run/gluster"
logfile = "w2.log"
peeraddress = "127.0.0.1:23008"
Expand Down
3 changes: 3 additions & 0 deletions e2e/config/3.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
workdir = "w3"
localstatedir = "w3"
logdir = "w3/log"
loglevel = "DEBUG"
rundir = "w3/run/gluster"
logfile = "w3.log"
peeraddress = "127.0.0.1:22008"
Expand Down
3 changes: 3 additions & 0 deletions e2e/config/4.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
workdir = "w4"
localstatedir = "w4"
logdir = "w4/log"
loglevel = "DEBUG"
rundir = "w4/run/gluster"
logfile = "w4.log"
peeraddress = "127.0.0.1:21008"
Expand Down
2 changes: 1 addition & 1 deletion e2e/glustershd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestGlusterShd(t *testing.T) {
vol1, err := client.VolumeCreate(reqVol)
r.Nil(err)

r.Nil(client.VolumeStart(vol1.Name), "volume start failed")
r.Nil(client.VolumeStart(vol1.Name, false), "volume start failed")

err = client.GlusterShdEnable(vol1.Name)
r.Nil(err)
Expand Down
2 changes: 1 addition & 1 deletion e2e/quota_enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func testQuotaEnable(t *testing.T) {
vol1, err := client.VolumeCreate(reqVol)
r.Nil(err)

r.Nil(client.VolumeStart(vol1.Name), "volume start failed")
r.Nil(client.VolumeStart(vol1.Name, false), "volume start failed")

err = client.QuotaEnable(volname)
r.Nil(err)
Expand Down
10 changes: 7 additions & 3 deletions e2e/volume_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ func testVolumeCreate(t *testing.T) {
}
_, err := client.VolumeCreate(createReq)
r.Nil(err)

//invalid volume name
createReq.Name = "##@@#@!#@!!@#"
_, err = client.VolumeCreate(createReq)
r.NotNil(err)
}

func testVolumeExpand(t *testing.T) {
Expand Down Expand Up @@ -139,8 +144,7 @@ func testVolumeDelete(t *testing.T) {

func testVolumeStart(t *testing.T) {
r := require.New(t)

r.Nil(client.VolumeStart(volname), "volume start failed")
r.Nil(client.VolumeStart(volname, false), "volume start failed")
}

func testVolumeStop(t *testing.T) {
Expand Down Expand Up @@ -428,7 +432,7 @@ func testDisperse(t *testing.T) {
_, err := client.VolumeCreate(createReq)
r.Nil(err)

r.Nil(client.VolumeStart(disperseVolName), "disperse volume start failed")
r.Nil(client.VolumeStart(disperseVolName, true), "disperse volume start failed")

mntPath, err := ioutil.TempDir(tmpDir, "mnt")
r.Nil(err)
Expand Down
13 changes: 9 additions & 4 deletions extras/make/paths.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
# https://fedoraproject.org/wiki/Packaging:RPMMacros?rd=Packaging/RPMMacros

PREFIX ?= /usr/local

BASE_PREFIX = $(PREFIX)
ifeq ($(PREFIX), /usr)
BASE_PREFIX = ""
endif

EXEC_PREFIX ?= $(PREFIX)

BINDIR ?= $(EXEC_PREFIX)/bin
SBINDIR ?= $(EXEC_PREFIX)/sbin

DATADIR ?= $(PREFIX)/share
LOCALSTATEDIR ?= $(PREFIX)/var/lib
LOGDIR ?= $(PREFIX)/var/log

SYSCONFDIR ?= $(PREFIX)/etc
LOCALSTATEDIR ?= $(BASE_PREFIX)/var/lib
LOGDIR ?= $(BASE_PREFIX)/var/log

SYSCONFDIR ?= $(BASE_PREFIX)/etc
81 changes: 81 additions & 0 deletions extras/nightly-rpms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

# This scripts builds RPMs from the current git head.
# The script needs be run from the root of the repository
# NOTE: RPMs are built only for EL7 (CentOS7) distributions.

set -e

##
## Set up build environment
##
RESULTDIR=${RESULTDIR:-$PWD/rpms}
BUILDDIR=$PWD/$(mktemp -d nightlyrpmXXXXXX)

BASEDIR=$(dirname "$0")
GD2CLONE=$(realpath "$BASEDIR/..")

yum -y install make mock rpm-build golang

export GOPATH=$BUILDDIR/go
mkdir -p "$GOPATH"/{bin,pkg,src}
export PATH=$GOPATH/bin:$PATH

GD2SRC=$GOPATH/src/github.com/gluster/glusterd2
mkdir -p "$GOPATH/src/github.com/gluster"
ln -s "$GD2CLONE" "$GD2SRC"

"$GD2SRC/scripts/install-reqs.sh"

##
## Prepare GD2 archives and specfile for building RPMs
##
pushd "$GD2SRC"

VERSION=$(./scripts/pkg-version --version)
RELEASE=$(./scripts/pkg-version --release)
FULL_VERSION=$(./scripts/pkg-version --full)

# Create a vendored dist archive
DISTDIR=$BUILDDIR SIGN=no make dist-vendor

# Copy over specfile to the BUILDDIR and modify it to use the current Git HEAD versions
cp ./extras/rpms/* "$BUILDDIR"

popd #GD2SRC

pushd "$BUILDDIR"

DISTARCHIVE="glusterd2-$FULL_VERSION-vendor.tar.xz"
SPEC=glusterd2.spec
sed -i -E "
# Use bundled always
s/with_bundled 0/with_bundled 1/;
# Replace version with HEAD version
s/^Version:[[:space:]]+([0-9]+\\.)*[0-9]+$/Version: $VERSION/;
# Replace release with proper release
s/^Release:[[:space:]]+.*%\\{\\?dist\\}/Release: $RELEASE%{?dist}/;
# Replace Source0 with generated archive
s/^Source0:[[:space:]]+.*-vendor.tar.xz/Source0: $DISTARCHIVE/;
# Change prep setup line to use correct release
s/^(%setup -q -n %\\{name\\}-v%\\{version\\}-)(0)/\\1$RELEASE/;
" $SPEC

##
## Build the RPMs
##

# Create SRPM
mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
cp "$DISTARCHIVE" glusterd2-logrotate rpmbuild/SOURCES
cp $SPEC rpmbuild/SPECS
SRPM=$(rpmbuild --define "_topdir $PWD/rpmbuild" -bs rpmbuild/SPECS/$SPEC | cut -d\ -f2)

# Build RPM from SRPM using mock
mkdir -p "$RESULTDIR"
mock -r epel-7-x86_64 --resultdir="$RESULTDIR" --rebuild "$SRPM"

popd #BUILDDIR

## Cleanup
rm -rf "$BUILDDIR"
4 changes: 2 additions & 2 deletions extras/rpms/glusterd2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
%global gd2make %{__make} PREFIX=%{_prefix} EXEC_PREFIX=%{_exec_prefix} BINDIR=%{_bindir} SBINDIR=%{_sbindir} DATADIR=%{_datadir} LOCALSTATEDIR=%{_sharedstatedir} LOGDIR=%{_localstatedir}/log SYSCONFDIR=%{_sysconfdir} FASTBUILD=off

Name: %{repo}
Version: 4.0.0
Release: 2%{?dist}
Version: 4.1.0
Release: dev%{?dist}
Summary: The GlusterFS management daemon (preview)
License: GPLv2 or LGPLv3+
URL: https://%{provider_prefix}
Expand Down
2 changes: 1 addition & 1 deletion glustercli/cmd/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ var volumeStartCmd = &cobra.Command{
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
volname := cmd.Flags().Args()[0]
err := client.VolumeStart(volname)
err := client.VolumeStart(volname, flagStartCmdForce)
if err != nil {
if verbose {
log.WithFields(log.Fields{
Expand Down
1 change: 1 addition & 0 deletions glusterd2/commands/volumes/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (c *Command) Routes() route.Routes {
Method: "POST",
Pattern: "/volumes/{volname}/start",
Version: 1,
RequestType: utils.GetTypeString((*api.VolumeStartReq)(nil)),
ResponseType: utils.GetTypeString((*api.VolumeStartResp)(nil)),
HandlerFunc: volumeStartHandler},
route.Route{
Expand Down
11 changes: 9 additions & 2 deletions glusterd2/commands/volumes/volume-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"net/http"
"path/filepath"
"regexp"

"github.com/gluster/glusterd2/glusterd2/events"
"github.com/gluster/glusterd2/glusterd2/gdctx"
Expand All @@ -16,10 +17,16 @@ import (
"github.com/pborman/uuid"
)

var (
reg = regexp.MustCompile("^[a-zA-Z0-9_-]+$")
)

func validateVolCreateReq(req *api.VolCreateReq) error {

if req.Name == "" {
return gderrors.ErrEmptyVolName
valid := reg.MatchString(req.Name)

if !valid {
return gderrors.ErrInvalidVolName
}

if req.Transport != "" && req.Transport != "tcp" && req.Transport != "rdma" {
Expand Down
11 changes: 10 additions & 1 deletion glusterd2/commands/volumes/volume-start.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func startAllBricks(c transaction.TxnCtx) error {
}).Info("Starting brick")

if err := b.StartBrick(); err != nil {
if err == errors.ErrProcessAlreadyRunning {
continue
}
return err
}
}
Expand Down Expand Up @@ -68,6 +71,12 @@ func volumeStartHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
logger := gdctx.GetReqLogger(ctx)
volname := mux.Vars(r)["volname"]
var req api.VolumeStartReq

if err := restutils.UnmarshalRequest(r, &req); err != nil {
restutils.SendHTTPError(ctx, w, http.StatusBadRequest, err)
return
}

lock, unlock := transaction.CreateLockFuncs(volname)
// Taking a lock outside the txn as volinfo.Nodes() must also
Expand All @@ -92,7 +101,7 @@ func volumeStartHandler(w http.ResponseWriter, r *http.Request) {
return
}

if volinfo.State == volume.VolStarted {
if volinfo.State == volume.VolStarted && !req.ForceStartBricks {
restutils.SendHTTPError(ctx, w, http.StatusBadRequest, errors.ErrVolAlreadyStarted)
return
}
Expand Down
Loading

0 comments on commit 8ad368d

Please sign in to comment.