Skip to content

Commit 0a77a17

Browse files
authored
[Bugfix] Agency Cache Reload (#1823)
1 parent 71f3eeb commit 0a77a17

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- (Bugfix) Add missing ArangoDeployment ExternalAccess Managed Type definition
1212
- (Feature) Agency DBServer Discovery
1313
- (Bugfix) Fix Manifests
14+
- (Bugfix) Agency Cache Reload
1415

1516
## [1.2.44](https://github.com/arangodb/kube-arangodb/tree/1.2.44) (2025-02-03)
1617
- (Maintenance) Kubernetes 1.31.1 libraries

pkg/deployment/agency/cache.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -155,6 +155,8 @@ type Cache interface {
155155
Health() (Health, bool)
156156
// ShardsInSyncMap returns last in sync state of shards. If no state is available, false is returned.
157157
ShardsInSyncMap() (state.ShardsSyncStatus, bool)
158+
159+
Invalidate()
158160
}
159161

160162
func NewCache(namespace, name string, mode *api.DeploymentMode) Cache {
@@ -214,6 +216,9 @@ func (c cacheSingle) Data() (state.State, bool) {
214216
return state.State{}, true
215217
}
216218

219+
func (c cacheSingle) Invalidate() {
220+
}
221+
217222
type cache struct {
218223
namespace, name string
219224

@@ -228,6 +233,10 @@ type cache struct {
228233
shardsSyncStatus state.ShardsSyncStatus
229234
}
230235

236+
func (c *cache) Invalidate() {
237+
c.loader.Invalidate()
238+
}
239+
231240
func (c *cache) WrapLogger(in *zerolog.Event) *zerolog.Event {
232241
return in.Str("namespace", c.namespace).Str("name", c.name)
233242
}

pkg/deployment/agency/definitions.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -40,8 +40,10 @@ const (
4040

4141
TargetHotBackupKey = "HotBackup"
4242

43-
PlanCollectionsKey = "Collections"
44-
PlanDatabasesKey = "Databases"
43+
PlanCollectionsKey = "Collections"
44+
PlanDatabasesKey = "Databases"
45+
PlanDBServersKey = "DBServers"
46+
PlanCoordinatorsKey = "Coordinators"
4547

4648
SupervisionKey = "Supervision"
4749
SupervisionMaintenanceKey = "Maintenance"
@@ -74,6 +76,8 @@ func GetAgencyReadRequestFields() ReadRequest {
7476
GetAgencyKey(ArangoKey, SupervisionKey, SupervisionMaintenanceKey),
7577
GetAgencyKey(ArangoKey, PlanKey, PlanCollectionsKey),
7678
GetAgencyKey(ArangoKey, PlanKey, PlanDatabasesKey),
79+
GetAgencyKey(ArangoKey, PlanKey, PlanDBServersKey),
80+
GetAgencyKey(ArangoKey, PlanKey, PlanCoordinatorsKey),
7781
GetAgencyKey(ArangoKey, CurrentKey, PlanCollectionsKey),
7882
GetAgencyKey(ArangoKey, CurrentKey, CurrentServersKnown),
7983
GetAgencyKey(ArangoKey, CurrentKey, CurrentMaintenanceServers),

pkg/deployment/deployment.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -200,7 +200,12 @@ func (d *Deployment) RefreshAgencyCache(ctx context.Context) (uint64, error) {
200200
clients[m.ID] = a
201201
}
202202

203-
return d.agencyCache.Reload(ctx, rsize, clients)
203+
if offset, err := d.agencyCache.Reload(ctx, rsize, clients); err != nil {
204+
d.agencyCache.Invalidate()
205+
return 0, err
206+
} else {
207+
return offset, nil
208+
}
204209
}
205210
}
206211

pkg/logging/logger.go

+5
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ type Logger interface {
259259

260260
Bool(key string, i bool) Logger
261261
Str(key, value string) Logger
262+
JSON(key string, value any) Logger
262263
Strs(key string, values ...string) Logger
263264
SinceStart(key string, start time.Time) Logger
264265
Err(err error) Logger
@@ -395,6 +396,10 @@ func (c *chain) Interface(key string, i interface{}) Logger {
395396
return c.Wrap(Interface(key, i))
396397
}
397398

399+
func (c *chain) JSON(key string, value any) Logger {
400+
return c.Wrap(JSON(key, value))
401+
}
402+
398403
func (c *chain) Err(err error) Logger {
399404
if err == nil {
400405
return c

pkg/logging/wrap.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121
package logging
2222

2323
import (
24+
"encoding/json"
2425
"time"
2526

2627
"github.com/rs/zerolog"
@@ -97,3 +98,13 @@ func Dur(key string, dur time.Duration) Wrap {
9798
return in.Dur(key, dur)
9899
}
99100
}
101+
102+
func JSON(key string, item any) Wrap {
103+
return func(in *zerolog.Event) *zerolog.Event {
104+
data, err := json.Marshal(item)
105+
if err != nil {
106+
return in
107+
}
108+
return in.Str(key, string(data))
109+
}
110+
}

0 commit comments

Comments
 (0)