mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Backup InProgress Agency Key (#955)
This commit is contained in:
parent
8daef0cbf4
commit
2e3186abf4
10 changed files with 6972 additions and 5 deletions
|
@ -6,6 +6,7 @@
|
|||
- (Bugfix) Fix backup creation timeout
|
||||
- (Bugfix) ArangoSync port fix
|
||||
- (Bugfix) Fix GetClient lock system
|
||||
- (Feature) Backup InProgress Agency key discovery
|
||||
|
||||
## [1.2.9](https://github.com/arangodb/kube-arangodb/tree/1.2.9) (2022-03-30)
|
||||
- (Feature) Improve Kubernetes clientsets management
|
||||
|
|
|
@ -138,6 +138,7 @@ var (
|
|||
arangoD time.Duration
|
||||
arangoDCheck time.Duration
|
||||
reconciliation time.Duration
|
||||
agency time.Duration
|
||||
}
|
||||
chaosOptions struct {
|
||||
allowed bool
|
||||
|
@ -177,6 +178,7 @@ func init() {
|
|||
f.DurationVar(&operatorTimeouts.k8s, "timeout.k8s", globals.DefaultKubernetesTimeout, "The request timeout to the kubernetes")
|
||||
f.DurationVar(&operatorTimeouts.arangoD, "timeout.arangod", globals.DefaultArangoDTimeout, "The request timeout to the ArangoDB")
|
||||
f.DurationVar(&operatorTimeouts.arangoDCheck, "timeout.arangod-check", globals.DefaultArangoDCheckTimeout, "The version check request timeout to the ArangoDB")
|
||||
f.DurationVar(&operatorTimeouts.agency, "timeout.agency", globals.DefaultArangoDAgencyTimeout, "The Agency read timeout")
|
||||
f.DurationVar(&operatorTimeouts.reconciliation, "timeout.reconciliation", globals.DefaultReconciliationTimeout, "The reconciliation timeout to the ArangoDB CR")
|
||||
f.BoolVar(&operatorOptions.scalingIntegrationEnabled, "internal.scaling-integration", true, "Enable Scaling Integration")
|
||||
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) {
|
|||
|
||||
globals.GetGlobalTimeouts().Kubernetes().Set(operatorTimeouts.k8s)
|
||||
globals.GetGlobalTimeouts().ArangoD().Set(operatorTimeouts.arangoD)
|
||||
globals.GetGlobalTimeouts().Agency().Set(operatorTimeouts.agency)
|
||||
globals.GetGlobalTimeouts().ArangoDCheck().Set(operatorTimeouts.arangoDCheck)
|
||||
globals.GetGlobalTimeouts().Reconciliation().Set(operatorTimeouts.reconciliation)
|
||||
globals.GetGlobals().Kubernetes().RequestBatchSize().Set(operatorKubernetesOptions.maxBatchSize)
|
||||
|
|
|
@ -30,6 +30,9 @@ const (
|
|||
|
||||
PlanKey = "Plan"
|
||||
CurrentKey = "Current"
|
||||
TargetKey = "Target"
|
||||
|
||||
TargetHotBackupKey = "HotBackup"
|
||||
|
||||
PlanCollectionsKey = "Collections"
|
||||
|
||||
|
|
|
@ -40,7 +40,14 @@ func loadState(ctx context.Context, client agency.Agency) (State, error) {
|
|||
|
||||
var data []byte
|
||||
|
||||
req, err = req.SetBody(GetAgencyReadRequest(GetAgencyReadKey(GetAgencyKey(ArangoKey, SupervisionKey, SupervisionMaintenanceKey), GetAgencyKey(ArangoKey, PlanKey, PlanCollectionsKey), GetAgencyKey(ArangoKey, CurrentKey, PlanCollectionsKey))))
|
||||
readKeys := []string{
|
||||
GetAgencyKey(ArangoKey, SupervisionKey, SupervisionMaintenanceKey),
|
||||
GetAgencyKey(ArangoKey, PlanKey, PlanCollectionsKey),
|
||||
GetAgencyKey(ArangoKey, CurrentKey, PlanCollectionsKey),
|
||||
GetAgencyKey(ArangoKey, TargetKey, TargetHotBackupKey),
|
||||
}
|
||||
|
||||
req, err = req.SetBody(GetAgencyReadRequest(GetAgencyReadKey(readKeys...)))
|
||||
if err != nil {
|
||||
return State{}, err
|
||||
}
|
||||
|
@ -91,6 +98,7 @@ type State struct {
|
|||
Supervision StateSupervision `json:"Supervision"`
|
||||
Plan StatePlan `json:"Plan"`
|
||||
Current StateCurrent `json:"Current"`
|
||||
Target StateTarget `json:"Target"`
|
||||
}
|
||||
|
||||
type StateCurrent struct {
|
||||
|
|
|
@ -43,6 +43,9 @@ var agencyDump39 []byte
|
|||
//go:embed testdata/agency_dump.3.9.satellite.json
|
||||
var agencyDump39Satellite []byte
|
||||
|
||||
//go:embed testdata/agency_dump.3.9.hotbackup.json
|
||||
var agencyDump39HotBackup []byte
|
||||
|
||||
var (
|
||||
data = map[string][]byte{
|
||||
"3.6": agencyDump36,
|
||||
|
@ -50,6 +53,7 @@ var (
|
|||
"3.8": agencyDump38,
|
||||
"3.9": agencyDump39,
|
||||
"3.9-satellite": agencyDump39Satellite,
|
||||
"3.9-hotbackup": agencyDump39HotBackup,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
29
pkg/deployment/agency/target.go
Normal file
29
pkg/deployment/agency/target.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package agency
|
||||
|
||||
type StateTarget struct {
|
||||
HotBackup StateTargetHotBackup `json:"HotBackup,omitempty"`
|
||||
}
|
||||
|
||||
type StateTargetHotBackup struct {
|
||||
Create *StateExists `json:"Create,omitempty"`
|
||||
}
|
43
pkg/deployment/agency/target_test.go
Normal file
43
pkg/deployment/agency/target_test.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
//
|
||||
|
||||
package agency
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_Target_HotBackup(t *testing.T) {
|
||||
t.Run("Exists", func(t *testing.T) {
|
||||
var s DumpState
|
||||
require.NoError(t, json.Unmarshal(agencyDump39HotBackup, &s))
|
||||
|
||||
require.True(t, s.Agency.Arango.Target.HotBackup.Create.Exists())
|
||||
})
|
||||
t.Run("Does Not Exists", func(t *testing.T) {
|
||||
var s DumpState
|
||||
require.NoError(t, json.Unmarshal(agencyDump39Satellite, &s))
|
||||
|
||||
require.False(t, s.Agency.Arango.Target.HotBackup.Create.Exists())
|
||||
})
|
||||
}
|
6869
pkg/deployment/agency/testdata/agency_dump.3.9.hotbackup.json
vendored
Normal file
6869
pkg/deployment/agency/testdata/agency_dump.3.9.hotbackup.json
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -161,13 +161,13 @@ func (d *Deployment) GetAgencyCache() (agency.State, bool) {
|
|||
}
|
||||
|
||||
func (d *Deployment) RefreshAgencyCache(ctx context.Context) (uint64, error) {
|
||||
lCtx, c := context.WithTimeout(ctx, time.Second)
|
||||
defer c()
|
||||
|
||||
if d.apiObject.Spec.Mode.Get() == api.DeploymentModeSingle {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
lCtx, c := globals.GetGlobalTimeouts().Agency().WithTimeout(ctx)
|
||||
defer c()
|
||||
|
||||
a, err := d.GetAgency(lCtx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
|
|
@ -25,6 +25,7 @@ import "time"
|
|||
const (
|
||||
DefaultKubernetesTimeout = 2 * time.Second
|
||||
DefaultArangoDTimeout = time.Second * 10
|
||||
DefaultArangoDAgencyTimeout = time.Second * 10
|
||||
DefaultArangoDCheckTimeout = time.Second * 2
|
||||
DefaultReconciliationTimeout = time.Minute
|
||||
|
||||
|
@ -39,6 +40,7 @@ var globalObj = &globals{
|
|||
arangod: NewTimeout(DefaultArangoDTimeout),
|
||||
arangodCheck: NewTimeout(DefaultArangoDCheckTimeout),
|
||||
reconciliation: NewTimeout(DefaultReconciliationTimeout),
|
||||
agency: NewTimeout(DefaultArangoDAgencyTimeout),
|
||||
},
|
||||
kubernetes: &globalKubernetes{
|
||||
requestBatchSize: NewInt64(DefaultKubernetesRequestBatchSize),
|
||||
|
@ -110,10 +112,15 @@ type GlobalTimeouts interface {
|
|||
Kubernetes() Timeout
|
||||
ArangoD() Timeout
|
||||
ArangoDCheck() Timeout
|
||||
Agency() Timeout
|
||||
}
|
||||
|
||||
type globalTimeouts struct {
|
||||
requests, arangod, reconciliation, arangodCheck Timeout
|
||||
requests, arangod, reconciliation, arangodCheck, agency Timeout
|
||||
}
|
||||
|
||||
func (g *globalTimeouts) Agency() Timeout {
|
||||
return g.agency
|
||||
}
|
||||
|
||||
func (g *globalTimeouts) ArangoDCheck() Timeout {
|
||||
|
|
Loading…
Reference in a new issue