1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Bugfix] Fix ResignJob ID Discovery (#1440)

This commit is contained in:
Adam Janikowski 2023-10-14 21:02:08 +02:00 committed by GitHub
parent 999afcbe89
commit 83c5c83589
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 1564 additions and 16 deletions

View file

@ -12,6 +12,7 @@
- (Bugfix) Fix VersionCheck args propagation
- (Feature) EnforcedResignLeadership action
- (Maintenance) Make scale_down_candidate annotation obsolete
- (Bugfix) Fix ResignJob ID propagation
## [1.2.33](https://github.com/arangodb/kube-arangodb/tree/1.2.33) (2023-09-27)
- (Maintenance) Bump golang.org/x/net to v0.13.0

View file

@ -0,0 +1,35 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package state
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/require"
)
func Test_JobDiscovery(t *testing.T) {
var s DumpState
require.NoError(t, json.Unmarshal(agencyDump310, &s))
require.Len(t, s.Agency.Arango.Target.JobFinished, 2)
}

View file

@ -40,6 +40,9 @@ var agencyDump38 []byte
//go:embed testdata/agency_dump.3.9.json
var agencyDump39 []byte
//go:embed testdata/agency_dump.3.10.json
var agencyDump310 []byte
//go:embed testdata/agency_dump.3.9.satellite.json
var agencyDump39Satellite []byte

File diff suppressed because it is too large Load diff

View file

@ -97,10 +97,6 @@ func (a *actionEnforceResignLeadership) CheckProgress(ctx context.Context) (bool
} else if agencyState.Supervision.Maintenance.Exists() {
a.log.Warn("Maintenance is enabled, skipping action")
// We are done, action cannot be handled on maintenance mode
m.CleanoutJobID = ""
if err := a.actionCtx.UpdateMember(ctx, m); err != nil {
return false, false, errors.WithStack(err)
}
return true, false, nil
} else if isServerRebooted(a.log, a.action, agencyState, driver.ServerID(m.ID)) {
return true, false, nil
@ -108,27 +104,24 @@ func (a *actionEnforceResignLeadership) CheckProgress(ctx context.Context) (bool
// Lets start resign job if required
if j, ok := a.actionCtx.Get(a.action, resignLeadershipJobID); ok && j != "" {
_, jobStatus := agencyState.Target.GetJob(state.JobID(m.CleanoutJobID))
_, jobStatus := agencyState.Target.GetJob(state.JobID(j))
switch jobStatus {
case state.JobPhaseFailed:
m.CleanoutJobID = ""
if err := a.actionCtx.UpdateMember(ctx, m); err != nil {
return false, false, errors.WithStack(err)
}
a.log.Error("Resign server job failed")
// Remove key
a.actionCtx.Add(resignLeadershipJobID, "", true)
return false, false, nil
case state.JobPhaseFinished:
m.CleanoutJobID = ""
if err := a.actionCtx.UpdateMember(ctx, m); err != nil {
return false, false, errors.WithStack(err)
}
a.log.Info("Job finished")
// Remove key
a.actionCtx.Add(resignLeadershipJobID, "", true)
case state.JobPhaseUnknown:
a.log.Str("status", string(jobStatus)).Error("Resign server job unknown status")
return false, false, nil
default:
return false, false, nil
}
// Remove key
a.actionCtx.Add(resignLeadershipJobID, "", true)
// Job is Finished, check if we are not a leader anymore
if agencyState.PlanLeaderServers().Contains(state.Server(m.ID)) {
// We are still a leader!