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

Abort reconcilientation plan on failed cleanout server #171

Merged
merged 6 commits into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from 5 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
50 changes: 27 additions & 23 deletions deps/github.com/arangodb/go-driver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,9 @@ else ifeq ("$(TEST_AUTH)", "jwt")
ARANGOARGS := --server.jwt-secret=/jwtsecret
endif

ifeq ("$(TEST_MODE)", "single")
TEST_NET := container:$(DBCONTAINER)
TEST_ENDPOINTS := http://localhost:8529
else
TEST_NET := container:$(TESTCONTAINER)-ns
TEST_ENDPOINTS := http://localhost:7001
TESTS := $(REPOPATH)/test
TEST_NET := container:$(TESTCONTAINER)-ns
TEST_ENDPOINTS := http://localhost:7001
TESTS := $(REPOPATH)/test
ifeq ("$(TEST_AUTH)", "rootpw")
CLUSTERENV := JWTSECRET=testing
TEST_AUTHENTICATION := basic:root:
Expand All @@ -77,7 +73,6 @@ ifeq ("$(TEST_SSL)", "auto")
CLUSTERENV := SSL=auto $(CLUSTERENV)
TEST_ENDPOINTS = https://localhost:7001
endif
endif

ifeq ("$(TEST_CONNECTION)", "vst")
TESTS := $(REPOPATH)/test
Expand Down Expand Up @@ -133,13 +128,13 @@ run-tests-http: $(GOBUILDDIR)
# Single server tests
run-tests-single: run-tests-single-json run-tests-single-vpack run-tests-single-vst-1.0 $(VST11_SINGLE_TESTS)

run-tests-single-json: run-tests-single-json-with-auth run-tests-single-json-no-auth
run-tests-single-json: run-tests-single-json-with-auth run-tests-single-json-no-auth run-tests-single-json-ssl

run-tests-single-vpack: run-tests-single-vpack-with-auth run-tests-single-vpack-no-auth
run-tests-single-vpack: run-tests-single-vpack-with-auth run-tests-single-vpack-no-auth run-tests-single-vpack-ssl

run-tests-single-vst-1.0: run-tests-single-vst-1.0-with-auth run-tests-single-vst-1.0-no-auth
run-tests-single-vst-1.0: run-tests-single-vst-1.0-with-auth run-tests-single-vst-1.0-no-auth run-tests-single-vst-1.0-ssl

run-tests-single-vst-1.1: run-tests-single-vst-1.1-with-auth run-tests-single-vst-1.1-jwt-auth run-tests-single-vst-1.1-no-auth
run-tests-single-vst-1.1: run-tests-single-vst-1.1-with-auth run-tests-single-vst-1.1-jwt-auth run-tests-single-vst-1.1-no-auth run-tests-single-vst-1.1-ssl run-tests-single-vst-1.1-jwt-ssl

run-tests-single-json-no-auth:
@echo "Single server, HTTP+JSON, no authentication"
Expand Down Expand Up @@ -177,6 +172,26 @@ run-tests-single-vst-1.1-jwt-auth:
@echo "Single server, Velocystream 1.1, JWT authentication"
@${MAKE} TEST_MODE="single" TEST_AUTH="jwt" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests

run-tests-single-json-ssl:
@echo "Single server, HTTP+JSON, with authentication, SSL"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONTENT_TYPE="json" __run_tests

run-tests-single-vpack-ssl:
@echo "Single server, HTTP+Velocypack, with authentication, SSL"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONTENT_TYPE="vpack" __run_tests

run-tests-single-vst-1.0-ssl:
@echo "Single server, Velocystream 1.0, with authentication, SSL"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONNECTION="vst" TEST_CVERSION="1.0" __run_tests

run-tests-single-vst-1.1-ssl:
@echo "Single server, Velocystream 1.1, with authentication, SSL"
@${MAKE} TEST_MODE="single" TEST_AUTH="rootpw" TEST_SSL="auto" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests

run-tests-single-vst-1.1-jwt-ssl:
@echo "Single server, Velocystream 1.1, JWT authentication, SSL"
@${MAKE} TEST_MODE="single" TEST_AUTH="jwt" TEST_SSL="auto" TEST_CONNECTION="vst" TEST_CVERSION="1.1" __run_tests

# ResilientSingle server tests
run-tests-resilientsingle: run-tests-resilientsingle-json run-tests-resilientsingle-vpack run-tests-resilientsingle-vst-1.0 $(VST11_RESILIENTSINGLE_TESTS)

Expand Down Expand Up @@ -310,25 +325,14 @@ else
ifdef JWTSECRET
echo "$JWTSECRET" > "${JWTSECRETFILE}"
endif
ifeq ("$(TEST_MODE)", "single")
@-docker rm -f -v $(DBCONTAINER) $(TESTCONTAINER) &> /dev/null
docker run -d --name $(DBCONTAINER) \
$(ARANGOENV) $(ARANGOVOL) \
$(ARANGODB) --log.level requests=debug --log.use-microtime true $(ARANGOARGS)
else
@-docker rm -f -v $(TESTCONTAINER) &> /dev/null
@TESTCONTAINER=$(TESTCONTAINER) ARANGODB=$(ARANGODB) STARTER=$(STARTER) STARTERMODE=$(TEST_MODE) TMPDIR=${GOBUILDDIR} $(CLUSTERENV) $(ROOTDIR)/test/cluster.sh start
endif
endif

__test_cleanup:
@docker rm -f -v $(TESTCONTAINER) &> /dev/null
ifndef TEST_ENDPOINTS_OVERRIDE
ifeq ("$(TEST_MODE)", "single")
@docker rm -f -v $(DBCONTAINER) &> /dev/null
else
@TESTCONTAINER=$(TESTCONTAINER) ARANGODB=$(ARANGODB) STARTER=$(STARTER) STARTERMODE=$(TEST_MODE) $(ROOTDIR)/test/cluster.sh cleanup
endif
endif
@sleep 3

Expand Down
13 changes: 12 additions & 1 deletion deps/github.com/arangodb/go-driver/cluster_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ type cleanOutServerRequest struct {
Server string `json:"server"`
}

type cleanOutServerResponse struct {
JobID string `json:"id"`
}

// CleanOutServer triggers activities to clean out a DBServers.
func (c *cluster) CleanOutServer(ctx context.Context, serverID string) error {
req, err := c.conn.NewRequest("POST", "_admin/cluster/cleanOutServer")
Expand All @@ -135,14 +139,21 @@ func (c *cluster) CleanOutServer(ctx context.Context, serverID string) error {
if _, err := req.SetBody(input); err != nil {
return WithStack(err)
}
applyContextSettings(ctx, req)
cs := applyContextSettings(ctx, req)
resp, err := c.conn.Do(ctx, req)
if err != nil {
return WithStack(err)
}
if err := resp.CheckStatus(200, 202); err != nil {
return WithStack(err)
}
var result cleanOutServerResponse
if err := resp.ParseBody("", &result); err != nil {
return WithStack(err)
}
if cs.JobIDResponse != nil {
*cs.JobIDResponse = result.JobID
}
return nil
}

Expand Down
15 changes: 15 additions & 0 deletions deps/github.com/arangodb/go-driver/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const (
keyFollowLeaderRedirect ContextKey = "arangodb-followLeaderRedirect"
keyDBServerID ContextKey = "arangodb-dbserverID"
keyBatchID ContextKey = "arangodb-batchID"
keyJobIDResponse ContextKey = "arangodb-jobIDResponse"
)

// WithRevision is used to configure a context to make document
Expand Down Expand Up @@ -213,6 +214,13 @@ func WithBatchID(parent context.Context, id string) context.Context {
return context.WithValue(contextOrBackground(parent), keyBatchID, id)
}

// WithJobIDResponse is used to configure a context that includes a reference to a JobID
// that is filled on a error-free response.
// This is used in cluster functions.
func WithJobIDResponse(parent context.Context, jobID *string) context.Context {
return context.WithValue(contextOrBackground(parent), keyJobIDResponse, jobID)
}

type contextSettings struct {
Silent bool
WaitForSync bool
Expand All @@ -229,6 +237,7 @@ type contextSettings struct {
FollowLeaderRedirect *bool
DBServerID string
BatchID string
JobIDResponse *string
}

// applyContextSettings returns the settings configured in the context in the given request.
Expand Down Expand Up @@ -356,6 +365,12 @@ func applyContextSettings(ctx context.Context, req Request) contextSettings {
result.BatchID = id
}
}
// JobIDResponse
if v := ctx.Value(keyJobIDResponse); v != nil {
if idRef, ok := v.(*string); ok {
result.JobIDResponse = idRef
}
}
return result
}

Expand Down
25 changes: 19 additions & 6 deletions deps/github.com/arangodb/go-driver/cursor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ package driver

import (
"context"
"encoding/json"
"path"
"reflect"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -165,12 +167,23 @@ func (c *cursor) ReadDocument(ctx context.Context, result interface{}) (Document
}
c.resultIndex++
var meta DocumentMeta
if err := c.conn.Unmarshal(*c.Result[index], &meta); err != nil {
// If a cursor returns something other than a document, this will fail.
// Just ignore it.
}
if err := c.conn.Unmarshal(*c.Result[index], result); err != nil {
return DocumentMeta{}, WithStack(err)
resultPtr := c.Result[index]
if resultPtr == nil {
// Got NULL result
rv := reflect.ValueOf(result)
if rv.Kind() != reflect.Ptr || rv.IsNil() {
return DocumentMeta{}, WithStack(&json.InvalidUnmarshalError{Type: reflect.TypeOf(result)})
}
e := rv.Elem()
e.Set(reflect.Zero(e.Type()))
} else {
if err := c.conn.Unmarshal(*resultPtr, &meta); err != nil {
// If a cursor returns something other than a document, this will fail.
// Just ignore it.
}
if err := c.conn.Unmarshal(*resultPtr, result); err != nil {
return DocumentMeta{}, WithStack(err)
}
}
return meta, nil
}
Expand Down
Loading