Skip to content

Commit 90455e4

Browse files
committed
Merge branch 'feature/upgrade-plan' into feature/storage-engine-changes
2 parents c9b5eba + 7bb1ee9 commit 90455e4

File tree

11 files changed

+858
-217
lines changed

11 files changed

+858
-217
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ifdef TRAVIS
5858
echo Using IP=$(IP)
5959
endif
6060

61-
TEST_TIMEOUT := 20m
61+
TEST_TIMEOUT := 25m
6262

6363
BINNAME := arangodb$(GOEXE)
6464
BIN := $(BINDIR)/$(GOOS)/$(GOARCH)/$(BINNAME)

client/api.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,18 @@ type API interface {
5151
Shutdown(ctx context.Context, goodbye bool) error
5252

5353
// StartDatabaseUpgrade is called to start the upgrade process
54-
StartDatabaseUpgrade(ctx context.Context, force bool) error
54+
StartDatabaseUpgrade(ctx context.Context) error
5555

5656
// RetryDatabaseUpgrade resets a failure mark in the existing upgrade plan
5757
// such that the starters will retry the upgrade once more.
5858
RetryDatabaseUpgrade(ctx context.Context) error
5959

60+
// AbortDatabaseUpgrade removes the existing upgrade plan.
61+
// Note that Starters working on an entry of the upgrade
62+
// will finish that entry.
63+
// If there is no plan, a NotFoundError will be returned.
64+
AbortDatabaseUpgrade(ctx context.Context) error
65+
6066
// Status returns the status of any upgrade plan
6167
UpgradeStatus(context.Context) (UpgradeStatus, error)
6268
}
@@ -134,6 +140,10 @@ type UpgradeStatus struct {
134140
Failed bool `json:"failed"`
135141
// Reasons contains a human readable description of the state
136142
Reason string `json:"reason,omitempty"`
143+
// FromVersions contains all database versions found that will be upgraded.
144+
FromVersions []driver.Version `json:"from_versions"`
145+
// ToVersion contains the database version that will be upgraded to.
146+
ToVersion driver.Version `json:"to_version"`
137147
// ServersUpgraded contains the servers that have been upgraded
138148
ServersUpgraded []UpgradeStatusServer `json:"servers_upgraded"`
139149
// ServersRemaining contains the servers that have not yet been upgraded

client/client.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,8 @@ func (c *client) Shutdown(ctx context.Context, goodbye bool) error {
199199
}
200200

201201
// StartDatabaseUpgrade is called to start the upgrade process
202-
func (c *client) StartDatabaseUpgrade(ctx context.Context, force bool) error {
203-
q := url.Values{}
204-
if force {
205-
q.Set("force", "true")
206-
}
207-
url := c.createURL("/database-auto-upgrade", q)
202+
func (c *client) StartDatabaseUpgrade(ctx context.Context) error {
203+
url := c.createURL("/database-auto-upgrade", nil)
208204

209205
req, err := http.NewRequest("POST", url, nil)
210206
if err != nil {
@@ -247,6 +243,31 @@ func (c *client) RetryDatabaseUpgrade(ctx context.Context) error {
247243
return nil
248244
}
249245

246+
// AbortDatabaseUpgrade removes the existing upgrade plan.
247+
// Note that Starters working on an entry of the upgrade
248+
// will finish that entry.
249+
// If there is no plan, a NotFoundError will be returned.
250+
func (c *client) AbortDatabaseUpgrade(ctx context.Context) error {
251+
url := c.createURL("/database-auto-upgrade", nil)
252+
253+
req, err := http.NewRequest("DELETE", url, nil)
254+
if err != nil {
255+
return maskAny(err)
256+
}
257+
if ctx != nil {
258+
req = req.WithContext(ctx)
259+
}
260+
resp, err := c.client.Do(req)
261+
if err != nil {
262+
return maskAny(err)
263+
}
264+
if err := c.handleResponse(resp, "DELETE", url, nil); err != nil {
265+
return maskAny(err)
266+
}
267+
268+
return nil
269+
}
270+
250271
// Status returns the status of any upgrade plan
251272
func (c *client) UpgradeStatus(ctx context.Context) (UpgradeStatus, error) {
252273
url := c.createURL("/database-auto-upgrade", nil)

client/error.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ type ErrorResponse struct {
8181
Error string
8282
}
8383

84+
// IsNotFound returns true if the given error is caused by a NotFoundError.
85+
func IsNotFound(err error) bool {
86+
return IsStatusErrorWithCode(err, http.StatusNotFound)
87+
}
88+
8489
// IsServiceUnavailable returns true if the given error is caused by a ServiceUnavailableError.
8590
func IsServiceUnavailable(err error) bool {
8691
return IsStatusErrorWithCode(err, http.StatusServiceUnavailable)
@@ -101,6 +106,11 @@ func IsInternalServer(err error) bool {
101106
return IsStatusErrorWithCode(err, http.StatusInternalServerError)
102107
}
103108

109+
// NewNotFoundError creates a not found error with given message.
110+
func NewNotFoundError(msg string) error {
111+
return StatusError{StatusCode: http.StatusNotFound, message: msg}
112+
}
113+
104114
// NewServiceUnavailableError creates a service unavailable error with given message.
105115
func NewServiceUnavailableError(msg string) error {
106116
return StatusError{StatusCode: http.StatusServiceUnavailable, message: msg}

0 commit comments

Comments
 (0)