Skip to content

Commit cf11c26

Browse files
authored
[Bugfix] [Relelase] 1.2.14-preview-1 (#1054)
1 parent a6f2a84 commit cf11c26

File tree

7 files changed

+52
-21
lines changed

7 files changed

+52
-21
lines changed

pkg/apis/deployment/v1/server_group.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ var (
107107
ServerGroupSyncMasters,
108108
ServerGroupSyncWorkers,
109109
}
110+
// AllArangoDServerGroups contains a constant list of all ArangoD server groups
111+
AllArangoDServerGroups = []ServerGroup{
112+
ServerGroupAgents,
113+
ServerGroupSingle,
114+
ServerGroupDBServers,
115+
ServerGroupCoordinators,
116+
}
110117
)
111118

112119
// AsRole returns the "role" value for the given group.

pkg/apis/deployment/v2alpha1/server_group.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ var (
107107
ServerGroupSyncMasters,
108108
ServerGroupSyncWorkers,
109109
}
110+
// AllArangoDServerGroups contains a constant list of all ArangoD server groups
111+
AllArangoDServerGroups = []ServerGroup{
112+
ServerGroupAgents,
113+
ServerGroupSingle,
114+
ServerGroupDBServers,
115+
ServerGroupCoordinators,
116+
}
110117
)
111118

112119
// AsRole returns the "role" value for the given group.

pkg/deployment/access_package.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"strings"
2626
"time"
2727

28-
"gopkg.in/yaml.v3"
28+
"gopkg.in/yaml.v2"
2929
core "k8s.io/api/core/v1"
3030
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3131

pkg/deployment/agency/cache.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ import (
2424
"context"
2525
"sync"
2626

27+
"github.com/rs/zerolog"
28+
2729
"github.com/arangodb/go-driver"
2830
"github.com/arangodb/go-driver/agency"
2931

3032
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
3133
"github.com/arangodb/kube-arangodb/pkg/generated/metric_descriptions"
34+
"github.com/arangodb/kube-arangodb/pkg/logging"
3235
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3336
"github.com/arangodb/kube-arangodb/pkg/util/globals"
3437
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
@@ -164,10 +167,14 @@ func NewCache(namespace, name string, mode *api.DeploymentMode) Cache {
164167
}
165168

166169
func NewAgencyCache(namespace, name string) Cache {
167-
return &cache{
170+
c := &cache{
168171
namespace: namespace,
169172
name: name,
170173
}
174+
175+
c.log = logger.WrapObj(c)
176+
177+
return c
171178
}
172179

173180
func NewSingleCache() Cache {
@@ -197,6 +204,8 @@ func (c cacheSingle) Data() (State, bool) {
197204
type cache struct {
198205
namespace, name string
199206

207+
log logging.Logger
208+
200209
lock sync.RWMutex
201210

202211
valid bool
@@ -208,6 +217,10 @@ type cache struct {
208217
health Health
209218
}
210219

220+
func (c *cache) WrapLogger(in *zerolog.Event) *zerolog.Event {
221+
return in.Str("namespace", c.namespace).Str("name", c.name)
222+
}
223+
211224
func (c *cache) CommitIndex() uint64 {
212225
c.lock.RLock()
213226
defer c.lock.RUnlock()
@@ -238,7 +251,7 @@ func (c *cache) Reload(ctx context.Context, size int, clients map[string]agency.
238251
c.lock.Lock()
239252
defer c.lock.Unlock()
240253

241-
leaderCli, leaderConfig, health, err := getLeader(ctx, size, clients)
254+
leaderCli, leaderConfig, health, err := c.getLeader(ctx, size, clients)
242255
if err != nil {
243256
// Invalidate a leader ID and agency state.
244257
// In the next iteration leaderID will be sat because `valid` will be false.
@@ -258,7 +271,7 @@ func (c *cache) Reload(ctx context.Context, size int, clients map[string]agency.
258271
}
259272

260273
// A leader should be known even if an agency state is invalid.
261-
if data, err := loadState(ctx, leaderCli); err != nil {
274+
if data, err := c.loadState(ctx, leaderCli); err != nil {
262275
c.valid = false
263276
return leaderConfig.CommitIndex, err
264277
} else {
@@ -271,7 +284,7 @@ func (c *cache) Reload(ctx context.Context, size int, clients map[string]agency.
271284

272285
// getLeader returns config and client to a leader agency, and health to check if agencies are on the same page.
273286
// If there is no quorum for the leader then error is returned.
274-
func getLeader(ctx context.Context, size int, clients map[string]agency.Agency) (agency.Agency, *Config, health, error) {
287+
func (c *cache) getLeader(ctx context.Context, size int, clients map[string]agency.Agency) (agency.Agency, *Config, health, error) {
275288
configs := make([]*Config, len(clients))
276289
errs := make([]error, len(clients))
277290
names := make([]string, 0, len(clients))
@@ -324,11 +337,11 @@ func getLeader(ctx context.Context, size int, clients map[string]agency.Agency)
324337
}
325338
}
326339
if err := h.Serving(); err != nil {
327-
logger.Err(err).Warn("Agency Not serving")
340+
c.log.Err(err).Warn("Agency Not serving")
328341
return nil, nil, h, err
329342
}
330343
if err := h.Healthy(); err != nil {
331-
logger.Err(err).Warn("Agency Not healthy")
344+
c.log.Err(err).Debug("Agency Not healthy")
332345
}
333346

334347
for id := range names {

pkg/deployment/agency/state.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3232
)
3333

34-
func loadState(ctx context.Context, client agency.Agency) (State, error) {
34+
func (c *cache) loadState(ctx context.Context, client agency.Agency) (State, error) {
3535
conn := client.Connection()
3636

3737
req, err := client.Connection().NewRequest(http.MethodPost, "/_api/agency/read")
@@ -67,25 +67,17 @@ func loadState(ctx context.Context, client agency.Agency) (State, error) {
6767
return State{}, err
6868
}
6969

70-
var c StateRoots
70+
var r StateRoots
7171

72-
if err := json.Unmarshal(data, &c); err != nil {
72+
if err := json.Unmarshal(data, &r); err != nil {
7373
return State{}, err
7474
}
7575

76-
if len(c) != 1 {
76+
if len(r) != 1 {
7777
return State{}, errors.Newf("Invalid response size")
7878
}
7979

80-
state := c[0].Arango
81-
82-
if _, ok := state.Current.Collections["_system"]; !ok {
83-
return State{}, errors.Newf("Unable to find system database (invalid data)")
84-
}
85-
86-
if _, ok := state.Plan.Collections["_system"]; !ok {
87-
return State{}, errors.Newf("Unable to find system database (invalid data)")
88-
}
80+
state := r[0].Arango
8981

9082
return state, nil
9183
}

pkg/deployment/reconcile/action_backup_restore.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package reconcile
2222

2323
import (
2424
"context"
25+
"time"
2526

2627
"github.com/arangodb/go-driver"
2728

@@ -203,6 +204,16 @@ func (a actionBackupRestore) CheckProgress(ctx context.Context) (bool, bool, err
203204
// Retry
204205
return false, false, nil
205206
}
207+
208+
// Add wait grace period for restore jobs - async job creation is asynchronous
209+
if ok := conn.IsAsyncErrorNotFound(restoreError); ok {
210+
if s := a.action.StartTime; s != nil && !s.Time.IsZero() {
211+
if time.Since(s.Time) < 10*time.Second {
212+
// Retry
213+
return false, false, nil
214+
}
215+
}
216+
}
206217
}
207218

208219
// Restore is done
@@ -214,6 +225,7 @@ func (a actionBackupRestore) CheckProgress(ctx context.Context) (bool, bool, err
214225
}
215226

216227
if restoreError != nil {
228+
a.log.Err(restoreError).Error("Restore failed")
217229
result.State = api.DeploymentRestoreStateRestoreFailed
218230
result.Message = restoreError.Error()
219231
}

pkg/deployment/reconcile/plan_builder_tls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ func (r *Reconciler) createKeyfileRenewalPlanSynced(ctx context.Context, apiObje
292292
member := statusMember.Member
293293

294294
if !plan.IsEmpty() {
295-
return nil
295+
continue
296296
}
297297

298298
cache, ok := planCtx.ACS().ClusterCache(member.ClusterID)

0 commit comments

Comments
 (0)