Skip to content

Commit 2e3186a

Browse files
authored
[Feature] Backup InProgress Agency Key (#955)
1 parent 8daef0c commit 2e3186a

File tree

10 files changed

+6972
-5
lines changed

10 files changed

+6972
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- (Bugfix) Fix backup creation timeout
77
- (Bugfix) ArangoSync port fix
88
- (Bugfix) Fix GetClient lock system
9+
- (Feature) Backup InProgress Agency key discovery
910

1011
## [1.2.9](https://github.com/arangodb/kube-arangodb/tree/1.2.9) (2022-03-30)
1112
- (Feature) Improve Kubernetes clientsets management

cmd/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ var (
138138
arangoD time.Duration
139139
arangoDCheck time.Duration
140140
reconciliation time.Duration
141+
agency time.Duration
141142
}
142143
chaosOptions struct {
143144
allowed bool
@@ -177,6 +178,7 @@ func init() {
177178
f.DurationVar(&operatorTimeouts.k8s, "timeout.k8s", globals.DefaultKubernetesTimeout, "The request timeout to the kubernetes")
178179
f.DurationVar(&operatorTimeouts.arangoD, "timeout.arangod", globals.DefaultArangoDTimeout, "The request timeout to the ArangoDB")
179180
f.DurationVar(&operatorTimeouts.arangoDCheck, "timeout.arangod-check", globals.DefaultArangoDCheckTimeout, "The version check request timeout to the ArangoDB")
181+
f.DurationVar(&operatorTimeouts.agency, "timeout.agency", globals.DefaultArangoDAgencyTimeout, "The Agency read timeout")
180182
f.DurationVar(&operatorTimeouts.reconciliation, "timeout.reconciliation", globals.DefaultReconciliationTimeout, "The reconciliation timeout to the ArangoDB CR")
181183
f.BoolVar(&operatorOptions.scalingIntegrationEnabled, "internal.scaling-integration", true, "Enable Scaling Integration")
182184
f.Int64Var(&operatorKubernetesOptions.maxBatchSize, "kubernetes.max-batch-size", globals.DefaultKubernetesRequestBatchSize, "Size of batch during objects read")
@@ -216,6 +218,7 @@ func executeMain(cmd *cobra.Command, args []string) {
216218

217219
globals.GetGlobalTimeouts().Kubernetes().Set(operatorTimeouts.k8s)
218220
globals.GetGlobalTimeouts().ArangoD().Set(operatorTimeouts.arangoD)
221+
globals.GetGlobalTimeouts().Agency().Set(operatorTimeouts.agency)
219222
globals.GetGlobalTimeouts().ArangoDCheck().Set(operatorTimeouts.arangoDCheck)
220223
globals.GetGlobalTimeouts().Reconciliation().Set(operatorTimeouts.reconciliation)
221224
globals.GetGlobals().Kubernetes().RequestBatchSize().Set(operatorKubernetesOptions.maxBatchSize)

pkg/deployment/agency/definitions.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const (
3030

3131
PlanKey = "Plan"
3232
CurrentKey = "Current"
33+
TargetKey = "Target"
34+
35+
TargetHotBackupKey = "HotBackup"
3336

3437
PlanCollectionsKey = "Collections"
3538

pkg/deployment/agency/state.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ func loadState(ctx context.Context, client agency.Agency) (State, error) {
4040

4141
var data []byte
4242

43-
req, err = req.SetBody(GetAgencyReadRequest(GetAgencyReadKey(GetAgencyKey(ArangoKey, SupervisionKey, SupervisionMaintenanceKey), GetAgencyKey(ArangoKey, PlanKey, PlanCollectionsKey), GetAgencyKey(ArangoKey, CurrentKey, PlanCollectionsKey))))
43+
readKeys := []string{
44+
GetAgencyKey(ArangoKey, SupervisionKey, SupervisionMaintenanceKey),
45+
GetAgencyKey(ArangoKey, PlanKey, PlanCollectionsKey),
46+
GetAgencyKey(ArangoKey, CurrentKey, PlanCollectionsKey),
47+
GetAgencyKey(ArangoKey, TargetKey, TargetHotBackupKey),
48+
}
49+
50+
req, err = req.SetBody(GetAgencyReadRequest(GetAgencyReadKey(readKeys...)))
4451
if err != nil {
4552
return State{}, err
4653
}
@@ -91,6 +98,7 @@ type State struct {
9198
Supervision StateSupervision `json:"Supervision"`
9299
Plan StatePlan `json:"Plan"`
93100
Current StateCurrent `json:"Current"`
101+
Target StateTarget `json:"Target"`
94102
}
95103

96104
type StateCurrent struct {

pkg/deployment/agency/state_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@ var agencyDump39 []byte
4343
//go:embed testdata/agency_dump.3.9.satellite.json
4444
var agencyDump39Satellite []byte
4545

46+
//go:embed testdata/agency_dump.3.9.hotbackup.json
47+
var agencyDump39HotBackup []byte
48+
4649
var (
4750
data = map[string][]byte{
4851
"3.6": agencyDump36,
4952
"3.7": agencyDump37,
5053
"3.8": agencyDump38,
5154
"3.9": agencyDump39,
5255
"3.9-satellite": agencyDump39Satellite,
56+
"3.9-hotbackup": agencyDump39HotBackup,
5357
}
5458
)
5559

pkg/deployment/agency/target.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package agency
22+
23+
type StateTarget struct {
24+
HotBackup StateTargetHotBackup `json:"HotBackup,omitempty"`
25+
}
26+
27+
type StateTargetHotBackup struct {
28+
Create *StateExists `json:"Create,omitempty"`
29+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package agency
22+
23+
import (
24+
"encoding/json"
25+
"testing"
26+
27+
"github.com/stretchr/testify/require"
28+
)
29+
30+
func Test_Target_HotBackup(t *testing.T) {
31+
t.Run("Exists", func(t *testing.T) {
32+
var s DumpState
33+
require.NoError(t, json.Unmarshal(agencyDump39HotBackup, &s))
34+
35+
require.True(t, s.Agency.Arango.Target.HotBackup.Create.Exists())
36+
})
37+
t.Run("Does Not Exists", func(t *testing.T) {
38+
var s DumpState
39+
require.NoError(t, json.Unmarshal(agencyDump39Satellite, &s))
40+
41+
require.False(t, s.Agency.Arango.Target.HotBackup.Create.Exists())
42+
})
43+
}

0 commit comments

Comments
 (0)