From fb72a4bef3e73e5ca709bf8ea8754a27dbfcd180 Mon Sep 17 00:00:00 2001 From: "Md. Ishtiaq Islam" Date: Fri, 6 Sep 2024 16:26:47 +0600 Subject: [PATCH 1/5] Add support for timeout for restic backup and restore Signed-off-by: Md. Ishtiaq Islam --- apis/constant.go | 4 ++ apis/core/v1alpha1/backupsession_types.go | 10 ++--- apis/core/v1alpha1/restoresession_helpers.go | 3 +- apis/core/v1alpha1/restoresession_types.go | 9 +--- apis/core/v1alpha1/types.go | 3 -- apis/core/v1alpha1/zz_generated.deepcopy.go | 13 +++--- crds/core.kubestash.com_backupsessions.yaml | 11 +++-- crds/core.kubestash.com_restoresessions.yaml | 12 ++--- pkg/restic/commands.go | 47 ++++++++++++++++---- pkg/restic/config.go | 5 ++- pkg/restic/restic_test.go | 14 +++--- 11 files changed, 73 insertions(+), 58 deletions(-) diff --git a/apis/constant.go b/apis/constant.go index 43d278da..e57aa5a4 100644 --- a/apis/constant.go +++ b/apis/constant.go @@ -153,3 +153,7 @@ const ( SnapshotVersionV1 = "v1" DirRepository = "repository" ) + +const ( + KeyRestoreSessionBeneficiary = "restoresession.kubestash.com/beneficiary" +) diff --git a/apis/core/v1alpha1/backupsession_types.go b/apis/core/v1alpha1/backupsession_types.go index 5ccf2faf..0b9ddf2a 100644 --- a/apis/core/v1alpha1/backupsession_types.go +++ b/apis/core/v1alpha1/backupsession_types.go @@ -63,6 +63,11 @@ type BackupSessionSpec struct { // If this set to non-zero, KubeStash will create a new BackupSession if the current one fails. // +optional RetryLeft int32 `json:"retryLeft,omitempty"` + + // Timeout specifies the maximum duration of backup. Backup will be considered Failed + // if backup does not complete within this time limit. By default, KubeStash don't set any timeout for backup. + // +optional + Timeout *metav1.Duration `json:"timeout,omitempty"` } // BackupSessionStatus defines the observed state of BackupSession @@ -75,11 +80,6 @@ type BackupSessionStatus struct { // +optional Duration string `json:"duration,omitempty"` - // Deadline specifies the deadline of backup. BackupSession will be - // considered Failed if backup does not complete within this deadline - // +optional - Deadline *metav1.Time `json:"sessionDeadline,omitempty"` - // TotalSnapshots specifies the total number of snapshots created for this backupSession. // +optional TotalSnapshots *int32 `json:"totalSnapshots,omitempty"` diff --git a/apis/core/v1alpha1/restoresession_helpers.go b/apis/core/v1alpha1/restoresession_helpers.go index df970cf4..b5515350 100644 --- a/apis/core/v1alpha1/restoresession_helpers.go +++ b/apis/core/v1alpha1/restoresession_helpers.go @@ -41,8 +41,7 @@ func (rs *RestoreSession) CalculatePhase() RestorePhase { } if cutil.IsConditionTrue(rs.Status.Conditions, TypeMetricsPushed) && - (cutil.IsConditionTrue(rs.Status.Conditions, TypeDeadlineExceeded) || - cutil.IsConditionFalse(rs.Status.Conditions, TypePreRestoreHooksExecutionSucceeded) || + (cutil.IsConditionFalse(rs.Status.Conditions, TypePreRestoreHooksExecutionSucceeded) || cutil.IsConditionFalse(rs.Status.Conditions, TypePostRestoreHooksExecutionSucceeded) || cutil.IsConditionFalse(rs.Status.Conditions, TypeRestoreExecutorEnsured)) { return RestoreFailed diff --git a/apis/core/v1alpha1/restoresession_types.go b/apis/core/v1alpha1/restoresession_types.go index f1bfbf52..2a3e91fe 100644 --- a/apis/core/v1alpha1/restoresession_types.go +++ b/apis/core/v1alpha1/restoresession_types.go @@ -64,8 +64,8 @@ type RestoreSessionSpec struct { // +optional Hooks *RestoreHooks `json:"hooks,omitempty"` - // Timeout specifies a duration that KubeStash should wait for the session execution to be completed. - // If the session execution does not finish within this time period, KubeStash will consider this session as a failure. + // Timeout specifies a duration that KubeStash should wait for the restore to be completed. + // If the restore does not finish within this time period, KubeStash will consider this restore as a failure. // +optional Timeout *metav1.Duration `json:"timeout,omitempty"` @@ -278,11 +278,6 @@ type RestoreSessionStatus struct { // +optional Duration string `json:"duration,omitempty"` - // Deadline specifies a timestamp till this session is valid. If the session does not complete within this deadline, - // it will be considered as failed. - // +optional - Deadline *metav1.Time `json:"deadline,omitempty"` - // TotalComponents represents the number of total components for this RestoreSession // +optional TotalComponents int32 `json:"totalComponents,omitempty"` diff --git a/apis/core/v1alpha1/types.go b/apis/core/v1alpha1/types.go index 96dbb652..445f867b 100644 --- a/apis/core/v1alpha1/types.go +++ b/apis/core/v1alpha1/types.go @@ -217,9 +217,6 @@ type RetryConfig struct { } const ( - TypeDeadlineExceeded = "DeadlineExceeded" - ReasonFailedToCompleteWithinDeadline = "FailedToCompleteWithinDeadline" - // TypeMetricsPushed indicates whether Metrics are pushed or not TypeMetricsPushed = "MetricsPushed" ReasonSuccessfullyPushedMetrics = "SuccessfullyPushedMetrics" diff --git a/apis/core/v1alpha1/zz_generated.deepcopy.go b/apis/core/v1alpha1/zz_generated.deepcopy.go index e7d09159..94fe36e6 100644 --- a/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -597,6 +597,11 @@ func (in *BackupSessionSpec) DeepCopyInto(out *BackupSessionSpec) { *out = new(corev1.TypedLocalObjectReference) (*in).DeepCopyInto(*out) } + if in.Timeout != nil { + in, out := &in.Timeout, &out.Timeout + *out = new(metav1.Duration) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupSessionSpec. @@ -612,10 +617,6 @@ func (in *BackupSessionSpec) DeepCopy() *BackupSessionSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BackupSessionStatus) DeepCopyInto(out *BackupSessionStatus) { *out = *in - if in.Deadline != nil { - in, out := &in.Deadline, &out.Deadline - *out = (*in).DeepCopy() - } if in.TotalSnapshots != nil { in, out := &in.TotalSnapshots, &out.TotalSnapshots *out = new(int32) @@ -1437,10 +1438,6 @@ func (in *RestoreSessionStatus) DeepCopyInto(out *RestoreSessionStatus) { *out = new(bool) **out = **in } - if in.Deadline != nil { - in, out := &in.Deadline, &out.Deadline - *out = (*in).DeepCopy() - } if in.Components != nil { in, out := &in.Components, &out.Components *out = make(map[string]ComponentRestoreStatus, len(*in)) diff --git a/crds/core.kubestash.com_backupsessions.yaml b/crds/core.kubestash.com_backupsessions.yaml index 51f413b2..a4b13f82 100644 --- a/crds/core.kubestash.com_backupsessions.yaml +++ b/crds/core.kubestash.com_backupsessions.yaml @@ -87,6 +87,11 @@ spec: description: Session specifies the name of the session that triggered this backup type: string + timeout: + description: Timeout specifies the maximum duration of backup. Backup + will be considered Failed if backup does not complete within this + time limit. By default, KubeStash don't set any timeout for backup. + type: string type: object status: description: BackupSessionStatus defines the observed state of BackupSession @@ -249,12 +254,6 @@ spec: not. This field will exist only if the `retryConfig` has been set in the respective backup invoker. type: boolean - sessionDeadline: - description: Deadline specifies the deadline of backup. BackupSession - will be considered Failed if backup does not complete within this - deadline - format: date-time - type: string snapshots: description: Snapshots specifies the Snapshots status items: diff --git a/crds/core.kubestash.com_restoresessions.yaml b/crds/core.kubestash.com_restoresessions.yaml index 7e9f1918..0b228fdc 100644 --- a/crds/core.kubestash.com_restoresessions.yaml +++ b/crds/core.kubestash.com_restoresessions.yaml @@ -24469,9 +24469,9 @@ spec: type: object timeout: description: Timeout specifies a duration that KubeStash should wait - for the session execution to be completed. If the session execution - does not finish within this time period, KubeStash will consider - this session as a failure. + for the restore to be completed. If the restore does not finish + within this time period, KubeStash will consider this restore as + a failure. type: string type: object status: @@ -24557,12 +24557,6 @@ spec: - type type: object type: array - deadline: - description: Deadline specifies a timestamp till this session is valid. - If the session does not complete within this deadline, it will be - considered as failed. - format: date-time - type: string dependencies: description: Dependencies specifies whether the objects required by this RestoreSession exist or not diff --git a/pkg/restic/commands.go b/pkg/restic/commands.go index a9c1a0a2..33d6a530 100644 --- a/pkg/restic/commands.go +++ b/pkg/restic/commands.go @@ -35,7 +35,8 @@ import ( ) const ( - ResticCMD = "restic" + ResticCMD = "restic" + TimeoutCMD = "timeout" ) type Snapshot struct { @@ -176,7 +177,15 @@ func (w *ResticWrapper) backup(params backupParams) ([]byte, error) { args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) - return w.run(Command{Name: ResticCMD, Args: args}) + command := Command{Name: ResticCMD, Args: args} + if w.config.Timeout != nil { + timeoutArgs := []interface{}{fmt.Sprintf("%f", w.config.Timeout.Seconds())} + timeoutArgs = append(timeoutArgs, ResticCMD) + timeoutArgs = append(timeoutArgs, args...) + command = Command{Name: TimeoutCMD, Args: timeoutArgs} + } + + return w.run(command) } func (w *ResticWrapper) backupFromStdin(options BackupOptions) ([]byte, error) { @@ -200,7 +209,15 @@ func (w *ResticWrapper) backupFromStdin(options BackupOptions) ([]byte, error) { args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) - commands = append(commands, Command{Name: ResticCMD, Args: args}) + command := Command{Name: ResticCMD, Args: args} + if w.config.Timeout != nil { + timeoutArgs := []interface{}{fmt.Sprintf("%f", w.config.Timeout.Seconds())} + timeoutArgs = append(timeoutArgs, ResticCMD) + timeoutArgs = append(timeoutArgs, args...) + command = Command{Name: TimeoutCMD, Args: timeoutArgs} + } + + commands = append(commands, command) return w.run(commands...) } @@ -246,7 +263,15 @@ func (w *ResticWrapper) restore(params restoreParams) ([]byte, error) { args = w.appendInsecureTLSFlag(args) args = w.appendMaxConnectionsFlag(args) - return w.run(Command{Name: ResticCMD, Args: args}) + command := Command{Name: ResticCMD, Args: args} + if w.config.Timeout != nil { + timeoutArgs := []interface{}{fmt.Sprintf("%f", w.config.Timeout.Seconds())} + timeoutArgs = append(timeoutArgs, ResticCMD) + timeoutArgs = append(timeoutArgs, args...) + command = Command{Name: TimeoutCMD, Args: timeoutArgs} + } + + return w.run(command) } func (w *ResticWrapper) DumpOnce(dumpOptions DumpOptions) ([]byte, error) { @@ -277,10 +302,16 @@ func (w *ResticWrapper) DumpOnce(dumpOptions DumpOptions) ([]byte, error) { args = w.appendMaxConnectionsFlag(args) args = w.appendInsecureTLSFlag(args) - // first add restic command, then add StdoutPipeCommands - commands := []Command{ - {Name: ResticCMD, Args: args}, + command := Command{Name: ResticCMD, Args: args} + if w.config.Timeout != nil { + timeoutArgs := []interface{}{fmt.Sprintf("%f", w.config.Timeout.Seconds())} + timeoutArgs = append(timeoutArgs, ResticCMD) + timeoutArgs = append(timeoutArgs, args...) + command = Command{Name: TimeoutCMD, Args: timeoutArgs} } + + // first add restic command, then add StdoutPipeCommands + commands := []Command{command} commands = append(commands, dumpOptions.StdoutPipeCommands...) return w.run(commands...) } @@ -368,7 +399,7 @@ func (w *ResticWrapper) run(commands ...Command) ([]byte, error) { w.sh.Stderr = io.MultiWriter(os.Stderr, errBuff) for _, cmd := range commands { - if cmd.Name == ResticCMD { + if cmd.Name == ResticCMD || cmd.Name == TimeoutCMD { // first apply NiceSettings, then apply IONiceSettings cmd, err = w.applyNiceSettings(cmd) if err != nil { diff --git a/pkg/restic/config.go b/pkg/restic/config.go index 6bf9617b..2a910c3b 100644 --- a/pkg/restic/config.go +++ b/pkg/restic/config.go @@ -18,12 +18,12 @@ package restic import ( "fmt" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "kubestash.dev/apimachinery/apis/storage/v1alpha1" "os" "path/filepath" "sort" - "kubestash.dev/apimachinery/apis/storage/v1alpha1" - shell "gomodules.xyz/go-sh" core "k8s.io/api/core/v1" kmapi "kmodules.xyz/client-go/api/v1" @@ -103,6 +103,7 @@ type SetupOptions struct { EnableCache bool Nice *ofst.NiceSettings IONice *ofst.IONiceSettings + Timeout *metav1.Duration } type KeyOptions struct { diff --git a/pkg/restic/restic_test.go b/pkg/restic/restic_test.go index b9dd6b97..49a012a9 100644 --- a/pkg/restic/restic_test.go +++ b/pkg/restic/restic_test.go @@ -18,14 +18,6 @@ package restic import ( "fmt" - "os" - "path/filepath" - "testing" - - addonapi "kubestash.dev/apimachinery/apis/addons/v1alpha1" - coreapi "kubestash.dev/apimachinery/apis/core/v1alpha1" - storageapi "kubestash.dev/apimachinery/apis/storage/v1alpha1" - "github.com/stretchr/testify/assert" "gomodules.xyz/pointer" core "k8s.io/api/core/v1" @@ -35,8 +27,14 @@ import ( kmapi "kmodules.xyz/client-go/api/v1" storage "kmodules.xyz/objectstore-api/api/v1" ofst "kmodules.xyz/offshoot-api/api/v1" + addonapi "kubestash.dev/apimachinery/apis/addons/v1alpha1" + coreapi "kubestash.dev/apimachinery/apis/core/v1alpha1" + storageapi "kubestash.dev/apimachinery/apis/storage/v1alpha1" + "os" + "path/filepath" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" + "testing" ) var ( From cb37ad008d5b05ee685b2c6369c4e050d20cbc1c Mon Sep 17 00:00:00 2001 From: "Md. Ishtiaq Islam" Date: Wed, 11 Sep 2024 12:48:12 +0600 Subject: [PATCH 2/5] Add timeout method Signed-off-by: Md. Ishtiaq Islam --- apis/constant.go | 5 +-- .../v1alpha1/backupconfiguration_types.go | 4 +-- apis/core/v1alpha1/backupsession_helpers.go | 11 +++++++ apis/core/v1alpha1/backupsession_types.go | 7 +++- apis/core/v1alpha1/restoresession_helpers.go | 12 +++++++ .../v1alpha1/restoresession_helpers_test.go | 19 ----------- apis/core/v1alpha1/restoresession_types.go | 7 +++- apis/core/v1alpha1/zz_generated.deepcopy.go | 8 +++++ crds/core.kubestash.com_backupbatches.yaml | 6 ++-- crds/core.kubestash.com_backupblueprints.yaml | 4 +-- ...re.kubestash.com_backupconfigurations.yaml | 6 ++-- crds/core.kubestash.com_backupsessions.yaml | 10 ++++-- crds/core.kubestash.com_restoresessions.yaml | 7 +++- pkg/restic/commands.go | 3 ++ pkg/restic/restic_test.go | 33 +++++++++++++++++++ 15 files changed, 106 insertions(+), 36 deletions(-) diff --git a/apis/constant.go b/apis/constant.go index e57aa5a4..33efe359 100644 --- a/apis/constant.go +++ b/apis/constant.go @@ -75,7 +75,6 @@ const ( KubeStashAppRefKind = "kubestash.com/app-ref-kind" KubeStashAppRefNamespace = "kubestash.com/app-ref-namespace" KubeStashAppRefName = "kubestash.com/app-ref-name" - KubeDBAppVersion = "kubedb.com/db-version" ) // Keys for structure logging @@ -154,6 +153,8 @@ const ( DirRepository = "repository" ) +// Annotations const ( - KeyRestoreSessionBeneficiary = "restoresession.kubestash.com/beneficiary" + AnnKubeDBAppVersion = "kubedb.com/db-version" + AnnRestoreSessionBeneficiary = "restoresession.kubestash.com/beneficiary" ) diff --git a/apis/core/v1alpha1/backupconfiguration_types.go b/apis/core/v1alpha1/backupconfiguration_types.go index 105c4ce4..45a71792 100644 --- a/apis/core/v1alpha1/backupconfiguration_types.go +++ b/apis/core/v1alpha1/backupconfiguration_types.go @@ -132,8 +132,8 @@ type SessionConfig struct { // +optional RetryConfig *RetryConfig `json:"retryConfig,omitempty"` - // Timeout specifies the maximum duration of backup. BackupSession will be considered Failed - // if backup does not complete within this time limit. By default, KubeStash don't set any timeout for backup. + // Timeout specifies the maximum duration of backup. Backup will be considered Failed + // if backup tasks do not complete within this time limit. By default, KubeStash don't set any timeout for backup. // +optional Timeout *metav1.Duration `json:"timeout,omitempty"` diff --git a/apis/core/v1alpha1/backupsession_helpers.go b/apis/core/v1alpha1/backupsession_helpers.go index d89f19e8..929c993e 100644 --- a/apis/core/v1alpha1/backupsession_helpers.go +++ b/apis/core/v1alpha1/backupsession_helpers.go @@ -243,3 +243,14 @@ func (b *BackupSession) checkFailureInRetentionPolicy() (bool, string) { } return false, "" } + +func (b *BackupSession) GetRemainingTimeoutDuration() (*metav1.Duration, error) { + if b.Spec.Timeout == nil || b.Status.Deadline == nil { + return nil, nil + } + currentTime := metav1.Now() + if b.Status.Deadline.Before(¤tTime) { + return nil, fmt.Errorf("deadline exceeded") + } + return &metav1.Duration{Duration: b.Status.Deadline.Sub(currentTime.Time)}, nil +} diff --git a/apis/core/v1alpha1/backupsession_types.go b/apis/core/v1alpha1/backupsession_types.go index 0b9ddf2a..57af8866 100644 --- a/apis/core/v1alpha1/backupsession_types.go +++ b/apis/core/v1alpha1/backupsession_types.go @@ -65,7 +65,7 @@ type BackupSessionSpec struct { RetryLeft int32 `json:"retryLeft,omitempty"` // Timeout specifies the maximum duration of backup. Backup will be considered Failed - // if backup does not complete within this time limit. By default, KubeStash don't set any timeout for backup. + // if backup tasks do not complete within this time limit. By default, KubeStash don't set any timeout for backup. // +optional Timeout *metav1.Duration `json:"timeout,omitempty"` } @@ -80,6 +80,11 @@ type BackupSessionStatus struct { // +optional Duration string `json:"duration,omitempty"` + // Deadline specifies the deadline of backup. Backup will be + // considered Failed if it does not complete within this deadline + // +optional + Deadline *metav1.Time `json:"backupDeadline,omitempty"` + // TotalSnapshots specifies the total number of snapshots created for this backupSession. // +optional TotalSnapshots *int32 `json:"totalSnapshots,omitempty"` diff --git a/apis/core/v1alpha1/restoresession_helpers.go b/apis/core/v1alpha1/restoresession_helpers.go index b5515350..6d5a516e 100644 --- a/apis/core/v1alpha1/restoresession_helpers.go +++ b/apis/core/v1alpha1/restoresession_helpers.go @@ -17,6 +17,7 @@ limitations under the License. package v1alpha1 import ( + "fmt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kmapi "kmodules.xyz/client-go/api/v1" "kubestash.dev/apimachinery/apis" @@ -180,3 +181,14 @@ func (rs *RestoreSession) GetDataSourceNamespace() string { } return rs.Spec.DataSource.Namespace } + +func (rs *RestoreSession) GetRemainingTimeoutDuration() (*metav1.Duration, error) { + if rs.Spec.Timeout == nil || rs.Status.Deadline == nil { + return nil, nil + } + currentTime := metav1.Now() + if rs.Status.Deadline.Before(¤tTime) { + return nil, fmt.Errorf("deadline exceeded") + } + return &metav1.Duration{Duration: rs.Status.Deadline.Sub(currentTime.Time)}, nil +} diff --git a/apis/core/v1alpha1/restoresession_helpers_test.go b/apis/core/v1alpha1/restoresession_helpers_test.go index 2e3b9d8f..7cf97362 100644 --- a/apis/core/v1alpha1/restoresession_helpers_test.go +++ b/apis/core/v1alpha1/restoresession_helpers_test.go @@ -230,25 +230,6 @@ func TestRestoreSessionPhaseIsFailedIfRestoreExecutorEnsuredConditionIsFalse(t * assert.Equal(t, RestoreFailed, rs.CalculatePhase()) } -func TestRestoreSessionPhaseIsFailedIfDeadlineExceededConditionIsTrue(t *testing.T) { - rs := sampleRestoreSession(func(r *RestoreSession) { - r.Status.Conditions = append(r.Status.Conditions, - kmapi.Condition{ - Type: TypeDeadlineExceeded, - Status: metav1.ConditionTrue, - Reason: ReasonFailedToCompleteWithinDeadline, - }, - kmapi.Condition{ - Type: TypeMetricsPushed, - Status: metav1.ConditionTrue, - Reason: ReasonSuccessfullyPushedMetrics, - }, - ) - }) - - assert.Equal(t, RestoreFailed, rs.CalculatePhase()) -} - func TestRestoreSessionPhaseIsRunningIfPostRestoreHooksNotExecuted(test *testing.T) { rs := sampleRestoreSession(func(r *RestoreSession) { r.Status.Components = map[string]ComponentRestoreStatus{ diff --git a/apis/core/v1alpha1/restoresession_types.go b/apis/core/v1alpha1/restoresession_types.go index 2a3e91fe..04b09268 100644 --- a/apis/core/v1alpha1/restoresession_types.go +++ b/apis/core/v1alpha1/restoresession_types.go @@ -65,7 +65,7 @@ type RestoreSessionSpec struct { Hooks *RestoreHooks `json:"hooks,omitempty"` // Timeout specifies a duration that KubeStash should wait for the restore to be completed. - // If the restore does not finish within this time period, KubeStash will consider this restore as a failure. + // If the restore tasks do not finish within this time period, KubeStash will consider this restore as a failure. // +optional Timeout *metav1.Duration `json:"timeout,omitempty"` @@ -278,6 +278,11 @@ type RestoreSessionStatus struct { // +optional Duration string `json:"duration,omitempty"` + // Deadline specifies the deadline of restore. Restore will be + // considered Failed if it does not complete within this deadline + // +optional + Deadline *metav1.Time `json:"restoreDeadline,omitempty"` + // TotalComponents represents the number of total components for this RestoreSession // +optional TotalComponents int32 `json:"totalComponents,omitempty"` diff --git a/apis/core/v1alpha1/zz_generated.deepcopy.go b/apis/core/v1alpha1/zz_generated.deepcopy.go index 94fe36e6..19894d7d 100644 --- a/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -617,6 +617,10 @@ func (in *BackupSessionSpec) DeepCopy() *BackupSessionSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BackupSessionStatus) DeepCopyInto(out *BackupSessionStatus) { *out = *in + if in.Deadline != nil { + in, out := &in.Deadline, &out.Deadline + *out = (*in).DeepCopy() + } if in.TotalSnapshots != nil { in, out := &in.TotalSnapshots, &out.TotalSnapshots *out = new(int32) @@ -1438,6 +1442,10 @@ func (in *RestoreSessionStatus) DeepCopyInto(out *RestoreSessionStatus) { *out = new(bool) **out = **in } + if in.Deadline != nil { + in, out := &in.Deadline, &out.Deadline + *out = (*in).DeepCopy() + } if in.Components != nil { in, out := &in.Components, &out.Components *out = make(map[string]ComponentRestoreStatus, len(*in)) diff --git a/crds/core.kubestash.com_backupbatches.yaml b/crds/core.kubestash.com_backupbatches.yaml index 4918fbb4..85ecc67b 100644 --- a/crds/core.kubestash.com_backupbatches.yaml +++ b/crds/core.kubestash.com_backupbatches.yaml @@ -36196,9 +36196,9 @@ spec: type: array timeout: description: Timeout specifies the maximum duration of backup. - BackupSession will be considered Failed if backup does not - complete within this time limit. By default, KubeStash don't - set any timeout for backup. + Backup will be considered Failed if backup tasks do not complete + within this time limit. By default, KubeStash don't set any + timeout for backup. type: string type: object type: array diff --git a/crds/core.kubestash.com_backupblueprints.yaml b/crds/core.kubestash.com_backupblueprints.yaml index 62b405d7..ce16147a 100644 --- a/crds/core.kubestash.com_backupblueprints.yaml +++ b/crds/core.kubestash.com_backupblueprints.yaml @@ -37241,8 +37241,8 @@ spec: type: integer timeout: description: Timeout specifies the maximum duration of backup. - BackupSession will be considered Failed if backup does - not complete within this time limit. By default, KubeStash + Backup will be considered Failed if backup tasks do not + complete within this time limit. By default, KubeStash don't set any timeout for backup. type: string type: object diff --git a/crds/core.kubestash.com_backupconfigurations.yaml b/crds/core.kubestash.com_backupconfigurations.yaml index 30807c31..e4297042 100644 --- a/crds/core.kubestash.com_backupconfigurations.yaml +++ b/crds/core.kubestash.com_backupconfigurations.yaml @@ -34375,9 +34375,9 @@ spec: type: integer timeout: description: Timeout specifies the maximum duration of backup. - BackupSession will be considered Failed if backup does not - complete within this time limit. By default, KubeStash don't - set any timeout for backup. + Backup will be considered Failed if backup tasks do not complete + within this time limit. By default, KubeStash don't set any + timeout for backup. type: string type: object type: array diff --git a/crds/core.kubestash.com_backupsessions.yaml b/crds/core.kubestash.com_backupsessions.yaml index a4b13f82..214138a4 100644 --- a/crds/core.kubestash.com_backupsessions.yaml +++ b/crds/core.kubestash.com_backupsessions.yaml @@ -89,13 +89,19 @@ spec: type: string timeout: description: Timeout specifies the maximum duration of backup. Backup - will be considered Failed if backup does not complete within this - time limit. By default, KubeStash don't set any timeout for backup. + will be considered Failed if backup tasks do not complete within + this time limit. By default, KubeStash don't set any timeout for + backup. type: string type: object status: description: BackupSessionStatus defines the observed state of BackupSession properties: + backupDeadline: + description: Deadline specifies the deadline of backup. Backup will + be considered Failed if it does not complete within this deadline + format: date-time + type: string conditions: description: Conditions represents list of conditions regarding this BackupSession diff --git a/crds/core.kubestash.com_restoresessions.yaml b/crds/core.kubestash.com_restoresessions.yaml index 0b228fdc..c66bb079 100644 --- a/crds/core.kubestash.com_restoresessions.yaml +++ b/crds/core.kubestash.com_restoresessions.yaml @@ -24469,7 +24469,7 @@ spec: type: object timeout: description: Timeout specifies a duration that KubeStash should wait - for the restore to be completed. If the restore does not finish + for the restore to be completed. If the restore tasks do not finish within this time period, KubeStash will consider this restore as a failure. type: string @@ -24661,6 +24661,11 @@ spec: - Invalid - Unknown type: string + restoreDeadline: + description: Deadline specifies the deadline of restore. Restore will + be considered Failed if it does not complete within this deadline + format: date-time + type: string targetFound: description: TargetFound specifies whether the restore target exist or not diff --git a/pkg/restic/commands.go b/pkg/restic/commands.go index 33d6a530..e954d1c6 100644 --- a/pkg/restic/commands.go +++ b/pkg/restic/commands.go @@ -424,6 +424,9 @@ func (w *ResticWrapper) run(commands ...Command) ([]byte, error) { func formatError(err error, stdErr string) error { parts := strings.Split(strings.TrimSuffix(stdErr, "\n"), "\n") if len(parts) > 1 { + if strings.Contains(parts[1], "signal terminated") { + return errors.New(strings.Join(append([]string{"deadline exceeded or signal terminated"}, parts[2:]...), " ")) + } return errors.New(strings.Join(parts[1:], " ")) } return err diff --git a/pkg/restic/restic_test.go b/pkg/restic/restic_test.go index 49a012a9..c4b45ae3 100644 --- a/pkg/restic/restic_test.go +++ b/pkg/restic/restic_test.go @@ -35,6 +35,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "testing" + "time" ) var ( @@ -462,6 +463,38 @@ func TestBackupRestoreWithArgs(t *testing.T) { } } +func TestBackupWithTimeout(t *testing.T) { + tempDir, err := os.MkdirTemp("", "stash-unit-test-") + if err != nil { + t.Error(err) + return + } + + w, err := setupTest(tempDir) + if err != nil { + t.Error(err) + return + } + defer cleanup(tempDir) + + // Initialize Repository + err = w.InitializeRepository() + if err != nil { + t.Error(err) + return + } + + duration := metav1.Duration{Duration: 10 * time.Millisecond} + w.config.Timeout = &duration + + backupOpt := BackupOptions{ + StdinPipeCommands: []Command{stdinPipeCommand}, + StdinFileName: fileName, + } + _, err = w.RunBackup(backupOpt) + assert.Error(t, err, "Timeout error") +} + func TestVerifyRepositoryIntegrity(t *testing.T) { tempDir, err := os.MkdirTemp("", "stash-unit-test-") if err != nil { From 4264514a1330eed18baf58c1ba30b44c5a8552a7 Mon Sep 17 00:00:00 2001 From: "Md. Ishtiaq Islam" Date: Mon, 16 Sep 2024 12:12:26 +0600 Subject: [PATCH 3/5] Refactor Signed-off-by: Md. Ishtiaq Islam --- pkg/restic/commands.go | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/pkg/restic/commands.go b/pkg/restic/commands.go index e954d1c6..9d37aeb8 100644 --- a/pkg/restic/commands.go +++ b/pkg/restic/commands.go @@ -178,12 +178,7 @@ func (w *ResticWrapper) backup(params backupParams) ([]byte, error) { args = w.appendMaxConnectionsFlag(args) command := Command{Name: ResticCMD, Args: args} - if w.config.Timeout != nil { - timeoutArgs := []interface{}{fmt.Sprintf("%f", w.config.Timeout.Seconds())} - timeoutArgs = append(timeoutArgs, ResticCMD) - timeoutArgs = append(timeoutArgs, args...) - command = Command{Name: TimeoutCMD, Args: timeoutArgs} - } + command = w.wrapWithTimeoutIfConfigured(command) return w.run(command) } @@ -210,12 +205,7 @@ func (w *ResticWrapper) backupFromStdin(options BackupOptions) ([]byte, error) { args = w.appendMaxConnectionsFlag(args) command := Command{Name: ResticCMD, Args: args} - if w.config.Timeout != nil { - timeoutArgs := []interface{}{fmt.Sprintf("%f", w.config.Timeout.Seconds())} - timeoutArgs = append(timeoutArgs, ResticCMD) - timeoutArgs = append(timeoutArgs, args...) - command = Command{Name: TimeoutCMD, Args: timeoutArgs} - } + command = w.wrapWithTimeoutIfConfigured(command) commands = append(commands, command) return w.run(commands...) @@ -264,12 +254,7 @@ func (w *ResticWrapper) restore(params restoreParams) ([]byte, error) { args = w.appendMaxConnectionsFlag(args) command := Command{Name: ResticCMD, Args: args} - if w.config.Timeout != nil { - timeoutArgs := []interface{}{fmt.Sprintf("%f", w.config.Timeout.Seconds())} - timeoutArgs = append(timeoutArgs, ResticCMD) - timeoutArgs = append(timeoutArgs, args...) - command = Command{Name: TimeoutCMD, Args: timeoutArgs} - } + command = w.wrapWithTimeoutIfConfigured(command) return w.run(command) } @@ -303,12 +288,7 @@ func (w *ResticWrapper) DumpOnce(dumpOptions DumpOptions) ([]byte, error) { args = w.appendInsecureTLSFlag(args) command := Command{Name: ResticCMD, Args: args} - if w.config.Timeout != nil { - timeoutArgs := []interface{}{fmt.Sprintf("%f", w.config.Timeout.Seconds())} - timeoutArgs = append(timeoutArgs, ResticCMD) - timeoutArgs = append(timeoutArgs, args...) - command = Command{Name: TimeoutCMD, Args: timeoutArgs} - } + command = w.wrapWithTimeoutIfConfigured(command) // first add restic command, then add StdoutPipeCommands commands := []Command{command} @@ -549,3 +529,12 @@ func (w *ResticWrapper) removeKey(params keyParams) ([]byte, error) { return w.run(Command{Name: ResticCMD, Args: args}) } + +func (w *ResticWrapper) wrapWithTimeoutIfConfigured(cmd Command) Command { + if w.config.Timeout != nil { + timeoutArgs := []interface{}{fmt.Sprintf("%f", w.config.Timeout.Seconds()), cmd.Name} + timeoutArgs = append(timeoutArgs, cmd.Args...) + return Command{Name: TimeoutCMD, Args: timeoutArgs} + } + return cmd +} From 7cb00e6324151acb0106ff774ff19a32f13171c4 Mon Sep 17 00:00:00 2001 From: Anisur Rahman Date: Tue, 17 Sep 2024 16:02:02 +0600 Subject: [PATCH 4/5] Add redic option to manifest Signed-off-by: Anisur Rahman --- apis/addons/v1alpha1/zz_generated.deepcopy.go | 1 + apis/config/v1alpha1/zz_generated.deepcopy.go | 1 + apis/core/v1alpha1/restoresession_types.go | 4 ++ apis/core/v1alpha1/zz_generated.deepcopy.go | 6 +++ .../storage/v1alpha1/zz_generated.deepcopy.go | 1 + apis/zz_generated.deepcopy.go | 1 + crds/core.kubestash.com_restoresessions.yaml | 54 +++++++++++++++++++ 7 files changed, 68 insertions(+) diff --git a/apis/addons/v1alpha1/zz_generated.deepcopy.go b/apis/addons/v1alpha1/zz_generated.deepcopy.go index e1da3996..22133508 100644 --- a/apis/addons/v1alpha1/zz_generated.deepcopy.go +++ b/apis/addons/v1alpha1/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright AppsCode Inc. and Contributors diff --git a/apis/config/v1alpha1/zz_generated.deepcopy.go b/apis/config/v1alpha1/zz_generated.deepcopy.go index 56bd1218..5dac5c13 100644 --- a/apis/config/v1alpha1/zz_generated.deepcopy.go +++ b/apis/config/v1alpha1/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright AppsCode Inc. and Contributors diff --git a/apis/core/v1alpha1/restoresession_types.go b/apis/core/v1alpha1/restoresession_types.go index 04b09268..16965fde 100644 --- a/apis/core/v1alpha1/restoresession_types.go +++ b/apis/core/v1alpha1/restoresession_types.go @@ -106,6 +106,10 @@ type ManifestRestoreOptions struct { // ZooKeeper specifies the options for selecting particular ZooKeeper components to restore in manifest restore // +optional ZooKeeper *KubeDBManifestOptions `json:"zooKeeper,omitempty"` + + // Redis specifies the options for selecting particular Redis components to restore in manifest restore + // +optional + Redis *KubeDBManifestOptions `json:"redis,omitempty"` } type MSSQLServerManifestOptions struct { diff --git a/apis/core/v1alpha1/zz_generated.deepcopy.go b/apis/core/v1alpha1/zz_generated.deepcopy.go index 19894d7d..1f1413ce 100644 --- a/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright AppsCode Inc. and Contributors @@ -1123,6 +1124,11 @@ func (in *ManifestRestoreOptions) DeepCopyInto(out *ManifestRestoreOptions) { *out = new(KubeDBManifestOptions) (*in).DeepCopyInto(*out) } + if in.Redis != nil { + in, out := &in.Redis, &out.Redis + *out = new(KubeDBManifestOptions) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManifestRestoreOptions. diff --git a/apis/storage/v1alpha1/zz_generated.deepcopy.go b/apis/storage/v1alpha1/zz_generated.deepcopy.go index 2be96888..c9ea9803 100644 --- a/apis/storage/v1alpha1/zz_generated.deepcopy.go +++ b/apis/storage/v1alpha1/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright AppsCode Inc. and Contributors diff --git a/apis/zz_generated.deepcopy.go b/apis/zz_generated.deepcopy.go index 40d4e350..6ee74efd 100644 --- a/apis/zz_generated.deepcopy.go +++ b/apis/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright AppsCode Inc. and Contributors diff --git a/crds/core.kubestash.com_restoresessions.yaml b/crds/core.kubestash.com_restoresessions.yaml index c66bb079..72c033e2 100644 --- a/crds/core.kubestash.com_restoresessions.yaml +++ b/crds/core.kubestash.com_restoresessions.yaml @@ -24390,6 +24390,60 @@ spec: type: object x-kubernetes-map-type: atomic type: object + redis: + description: Redis specifies the options for selecting particular + Redis components to restore in manifest restore + properties: + authSecret: + description: AuthSecret specifies whether to restore the AuthSecret + manifest or not + type: boolean + authSecretName: + description: AuthSecretName specifies new name of the AuthSecret + yaml after restore + type: string + configSecret: + description: ConfigSecret specifies whether to restore the + ConfigSecret manifest or not + type: boolean + configSecretName: + description: ConfigSecretName specifies new name of the ConfigSecret + yaml after restore + type: string + db: + description: DB specifies whether to restore the DB manifest + or not + type: boolean + dbName: + description: DBName specifies the new name of the DB yaml + after restore + type: string + initScript: + description: InitScript specifies whether to restore the InitScript + manifest or not + type: boolean + tlsIssuerRef: + description: TLSIssuerRef specifies the name of the IssuerRef + used for TLS configurations for both client and server + properties: + apiGroup: + description: APIGroup is the group for the resource being + referenced. If APIGroup is not specified, the specified + Kind must be in the core API group. For any other third-party + types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + required: + - kind + - name + type: object + x-kubernetes-map-type: atomic + type: object restoreNamespace: description: RestoreNamespace specifies the Namespace where the restored files will be applied From 9cbda1e7f2b17996ec3107d588578448a4edd782 Mon Sep 17 00:00:00 2001 From: "Md. Ishtiaq Islam" Date: Wed, 18 Sep 2024 14:26:54 +0600 Subject: [PATCH 5/5] Resolve changes Signed-off-by: Md. Ishtiaq Islam --- .../v1alpha1/backupconfiguration_types.go | 4 ++-- apis/core/v1alpha1/backupsession_helpers.go | 6 +++--- apis/core/v1alpha1/backupsession_types.go | 8 ++++---- apis/core/v1alpha1/restoresession_helpers.go | 6 +++--- apis/core/v1alpha1/restoresession_types.go | 8 ++++---- apis/core/v1alpha1/zz_generated.deepcopy.go | 20 +++++++++---------- crds/core.kubestash.com_backupbatches.yaml | 12 +++++------ crds/core.kubestash.com_backupblueprints.yaml | 12 +++++------ ...re.kubestash.com_backupconfigurations.yaml | 12 +++++------ crds/core.kubestash.com_backupsessions.yaml | 16 +++++++-------- crds/core.kubestash.com_restoresessions.yaml | 16 +++++++-------- 11 files changed, 60 insertions(+), 60 deletions(-) diff --git a/apis/core/v1alpha1/backupconfiguration_types.go b/apis/core/v1alpha1/backupconfiguration_types.go index 45a71792..5a34cb25 100644 --- a/apis/core/v1alpha1/backupconfiguration_types.go +++ b/apis/core/v1alpha1/backupconfiguration_types.go @@ -132,10 +132,10 @@ type SessionConfig struct { // +optional RetryConfig *RetryConfig `json:"retryConfig,omitempty"` - // Timeout specifies the maximum duration of backup. Backup will be considered Failed + // BackupTimeout specifies the maximum duration of backup. Backup will be considered Failed // if backup tasks do not complete within this time limit. By default, KubeStash don't set any timeout for backup. // +optional - Timeout *metav1.Duration `json:"timeout,omitempty"` + BackupTimeout *metav1.Duration `json:"backupTimeout,omitempty"` // SessionHistoryLimit specifies how many backup Jobs and associate resources KubeStash should keep for debugging purpose. // The default value is 1. diff --git a/apis/core/v1alpha1/backupsession_helpers.go b/apis/core/v1alpha1/backupsession_helpers.go index 929c993e..edf3152e 100644 --- a/apis/core/v1alpha1/backupsession_helpers.go +++ b/apis/core/v1alpha1/backupsession_helpers.go @@ -245,12 +245,12 @@ func (b *BackupSession) checkFailureInRetentionPolicy() (bool, string) { } func (b *BackupSession) GetRemainingTimeoutDuration() (*metav1.Duration, error) { - if b.Spec.Timeout == nil || b.Status.Deadline == nil { + if b.Spec.BackupTimeout == nil || b.Status.BackupDeadline == nil { return nil, nil } currentTime := metav1.Now() - if b.Status.Deadline.Before(¤tTime) { + if b.Status.BackupDeadline.Before(¤tTime) { return nil, fmt.Errorf("deadline exceeded") } - return &metav1.Duration{Duration: b.Status.Deadline.Sub(currentTime.Time)}, nil + return &metav1.Duration{Duration: b.Status.BackupDeadline.Sub(currentTime.Time)}, nil } diff --git a/apis/core/v1alpha1/backupsession_types.go b/apis/core/v1alpha1/backupsession_types.go index 57af8866..9f094839 100644 --- a/apis/core/v1alpha1/backupsession_types.go +++ b/apis/core/v1alpha1/backupsession_types.go @@ -64,10 +64,10 @@ type BackupSessionSpec struct { // +optional RetryLeft int32 `json:"retryLeft,omitempty"` - // Timeout specifies the maximum duration of backup. Backup will be considered Failed + // BackupTimeout specifies the maximum duration of backup. Backup will be considered Failed // if backup tasks do not complete within this time limit. By default, KubeStash don't set any timeout for backup. // +optional - Timeout *metav1.Duration `json:"timeout,omitempty"` + BackupTimeout *metav1.Duration `json:"backupTimeout,omitempty"` } // BackupSessionStatus defines the observed state of BackupSession @@ -80,10 +80,10 @@ type BackupSessionStatus struct { // +optional Duration string `json:"duration,omitempty"` - // Deadline specifies the deadline of backup. Backup will be + // BackupDeadline specifies the deadline of backup. Backup will be // considered Failed if it does not complete within this deadline // +optional - Deadline *metav1.Time `json:"backupDeadline,omitempty"` + BackupDeadline *metav1.Time `json:"backupDeadline,omitempty"` // TotalSnapshots specifies the total number of snapshots created for this backupSession. // +optional diff --git a/apis/core/v1alpha1/restoresession_helpers.go b/apis/core/v1alpha1/restoresession_helpers.go index 6d5a516e..11121df2 100644 --- a/apis/core/v1alpha1/restoresession_helpers.go +++ b/apis/core/v1alpha1/restoresession_helpers.go @@ -183,12 +183,12 @@ func (rs *RestoreSession) GetDataSourceNamespace() string { } func (rs *RestoreSession) GetRemainingTimeoutDuration() (*metav1.Duration, error) { - if rs.Spec.Timeout == nil || rs.Status.Deadline == nil { + if rs.Spec.RestoreTimeout == nil || rs.Status.RestoreDeadline == nil { return nil, nil } currentTime := metav1.Now() - if rs.Status.Deadline.Before(¤tTime) { + if rs.Status.RestoreDeadline.Before(¤tTime) { return nil, fmt.Errorf("deadline exceeded") } - return &metav1.Duration{Duration: rs.Status.Deadline.Sub(currentTime.Time)}, nil + return &metav1.Duration{Duration: rs.Status.RestoreDeadline.Sub(currentTime.Time)}, nil } diff --git a/apis/core/v1alpha1/restoresession_types.go b/apis/core/v1alpha1/restoresession_types.go index 16965fde..5b737d57 100644 --- a/apis/core/v1alpha1/restoresession_types.go +++ b/apis/core/v1alpha1/restoresession_types.go @@ -64,10 +64,10 @@ type RestoreSessionSpec struct { // +optional Hooks *RestoreHooks `json:"hooks,omitempty"` - // Timeout specifies a duration that KubeStash should wait for the restore to be completed. + // RestoreTimeout specifies a duration that KubeStash should wait for the restore to be completed. // If the restore tasks do not finish within this time period, KubeStash will consider this restore as a failure. // +optional - Timeout *metav1.Duration `json:"timeout,omitempty"` + RestoreTimeout *metav1.Duration `json:"restoreTimeout,omitempty"` // ManifestOptions provide options to select particular manifest object to restore // +optional @@ -282,10 +282,10 @@ type RestoreSessionStatus struct { // +optional Duration string `json:"duration,omitempty"` - // Deadline specifies the deadline of restore. Restore will be + // RestoreDeadline specifies the deadline of restore. Restore will be // considered Failed if it does not complete within this deadline // +optional - Deadline *metav1.Time `json:"restoreDeadline,omitempty"` + RestoreDeadline *metav1.Time `json:"restoreDeadline,omitempty"` // TotalComponents represents the number of total components for this RestoreSession // +optional diff --git a/apis/core/v1alpha1/zz_generated.deepcopy.go b/apis/core/v1alpha1/zz_generated.deepcopy.go index 1f1413ce..a1ec3193 100644 --- a/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -598,8 +598,8 @@ func (in *BackupSessionSpec) DeepCopyInto(out *BackupSessionSpec) { *out = new(corev1.TypedLocalObjectReference) (*in).DeepCopyInto(*out) } - if in.Timeout != nil { - in, out := &in.Timeout, &out.Timeout + if in.BackupTimeout != nil { + in, out := &in.BackupTimeout, &out.BackupTimeout *out = new(metav1.Duration) **out = **in } @@ -618,8 +618,8 @@ func (in *BackupSessionSpec) DeepCopy() *BackupSessionSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BackupSessionStatus) DeepCopyInto(out *BackupSessionStatus) { *out = *in - if in.Deadline != nil { - in, out := &in.Deadline, &out.Deadline + if in.BackupDeadline != nil { + in, out := &in.BackupDeadline, &out.BackupDeadline *out = (*in).DeepCopy() } if in.TotalSnapshots != nil { @@ -1418,8 +1418,8 @@ func (in *RestoreSessionSpec) DeepCopyInto(out *RestoreSessionSpec) { *out = new(RestoreHooks) (*in).DeepCopyInto(*out) } - if in.Timeout != nil { - in, out := &in.Timeout, &out.Timeout + if in.RestoreTimeout != nil { + in, out := &in.RestoreTimeout, &out.RestoreTimeout *out = new(metav1.Duration) **out = **in } @@ -1448,8 +1448,8 @@ func (in *RestoreSessionStatus) DeepCopyInto(out *RestoreSessionStatus) { *out = new(bool) **out = **in } - if in.Deadline != nil { - in, out := &in.Deadline, &out.Deadline + if in.RestoreDeadline != nil { + in, out := &in.RestoreDeadline, &out.RestoreDeadline *out = (*in).DeepCopy() } if in.Components != nil { @@ -1630,8 +1630,8 @@ func (in *SessionConfig) DeepCopyInto(out *SessionConfig) { *out = new(RetryConfig) **out = **in } - if in.Timeout != nil { - in, out := &in.Timeout, &out.Timeout + if in.BackupTimeout != nil { + in, out := &in.BackupTimeout, &out.BackupTimeout *out = new(metav1.Duration) **out = **in } diff --git a/crds/core.kubestash.com_backupbatches.yaml b/crds/core.kubestash.com_backupbatches.yaml index 85ecc67b..790559ec 100644 --- a/crds/core.kubestash.com_backupbatches.yaml +++ b/crds/core.kubestash.com_backupbatches.yaml @@ -110,6 +110,12 @@ spec: description: BatchSession specifies the session configuration for the targets. properties: + backupTimeout: + description: BackupTimeout specifies the maximum duration of + backup. Backup will be considered Failed if backup tasks do + not complete within this time limit. By default, KubeStash + don't set any timeout for backup. + type: string hooks: description: Hooks specifies the backup hooks that should be executed before and/or after the backup. @@ -36194,12 +36200,6 @@ spec: type: array type: object type: array - timeout: - description: Timeout specifies the maximum duration of backup. - Backup will be considered Failed if backup tasks do not complete - within this time limit. By default, KubeStash don't set any - timeout for backup. - type: string type: object type: array targets: diff --git a/crds/core.kubestash.com_backupblueprints.yaml b/crds/core.kubestash.com_backupblueprints.yaml index ce16147a..f745accc 100644 --- a/crds/core.kubestash.com_backupblueprints.yaml +++ b/crds/core.kubestash.com_backupblueprints.yaml @@ -15716,6 +15716,12 @@ spec: type: object type: array type: object + backupTimeout: + description: BackupTimeout specifies the maximum duration + of backup. Backup will be considered Failed if backup + tasks do not complete within this time limit. By default, + KubeStash don't set any timeout for backup. + type: string hooks: description: Hooks specifies the backup hooks that should be executed before and/or after the backup. @@ -37239,12 +37245,6 @@ spec: debugging purpose. The default value is 1. format: int32 type: integer - timeout: - description: Timeout specifies the maximum duration of backup. - Backup will be considered Failed if backup tasks do not - complete within this time limit. By default, KubeStash - don't set any timeout for backup. - type: string type: object type: array type: object diff --git a/crds/core.kubestash.com_backupconfigurations.yaml b/crds/core.kubestash.com_backupconfigurations.yaml index e4297042..bd2a3165 100644 --- a/crds/core.kubestash.com_backupconfigurations.yaml +++ b/crds/core.kubestash.com_backupconfigurations.yaml @@ -14554,6 +14554,12 @@ spec: type: object type: array type: object + backupTimeout: + description: BackupTimeout specifies the maximum duration of + backup. Backup will be considered Failed if backup tasks do + not complete within this time limit. By default, KubeStash + don't set any timeout for backup. + type: string hooks: description: Hooks specifies the backup hooks that should be executed before and/or after the backup. @@ -34373,12 +34379,6 @@ spec: purpose. The default value is 1. format: int32 type: integer - timeout: - description: Timeout specifies the maximum duration of backup. - Backup will be considered Failed if backup tasks do not complete - within this time limit. By default, KubeStash don't set any - timeout for backup. - type: string type: object type: array target: diff --git a/crds/core.kubestash.com_backupsessions.yaml b/crds/core.kubestash.com_backupsessions.yaml index 214138a4..fe23c658 100644 --- a/crds/core.kubestash.com_backupsessions.yaml +++ b/crds/core.kubestash.com_backupsessions.yaml @@ -56,6 +56,12 @@ spec: description: BackupSessionSpec specifies the information related to the respective backup invoker and session. properties: + backupTimeout: + description: BackupTimeout specifies the maximum duration of backup. + Backup will be considered Failed if backup tasks do not complete + within this time limit. By default, KubeStash don't set any timeout + for backup. + type: string invoker: description: Invoker points to the respective BackupConfiguration or BackupBatch which is responsible for triggering this backup. @@ -87,19 +93,13 @@ spec: description: Session specifies the name of the session that triggered this backup type: string - timeout: - description: Timeout specifies the maximum duration of backup. Backup - will be considered Failed if backup tasks do not complete within - this time limit. By default, KubeStash don't set any timeout for - backup. - type: string type: object status: description: BackupSessionStatus defines the observed state of BackupSession properties: backupDeadline: - description: Deadline specifies the deadline of backup. Backup will - be considered Failed if it does not complete within this deadline + description: BackupDeadline specifies the deadline of backup. Backup + will be considered Failed if it does not complete within this deadline format: date-time type: string conditions: diff --git a/crds/core.kubestash.com_restoresessions.yaml b/crds/core.kubestash.com_restoresessions.yaml index 72c033e2..8f15ba2a 100644 --- a/crds/core.kubestash.com_restoresessions.yaml +++ b/crds/core.kubestash.com_restoresessions.yaml @@ -24503,6 +24503,12 @@ spec: x-kubernetes-map-type: atomic type: object type: object + restoreTimeout: + description: RestoreTimeout specifies a duration that KubeStash should + wait for the restore to be completed. If the restore tasks do not + finish within this time period, KubeStash will consider this restore + as a failure. + type: string target: description: Target indicates the target application where the data will be restored. The target must be in the same namespace as the @@ -24521,12 +24527,6 @@ spec: required: - name type: object - timeout: - description: Timeout specifies a duration that KubeStash should wait - for the restore to be completed. If the restore tasks do not finish - within this time period, KubeStash will consider this restore as - a failure. - type: string type: object status: description: RestoreSessionStatus defines the observed state of RestoreSession @@ -24716,8 +24716,8 @@ spec: - Unknown type: string restoreDeadline: - description: Deadline specifies the deadline of restore. Restore will - be considered Failed if it does not complete within this deadline + description: RestoreDeadline specifies the deadline of restore. Restore + will be considered Failed if it does not complete within this deadline format: date-time type: string targetFound: