Skip to content

Commit

Permalink
Add disruption condition at snapshot
Browse files Browse the repository at this point in the history
Signed-off-by: Md. Ishtiaq Islam <[email protected]>
  • Loading branch information
ishtiaqhimel committed Sep 23, 2024
1 parent 6f40843 commit bd0f67d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
7 changes: 6 additions & 1 deletion apis/core/v1alpha1/backupsession_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func (b *BackupSession) CalculatePhase() BackupSessionPhase {
b.failedToExecutePostBackupHooks() ||
b.failedToApplyRetentionPolicy() ||
b.verificationsFailed() ||
b.sessionHistoryCleanupFailed()) {
b.sessionHistoryCleanupFailed() ||
b.retentionPolicyDisrupted()) {
return BackupSessionFailed
}

Expand All @@ -76,6 +77,10 @@ func (b *BackupSession) CalculatePhase() BackupSessionPhase {
return BackupSessionRunning
}

func (b *BackupSession) retentionPolicyDisrupted() bool {
return cutil.IsConditionTrue(b.Status.Conditions, TypeRetentionPolicyDisrupted)
}

func (b *BackupSession) sessionHistoryCleanupFailed() bool {
return cutil.IsConditionFalse(b.Status.Conditions, TypeSessionHistoryCleaned)
}
Expand Down
4 changes: 4 additions & 0 deletions apis/core/v1alpha1/backupsession_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ const (
TypeSnapshotsEnsured = "SnapshotsEnsured"
ReasonSuccessfullyEnsuredSnapshots = "SuccessfullyEnsuredSnapshots"
ReasonFailedToEnsureSnapshots = "FailedToEnsureSnapshots"

// TypeRetentionPolicyDisrupted indicates whether RetentionPolicy disrupted or not
TypeRetentionPolicyDisrupted = "RetentionPolicyDisrupted"
ReasonFailedToCompleteRetentionPolicyDueToDisruption = "FailedToCompleteRetentionPolicyDueToDisruption"
)

//+kubebuilder:object:root=true
Expand Down
3 changes: 2 additions & 1 deletion apis/core/v1alpha1/restoresession_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ func (rs *RestoreSession) CalculatePhase() RestorePhase {
if cutil.IsConditionTrue(rs.Status.Conditions, TypeMetricsPushed) &&
(cutil.IsConditionFalse(rs.Status.Conditions, TypePreRestoreHooksExecutionSucceeded) ||
cutil.IsConditionFalse(rs.Status.Conditions, TypePostRestoreHooksExecutionSucceeded) ||
cutil.IsConditionFalse(rs.Status.Conditions, TypeRestoreExecutorEnsured)) {
cutil.IsConditionFalse(rs.Status.Conditions, TypeRestoreExecutorEnsured) ||
cutil.IsConditionTrue(rs.Status.Conditions, TypeRestoreDisrupted)) {
return RestoreFailed
}

Expand Down
3 changes: 3 additions & 0 deletions apis/core/v1alpha1/restoresession_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ const (

TypeRestoreTargetFound = "RestoreTargetFound"
ReasonUnableToCheckTargetAvailability = "UnableToCheckTargetAvailability"

TypeRestoreDisrupted = "RestoreDisrupted"
ReasonFailedToCompleteDueToDisruption = "FailedToCompleteDueToDisruption"
)

//+kubebuilder:object:root=true
Expand Down
3 changes: 2 additions & 1 deletion apis/storage/v1alpha1/snapshot_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func (_ Snapshot) CustomResourceDefinition() *apiextensions.CustomResourceDefini

func (s *Snapshot) CalculatePhase() SnapshotPhase {
if cutil.IsConditionFalse(s.Status.Conditions, TypeSnapshotMetadataUploaded) ||
cutil.IsConditionFalse(s.Status.Conditions, TypeRecentSnapshotListUpdated) {
cutil.IsConditionFalse(s.Status.Conditions, TypeRecentSnapshotListUpdated) ||
cutil.IsConditionTrue(s.Status.Conditions, TypeBackupDisrupted) {
return SnapshotFailed
}
if s.GetComponentsPhase() == SnapshotPending {
Expand Down
3 changes: 3 additions & 0 deletions apis/storage/v1alpha1/snapshot_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ const (
TypeRecentSnapshotListUpdated = "RecentSnapshotListUpdated"
ReasonFailedToUpdateRecentSnapshotList = "FailedToUpdateRecentSnapshotList"
ReasonSuccessfullyUpdatedRecentSnapshotList = "SuccessfullyUpdatedRecentSnapshotList"

TypeBackupDisrupted = "BackupDisrupted"
ReasonFailedToCompleteDueToDisruption = "FailedToCompleteDueToDisruption"
)

//+kubebuilder:object:root=true
Expand Down

0 comments on commit bd0f67d

Please sign in to comment.