Skip to content

Commit d752b06

Browse files
authored
Special upgrade without ResignLeadership (#295)
1 parent 9b88a35 commit d752b06

File tree

6 files changed

+71
-22
lines changed

6 files changed

+71
-22
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## [master](https://github.com/arangodb-helper/arangodb/tree/master) (N/A)
44
- Allow to pass environment variables to processes and standardize argument pass (--envs.<group>.<ENV>=<VALUE> and --args.<group>.<ARG>=<VALUE>)
55
- Extend JWT Generator functionality by additional fields
6+
- Do not run ResignLeadership when upgrading from <= 3.6.14 or
7+
3.7 with <= 3.7.12.
68

79
# ArangoDB Starter Changelog Before 0.15.0
810

pkg/definitions/server_type.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ import (
3131
type ServerType string
3232

3333
const (
34-
ServerTypeUnknown = "unknown"
35-
ServerTypeCoordinator = "coordinator"
36-
ServerTypeDBServer = "dbserver"
37-
ServerTypeAgent = "agent"
38-
ServerTypeSingle = "single"
39-
ServerTypeResilientSingle = "resilientsingle"
40-
ServerTypeSyncMaster = "syncmaster"
41-
ServerTypeSyncWorker = "syncworker"
34+
ServerTypeUnknown = "unknown"
35+
ServerTypeCoordinator = "coordinator"
36+
ServerTypeDBServer = "dbserver"
37+
ServerTypeDBServerNoResign = "dbserver_noresign"
38+
ServerTypeAgent = "agent"
39+
ServerTypeSingle = "single"
40+
ServerTypeResilientSingle = "resilientsingle"
41+
ServerTypeSyncMaster = "syncmaster"
42+
ServerTypeSyncWorker = "syncworker"
4243
)
4344

4445
// String returns a string representation of the given ServerType.
@@ -51,7 +52,7 @@ func (s ServerType) PortOffset() int {
5152
switch s {
5253
case ServerTypeCoordinator, ServerTypeSingle, ServerTypeResilientSingle:
5354
return PortOffsetCoordinator
54-
case ServerTypeDBServer:
55+
case ServerTypeDBServer, ServerTypeDBServerNoResign:
5556
return PortOffsetDBServer
5657
case ServerTypeAgent:
5758
return PortOffsetAgent
@@ -93,7 +94,7 @@ func (s ServerType) ExpectedServerRole() (string, string) {
9394
return "SINGLE", ""
9495
case ServerTypeResilientSingle:
9596
return "SINGLE", "resilient"
96-
case ServerTypeDBServer:
97+
case ServerTypeDBServer, ServerTypeDBServerNoResign:
9798
return "PRIMARY", ""
9899
case ServerTypeAgent:
99100
return "AGENT", ""
@@ -111,6 +112,8 @@ func (s ServerType) GetName() string {
111112
return "agent"
112113
case ServerTypeDBServer:
113114
return "dbserver"
115+
case ServerTypeDBServerNoResign:
116+
return "dbserver"
114117
case ServerTypeCoordinator:
115118
return "coordinator"
116119
case ServerTypeSingle, ServerTypeResilientSingle:
@@ -128,6 +131,7 @@ func AllServerTypes() []ServerType {
128131
return []ServerType{
129132
ServerTypeCoordinator,
130133
ServerTypeDBServer,
134+
ServerTypeDBServerNoResign,
131135
ServerTypeAgent,
132136
ServerTypeSingle,
133137
ServerTypeResilientSingle,

service/runtime_server_manager.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,8 @@ func (s *runtimeServerManager) RestartServer(log zerolog.Logger, serverType defi
513513
p = s.agentProc.Process()
514514
case definitions.ServerTypeDBServer:
515515
p = s.dbserverProc.Process()
516+
case definitions.ServerTypeDBServerNoResign:
517+
p = s.dbserverProc.Process()
516518
case definitions.ServerTypeCoordinator:
517519
p = s.coordinatorProc.Process()
518520
case definitions.ServerTypeSingle, definitions.ServerTypeResilientSingle:

service/upgrade_manager.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333

3434
"github.com/arangodb-helper/arangodb/pkg/definitions"
3535

36-
driver "github.com/arangodb/go-driver"
36+
"github.com/arangodb/go-driver"
3737
"github.com/arangodb/go-driver/agency"
3838
upgraderules "github.com/arangodb/go-upgrade-rules"
3939
"github.com/pkg/errors"
@@ -171,10 +171,11 @@ const (
171171
// UpgradePlanEntry is the JSON structure that describes a single entry
172172
// in an upgrade plan.
173173
type UpgradePlanEntry struct {
174-
PeerID string `json:"peer_id"`
175-
Type UpgradeEntryType `json:"type"`
176-
Failures int `json:"failures,omitempty"`
177-
Reason string `json:"reason,omitempty"`
174+
PeerID string `json:"peer_id"`
175+
Type UpgradeEntryType `json:"type"`
176+
Failures int `json:"failures,omitempty"`
177+
Reason string `json:"reason,omitempty"`
178+
WithoutResign bool `json:"withoutResign,omitempty"`
178179
}
179180

180181
// CreateStatusServer creates a UpgradeStatusServer for the given entry.
@@ -255,6 +256,7 @@ func (m *upgradeManager) StartDatabaseUpgrade(ctx context.Context, forceMinorUpg
255256

256257
// Check if we can upgrade from running to binary versions
257258
specialUpgradeFrom346 := false
259+
specialUpgradeFrom3614 := false
258260
rules := upgraderules.CheckUpgradeRules
259261
if forceMinorUpgrade {
260262
rules = upgraderules.CheckSoftUpgradeRules
@@ -267,6 +269,9 @@ func (m *upgradeManager) StartDatabaseUpgrade(ctx context.Context, forceMinorUpg
267269
if from.CompareTo("3.4.6") == 0 {
268270
specialUpgradeFrom346 = true
269271
}
272+
if IsSpecialUpgradeFrom3614(from) {
273+
specialUpgradeFrom3614 = true
274+
}
270275
}
271276

272277
// Fetch mode
@@ -403,8 +408,9 @@ func (m *upgradeManager) StartDatabaseUpgrade(ctx context.Context, forceMinorUpg
403408
for _, p := range config.AllPeers {
404409
if p.HasDBServer() {
405410
plan.Entries = append(plan.Entries, UpgradePlanEntry{
406-
Type: UpgradeEntryTypeDBServer,
407-
PeerID: p.ID,
411+
Type: UpgradeEntryTypeDBServer,
412+
PeerID: p.ID,
413+
WithoutResign: specialUpgradeFrom3614,
408414
})
409415
}
410416
}
@@ -993,7 +999,10 @@ func (m *upgradeManager) processUpgradePlan(ctx context.Context, plan UpgradePla
993999
m.upgradeServerType = definitions.ServerTypeDBServer
9941000
m.updateNeeded = true
9951001
upgrade := func() error {
996-
if err := m.upgradeManagerContext.RestartServer(definitions.ServerTypeDBServer); err != nil {
1002+
if firstEntry.WithoutResign {
1003+
fmt.Printf("Without resign")
1004+
}
1005+
if err := m.upgradeManagerContext.RestartServer(definitions.ServerTypeDBServerNoResign); err != nil {
9971006
return recordFailure(errors.Wrap(err, "Failed to restart dbserver"))
9981007
}
9991008

@@ -1572,3 +1581,9 @@ func (m *upgradeManager) ShowArangodServerVersions(ctx context.Context) (bool, e
15721581

15731582
return len(versions) == 1, nil
15741583
}
1584+
1585+
// IsSpecialUpgradeFrom3614 determines if special case for upgrade is required
1586+
func IsSpecialUpgradeFrom3614(v driver.Version) bool {
1587+
return (v.CompareTo("3.6.0") >= 0 && v.CompareTo("3.6.14") <= 0) ||
1588+
(v.CompareTo("3.7.0") >= 0 && v.CompareTo("3.7.12") <= 0)
1589+
}

test/process_cluster_resign_leadership_test.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import (
3030
"testing"
3131
"time"
3232

33+
"github.com/arangodb-helper/arangodb/service"
34+
3335
"github.com/arangodb-helper/arangodb/client"
3436
"github.com/arangodb/go-driver"
3537
"github.com/pkg/errors"
@@ -80,13 +82,21 @@ func TestProcessClusterResignLeadership(t *testing.T) {
8082
t.Fatal(err.Error())
8183
}
8284

85+
WaitUntilServiceReadyAPI(t, coordinatorClient, ServiceReadyCheckVersion()).ExecuteT(t, 15*time.Second, 500*time.Millisecond)
86+
87+
if version, err := coordinatorClient.Version(context.Background()); err != nil {
88+
t.Fatal(err.Error())
89+
} else {
90+
t.Log("Found version: ", version.Version)
91+
if service.IsSpecialUpgradeFrom3614(version.Version) {
92+
t.Skipf("ResignLeadership wont work in case when Maintenance is enabled")
93+
}
94+
}
95+
8396
databaseName := "_system"
8497
collectionName := "test"
8598

86-
WaitUntilServiceReadyAPI(t, coordinatorClient, func(t *testing.T, ctx context.Context, c driver.Client) error {
87-
_, err := coordinatorClient.Database(context.Background(), databaseName)
88-
return err
89-
}).ExecuteT(t, 15*time.Second, 500*time.Millisecond)
99+
WaitUntilServiceReadyAPI(t, coordinatorClient, ServiceReadyCheckDatabase(databaseName)).ExecuteT(t, 15*time.Second, 500*time.Millisecond)
90100

91101
database, err := coordinatorClient.Database(context.Background(), databaseName)
92102
if err != nil {

test/util.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,22 @@ func WaitUntilServiceReady(t *testing.T, c driver.Client, checkFunc ServiceReady
265265
}
266266
}
267267

268+
// ServiceReadyCheckVersion checks if version can be fetched
269+
func ServiceReadyCheckVersion() ServiceReadyCheckFunc {
270+
return func(t *testing.T, ctx context.Context, c driver.Client) error {
271+
_, err := c.Version(ctx)
272+
return err
273+
}
274+
}
275+
276+
// ServiceReadyCheckDatabase checks if database info can be fetched
277+
func ServiceReadyCheckDatabase(databaseName string) ServiceReadyCheckFunc {
278+
return func(t *testing.T, ctx context.Context, c driver.Client) error {
279+
_, err := c.Database(ctx, databaseName)
280+
return err
281+
}
282+
}
283+
268284
func WaitForHttpPortClosed(log Logger, throttle Throttle, url string) TimeoutFunc {
269285
return func() error {
270286
_, err := http.Get(url)

0 commit comments

Comments
 (0)