Skip to content

Commit d166397

Browse files
[Improvement] GT-228 Add new field to CR for more precise calculation of DC2DC replication progress (#1239)
1 parent 0abdeed commit d166397

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- (Maintenance) Change MD content injection method
2121
- (Maintenance) Generate README Platforms
2222
- (Improvement) Cleanout calculation - picks members with the lowest number of shards
23+
- (Improvement) Add new field to CR for more precise calculation of DC2DC replication progress
2324

2425
## [1.2.24](https://github.com/arangodb/kube-arangodb/tree/1.2.24) (2023-01-25)
2526
- (Bugfix) Fix deployment creation on ARM64

pkg/apis/replication/v1/database_synchronization_status.go

Lines changed: 3 additions & 1 deletion
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-2023 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.
@@ -22,8 +22,10 @@ package v1
2222

2323
// DatabaseSynchronizationStatus contains the synchronization status of replication for database
2424
type DatabaseSynchronizationStatus struct {
25+
// Deprecated
2526
// ShardsTotal shows how many shards are expected to be in-sync
2627
ShardsTotal int `json:"shards-total"`
28+
// Deprecated
2729
// ShardsInSync shows how many shards are already in-sync
2830
ShardsInSync int `json:"shards-in-sync"`
2931
// Errors contains a list of errors if there were unexpected errors during synchronization

pkg/apis/replication/v1/synchronization_status.go

Lines changed: 7 additions & 4 deletions
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-2023 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.
@@ -24,7 +24,10 @@ package v1
2424
type SynchronizationStatus struct {
2525
// Databases holds the synchronization status for each database.
2626
Databases map[string]DatabaseSynchronizationStatus `json:"databases,omitempty"`
27-
// AllInSync is true if all shards listed in 'databases' are in sync
28-
AllInSync bool `json:"allInSync,omitempty"`
29-
Error string `json:"error,omitempty"`
27+
// Progress the value in percents showing the progress of synchronization
28+
Progress float32 `json:"progress,omitempty"`
29+
// AllInSync is true if target cluster is fully in-sync with source cluster
30+
AllInSync bool `json:"allInSync,omitempty"`
31+
// Error contains an error description if there is an error preventing synchronization
32+
Error string `json:"error,omitempty"`
3033
}

pkg/apis/replication/v2alpha1/database_synchronization_status.go

Lines changed: 3 additions & 1 deletion
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-2023 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.
@@ -22,8 +22,10 @@ package v2alpha1
2222

2323
// DatabaseSynchronizationStatus contains the synchronization status of replication for database
2424
type DatabaseSynchronizationStatus struct {
25+
// Deprecated
2526
// ShardsTotal shows how many shards are expected to be in-sync
2627
ShardsTotal int `json:"shards-total"`
28+
// Deprecated
2729
// ShardsInSync shows how many shards are already in-sync
2830
ShardsInSync int `json:"shards-in-sync"`
2931
// Errors contains a list of errors if there were unexpected errors during synchronization

pkg/apis/replication/v2alpha1/synchronization_status.go

Lines changed: 7 additions & 4 deletions
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-2023 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.
@@ -24,7 +24,10 @@ package v2alpha1
2424
type SynchronizationStatus struct {
2525
// Databases holds the synchronization status for each database.
2626
Databases map[string]DatabaseSynchronizationStatus `json:"databases,omitempty"`
27-
// AllInSync is true if all shards listed in 'databases' are in sync
28-
AllInSync bool `json:"allInSync,omitempty"`
29-
Error string `json:"error,omitempty"`
27+
// Progress the value in percents showing the progress of synchronization
28+
Progress float32 `json:"progress,omitempty"`
29+
// AllInSync is true if target cluster is fully in-sync with source cluster
30+
AllInSync bool `json:"allInSync,omitempty"`
31+
// Error contains an error description if there is an error preventing synchronization
32+
Error string `json:"error,omitempty"`
3033
}

pkg/replication/sync_inspector.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,15 @@ func (dr *DeploymentReplication) hasOutgoingEndpoint(status client.SyncInfo, epS
242242
func (dr *DeploymentReplication) inspectIncomingSynchronizationStatus(destStatus client.SyncInfo) api.SynchronizationStatus {
243243
const maxReportedIncomingSyncErrorsPerDatabase = 10
244244

245+
var totalShardsFromStatus, shardsInSync int
245246
dbs := make(map[string]api.DatabaseSynchronizationStatus, 0)
246247
for _, s := range destStatus.Shards {
247248
db := dbs[s.Database]
248249
db.ShardsTotal++
250+
totalShardsFromStatus++
249251
if s.Status == client.SyncStatusRunning {
250252
db.ShardsInSync++
253+
shardsInSync++
251254
} else if s.Status == client.SyncStatusFailed && len(db.Errors) < maxReportedIncomingSyncErrorsPerDatabase {
252255
db.Errors = append(db.Errors, api.DatabaseSynchronizationError{
253256
Collection: s.Collection,
@@ -258,7 +261,17 @@ func (dr *DeploymentReplication) inspectIncomingSynchronizationStatus(destStatus
258261
dbs[s.Database] = db
259262
}
260263

264+
var totalShards = destStatus.TotalShardsCount
265+
if totalShards == 0 {
266+
// can be zero for old versions of arangosync
267+
totalShards = totalShardsFromStatus
268+
}
269+
progress := float32(0.0)
270+
if totalShards > 0 {
271+
progress = float32(shardsInSync) / float32(totalShards)
272+
}
261273
return api.SynchronizationStatus{
274+
Progress: progress,
262275
AllInSync: destStatus.Status == client.SyncStatusRunning,
263276
Databases: dbs,
264277
Error: "",

0 commit comments

Comments
 (0)