Skip to content

Commit 4f12875

Browse files
authored
[Bugfix] Skip Collection check for missing Database (#1361)
1 parent 2bd002e commit 4f12875

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- (Feature) Add Feature dependency
66
- (Feature) Run secured containers as a feature
77
- (Feature) Expose core.PodSecurityContext Sysctl options
8+
- (Bugfix) Skip Collection check for missing Database
89

910
## [1.2.31](https://github.com/arangodb/kube-arangodb/tree/1.2.31) (2023-07-14)
1011
- (Improvement) Block traffic on the services if there is more than 1 active leader in ActiveFailover mode

pkg/deployment/agency/state/generator_database_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ func (d databaseGenerator) Collection(name string) CollectionGeneratorInterface
6666

6767
func (d databaseGenerator) Add() Generator {
6868
return func(t *testing.T, s *State) {
69+
if s.Plan.Databases == nil {
70+
s.Plan.Databases = map[string]PlanDatabase{}
71+
}
72+
s.Plan.Databases[d.db] = PlanDatabase{}
73+
6974
if s.Plan.Collections == nil {
7075
s.Plan.Collections = PlanCollections{}
7176
}

pkg/deployment/agency/state/state.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ func GetDBServerBlockingRestartShards(s State, serverID Server) CollectionShardD
276276
func FilterDBServerShardRestart(serverID Server) ShardFilter {
277277
return NegateFilter(func(s State, db, col, shard string) bool {
278278
// Filter all shards which are not blocking restart of server
279+
if _, ok := s.Plan.Databases[db]; !ok {
280+
// DB Is missing, restart possible
281+
return true
282+
}
283+
279284
plan := s.Plan.Collections[db][col]
280285
planShard := plan.Shards[shard]
281286

pkg/deployment/agency/state/state_test.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,60 @@ func Test_GetCollectionDatabaseByID(t *testing.T) {
316316
require.False(t, ok)
317317
require.Equal(t, "", v)
318318
}
319+
320+
func Test_MissingDatabaseCase(t *testing.T) {
321+
s := State{
322+
Plan: Plan{
323+
Collections: map[string]PlanDBCollections{
324+
"_system": {
325+
"10013": {
326+
Shards: map[string]Servers{
327+
"s10024": {
328+
"PRMR-1e4bxazq",
329+
"PRMR-rpkgdy5h",
330+
},
331+
},
332+
},
333+
},
334+
"_test": {
335+
"100131": {
336+
Shards: map[string]Servers{
337+
"s100241": {
338+
"PRMR-1e4bxazq",
339+
"PRMR-rpkgdy5h",
340+
},
341+
},
342+
},
343+
},
344+
},
345+
Databases: map[string]PlanDatabase{
346+
"_system": {},
347+
},
348+
},
349+
Current: Current{
350+
Collections: map[string]CurrentDBCollections{
351+
"_system": {
352+
"10013": {
353+
"s10024": {
354+
Servers: Servers{
355+
"PRMR-1e4bxazq",
356+
"PRMR-rpkgdy5h",
357+
},
358+
},
359+
},
360+
},
361+
"_test": {
362+
"100131": {
363+
"s100241": {
364+
Servers: Servers{
365+
"PRMR-1e4bxazq",
366+
},
367+
},
368+
},
369+
},
370+
},
371+
},
372+
}
373+
374+
require.Len(t, GetDBServerBlockingRestartShards(s, "PRMR-1e4bxazq"), 0)
375+
}

0 commit comments

Comments
 (0)