Skip to content

Commit 89b2105

Browse files
committed
[Bugfix] Agency Cache Reload
1 parent 71f3eeb commit 89b2105

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
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

+9
Original file line numberDiff line numberDiff line change
@@ -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/deployment.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -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/deployment/reconcile/action_enforce_resign_leadership.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727

2828
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
2929
"github.com/arangodb/kube-arangodb/pkg/deployment/agency/state"
30-
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3130
"github.com/arangodb/kube-arangodb/pkg/util/globals"
3231
)
3332

@@ -142,15 +141,15 @@ func (a *actionEnforceResignLeadership) CheckProgress(ctx context.Context) (bool
142141
client, err := a.actionCtx.GetMembersState().State().GetDatabaseClient()
143142
if err != nil {
144143
a.log.Err(err).Error("Unable to get client")
145-
return false, false, errors.WithStack(err)
144+
return false, false, nil
146145
}
147146

148147
ctxChild, cancel := globals.GetGlobalTimeouts().ArangoD().WithTimeout(ctx)
149148
defer cancel()
150149
cluster, err := client.Cluster(ctxChild)
151150
if err != nil {
152151
a.log.Err(err).Error("Unable to get cluster client")
153-
return false, false, errors.WithStack(err)
152+
return false, false, nil
154153
}
155154

156155
var jobID string
@@ -160,7 +159,7 @@ func (a *actionEnforceResignLeadership) CheckProgress(ctx context.Context) (bool
160159
a.log.Debug("Temporary shutdown, resign leadership")
161160
if err := cluster.ResignServer(jobCtx, m.ID); err != nil {
162161
a.log.Err(err).Debug("Failed to resign server")
163-
return false, false, errors.WithStack(err)
162+
return false, false, nil
164163
}
165164

166165
a.actionCtx.Add(resignLeadershipJobID, jobID, true)

0 commit comments

Comments
 (0)