mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] [ArangoBackup] Propagate message during retries (#1613)
This commit is contained in:
parent
25542dea6e
commit
095e261b38
5 changed files with 56 additions and 8 deletions
|
@ -12,6 +12,7 @@
|
|||
- (Bugfix) Check Connection to the ArangoDB before creating Backup
|
||||
- (Feature) Deployment & Members Condition metrics
|
||||
- (Maintenance) Update Go to 1.21.8 & Dependencies
|
||||
- (Feature) (ArangoBackup) Propagate message during retries
|
||||
|
||||
## [1.2.38](https://github.com/arangodb/kube-arangodb/tree/1.2.38) (2024-02-22)
|
||||
- (Feature) Extract GRPC Server
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2023-2024 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.
|
||||
|
@ -29,7 +29,8 @@ import (
|
|||
func stateCreateErrorHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) {
|
||||
if !backup.Spec.Backoff.Enabled() {
|
||||
return wrapUpdateStatus(backup,
|
||||
updateStatusState(backupApi.ArangoBackupStateFailed, "retries are disabled"),
|
||||
updateStatusStateOnly(backupApi.ArangoBackupStateFailed),
|
||||
cleanBackOff(),
|
||||
cleanStatusJob())
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2023-2024 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.
|
||||
|
@ -97,7 +97,8 @@ func Test_State_CreateError_Retry_WhenBackoffDisabled_C1(t *testing.T) {
|
|||
// Assert
|
||||
newObj := refreshArangoBackup(t, handler, obj)
|
||||
require.Equal(t, newObj.Status.State, backupApi.ArangoBackupStateFailed)
|
||||
require.Equal(t, newObj.Status.Message, "retries are disabled")
|
||||
require.Nil(t, newObj.Status.Backoff)
|
||||
require.Equal(t, newObj.Status.Message, "")
|
||||
}
|
||||
|
||||
func Test_State_CreateError_Retry_WhenBackoffDisabled_C2(t *testing.T) {
|
||||
|
@ -126,7 +127,42 @@ func Test_State_CreateError_Retry_WhenBackoffDisabled_C2(t *testing.T) {
|
|||
// Assert
|
||||
newObj := refreshArangoBackup(t, handler, obj)
|
||||
require.Equal(t, newObj.Status.State, backupApi.ArangoBackupStateFailed)
|
||||
require.Equal(t, newObj.Status.Message, "retries are disabled")
|
||||
require.Nil(t, newObj.Status.Backoff)
|
||||
require.Equal(t, newObj.Status.Message, "")
|
||||
}
|
||||
|
||||
func Test_State_CreateError_Retry_WhenBackoffDisabled_C3(t *testing.T) {
|
||||
// Arrange
|
||||
message := "SomeRandomErrorMessage"
|
||||
|
||||
handler, mock := newErrorsFakeHandler(mockErrorsArangoClientBackup{})
|
||||
|
||||
obj, deployment := newObjectSet(t, backupApi.ArangoBackupStateCreateError)
|
||||
|
||||
obj.Status.Message = message
|
||||
|
||||
backupMeta, err := mock.Create()
|
||||
require.NoError(t, err)
|
||||
|
||||
obj.Status.Backup = &backupApi.ArangoBackupDetails{
|
||||
ID: string(backupMeta.ID),
|
||||
Version: backupMeta.Version,
|
||||
CreationTimestamp: meta.Now(),
|
||||
}
|
||||
|
||||
obj.Status.Time.Time = time.Now().Add(-2 * downloadDelay)
|
||||
|
||||
// Act
|
||||
createArangoDeployment(t, handler, deployment)
|
||||
createArangoBackup(t, handler, obj)
|
||||
|
||||
require.NoError(t, handler.Handle(context.Background(), tests.NewItem(t, operation.Update, obj)))
|
||||
|
||||
// Assert
|
||||
newObj := refreshArangoBackup(t, handler, obj)
|
||||
require.Equal(t, newObj.Status.State, backupApi.ArangoBackupStateFailed)
|
||||
require.Nil(t, newObj.Status.Backoff)
|
||||
require.Equal(t, newObj.Status.Message, message)
|
||||
}
|
||||
|
||||
func Test_State_CreateError_Transfer_To_Failed(t *testing.T) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2016-2024 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.
|
||||
|
@ -30,7 +30,8 @@ func stateUploadErrorHandler(h *handler, backup *backupApi.ArangoBackup) (*backu
|
|||
// no more retries - move to failed state
|
||||
if !backup.Status.Backoff.ShouldBackoff(backup.Spec.Backoff) {
|
||||
return wrapUpdateStatus(backup,
|
||||
updateStatusState(backupApi.ArangoBackupStateFailed, "out of Upload retries"),
|
||||
updateStatusStateOnly(backupApi.ArangoBackupStateFailed),
|
||||
cleanBackOff(),
|
||||
cleanStatusJob())
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// DISCLAIMER
|
||||
//
|
||||
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
|
||||
// Copyright 2016-2024 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.
|
||||
|
@ -50,6 +50,15 @@ func updateStatus(backup *backupApi.ArangoBackup, update ...updateStatusFunc) *b
|
|||
return s
|
||||
}
|
||||
|
||||
func updateStatusStateOnly(state state.State) updateStatusFunc {
|
||||
return func(status *backupApi.ArangoBackupStatus) {
|
||||
if status.State != state {
|
||||
status.Time = meta.Now()
|
||||
}
|
||||
status.State = state
|
||||
}
|
||||
}
|
||||
|
||||
func updateStatusState(state state.State, template string, a ...interface{}) updateStatusFunc {
|
||||
return func(status *backupApi.ArangoBackupStatus) {
|
||||
if status.State != state {
|
||||
|
|
Loading…
Reference in a new issue