mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Do not remove Agency members (#535)
This commit is contained in:
parent
d8c9f5a536
commit
397712df50
4 changed files with 54 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
|
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
|
||||||
|
- Prevent Agency Members recreation
|
||||||
- Added Customizable Volumes and VolumeMounts for ArangoDB server container
|
- Added Customizable Volumes and VolumeMounts for ArangoDB server container
|
||||||
- Added MemoryOverride flag for ArangoDB >= 3.6.3
|
- Added MemoryOverride flag for ArangoDB >= 3.6.3
|
||||||
- Improved Rotation discovery process
|
- Improved Rotation discovery process
|
||||||
|
|
|
@ -63,7 +63,7 @@ func (a *actionRecreateMember) Start(ctx context.Context) (bool, error) {
|
||||||
_, err := a.actionCtx.GetPvc(m.PersistentVolumeClaimName)
|
_, err := a.actionCtx.GetPvc(m.PersistentVolumeClaimName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if kubeErrors.IsNotFound(err) {
|
if kubeErrors.IsNotFound(err) {
|
||||||
return false, fmt.Errorf("PVC is missing %s. DBServer wont be recreated without old PV", m.PersistentVolumeClaimName)
|
return false, fmt.Errorf("PVC is missing %s. Members won't be recreated without old PV", m.PersistentVolumeClaimName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false, maskAny(err)
|
return false, maskAny(err)
|
||||||
|
|
|
@ -155,15 +155,20 @@ func createPlan(log zerolog.Logger, apiObject k8sutil.APIObject,
|
||||||
// Everything is fine, proceed
|
// Everything is fine, proceed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch group {
|
||||||
|
case api.ServerGroupAgents:
|
||||||
|
// For agents just recreate member do not rotate ID, do not remove PVC or service
|
||||||
|
memberLog.Msg("Restoring old member. For agency members recreation of PVC is not supported - to prevent DataLoss")
|
||||||
|
plan = append(plan,
|
||||||
|
api.NewAction(api.ActionTypeRecreateMember, group, m.ID))
|
||||||
|
default:
|
||||||
memberLog.Msg("Creating member replacement plan because member has failed")
|
memberLog.Msg("Creating member replacement plan because member has failed")
|
||||||
newID := ""
|
|
||||||
if group == api.ServerGroupAgents {
|
|
||||||
newID = m.ID // Agents cannot (yet) be replaced with new IDs
|
|
||||||
}
|
|
||||||
plan = append(plan,
|
plan = append(plan,
|
||||||
api.NewAction(api.ActionTypeRemoveMember, group, m.ID),
|
api.NewAction(api.ActionTypeRemoveMember, group, m.ID),
|
||||||
api.NewAction(api.ActionTypeAddMember, group, newID),
|
api.NewAction(api.ActionTypeAddMember, group, ""),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
|
@ -681,7 +681,7 @@ func TestCreatePlan(t *testing.T) {
|
||||||
ExpectedLog: "Creating rotation plan",
|
ExpectedLog: "Creating rotation plan",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Member in failed state",
|
Name: "Agent in failed state",
|
||||||
context: &testContext{
|
context: &testContext{
|
||||||
ArangoDeployment: deploymentTemplate.DeepCopy(),
|
ArangoDeployment: deploymentTemplate.DeepCopy(),
|
||||||
},
|
},
|
||||||
|
@ -690,10 +690,46 @@ func TestCreatePlan(t *testing.T) {
|
||||||
Count: util.NewInt(2),
|
Count: util.NewInt(2),
|
||||||
}
|
}
|
||||||
ad.Status.Members.Agents[0].Phase = api.MemberPhaseFailed
|
ad.Status.Members.Agents[0].Phase = api.MemberPhaseFailed
|
||||||
|
ad.Status.Members.Agents[0].ID = "id"
|
||||||
},
|
},
|
||||||
ExpectedPlan: []api.Action{
|
ExpectedPlan: []api.Action{
|
||||||
api.NewAction(api.ActionTypeRemoveMember, api.ServerGroupAgents, ""),
|
api.NewAction(api.ActionTypeRecreateMember, api.ServerGroupAgents, "id"),
|
||||||
api.NewAction(api.ActionTypeAddMember, api.ServerGroupAgents, ""),
|
},
|
||||||
|
ExpectedLog: "Restoring old member. For agency members recreation of PVC is not supported - to prevent DataLoss",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "Coordinator in failed state",
|
||||||
|
context: &testContext{
|
||||||
|
ArangoDeployment: deploymentTemplate.DeepCopy(),
|
||||||
|
},
|
||||||
|
Helper: func(ad *api.ArangoDeployment) {
|
||||||
|
ad.Spec.Coordinators = api.ServerGroupSpec{
|
||||||
|
Count: util.NewInt(2),
|
||||||
|
}
|
||||||
|
ad.Status.Members.Coordinators[0].Phase = api.MemberPhaseFailed
|
||||||
|
ad.Status.Members.Coordinators[0].ID = "id"
|
||||||
|
},
|
||||||
|
ExpectedPlan: []api.Action{
|
||||||
|
api.NewAction(api.ActionTypeRemoveMember, api.ServerGroupCoordinators, "id"),
|
||||||
|
api.NewAction(api.ActionTypeAddMember, api.ServerGroupCoordinators, ""),
|
||||||
|
},
|
||||||
|
ExpectedLog: "Creating member replacement plan because member has failed",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "DBServer in failed state",
|
||||||
|
context: &testContext{
|
||||||
|
ArangoDeployment: deploymentTemplate.DeepCopy(),
|
||||||
|
},
|
||||||
|
Helper: func(ad *api.ArangoDeployment) {
|
||||||
|
ad.Spec.DBServers = api.ServerGroupSpec{
|
||||||
|
Count: util.NewInt(2),
|
||||||
|
}
|
||||||
|
ad.Status.Members.DBServers[0].Phase = api.MemberPhaseFailed
|
||||||
|
ad.Status.Members.DBServers[0].ID = "id"
|
||||||
|
},
|
||||||
|
ExpectedPlan: []api.Action{
|
||||||
|
api.NewAction(api.ActionTypeRemoveMember, api.ServerGroupDBServers, "id"),
|
||||||
|
api.NewAction(api.ActionTypeAddMember, api.ServerGroupDBServers, ""),
|
||||||
},
|
},
|
||||||
ExpectedLog: "Creating member replacement plan because member has failed",
|
ExpectedLog: "Creating member replacement plan because member has failed",
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue