Skip to content

Commit

Permalink
Update VolumeSnapshotterStats field (#47)
Browse files Browse the repository at this point in the history
Signed-off-by: Anisur Rahman <[email protected]>
  • Loading branch information
anisurrahman75 authored Oct 13, 2023
1 parent 8571043 commit 15eae58
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion apis/addons/v1alpha1/addon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type Task struct {
// Valid values are:
// - "Restic": The underlying tool is [restic](https://restic.net/).
// - "WalG": The underlying tool is [wal-g](https://github.com/wal-g/wal-g).
// +kubebuilder:validation:Enum=Restic;WalG
// +kubebuilder:validation:Enum=Restic;WalG;VolumeSnapshotter;
Driver apis.Driver `json:"driver,omitempty"`

// Executor specifies the type of entity that will execute the task. For example, it can be a Job,
Expand Down
15 changes: 13 additions & 2 deletions apis/core/v1alpha1/restoresession_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func (rs *RestoreSession) CalculatePhase() RestorePhase {
return componentsPhase
}

if componentsPhase == RestorePhaseUnknown {
return componentsPhase
}

return RestoreRunning
}

Expand All @@ -72,6 +76,7 @@ func (rs *RestoreSession) getComponentsPhase() RestorePhase {

failedComponent := 0
successfulComponent := 0
unknownComponentPhase := 0

for _, c := range rs.Status.Components {
if c.Phase == RestoreSucceeded {
Expand All @@ -80,6 +85,9 @@ func (rs *RestoreSession) getComponentsPhase() RestorePhase {
if c.Phase == RestoreFailed {
failedComponent++
}
if c.Phase == RestorePhaseUnknown {
unknownComponentPhase++
}
}

totalComponents := int(rs.Status.TotalComponents)
Expand All @@ -88,8 +96,11 @@ func (rs *RestoreSession) getComponentsPhase() RestorePhase {
return RestoreSucceeded
}

if successfulComponent+failedComponent == totalComponents {
return RestoreFailed
if successfulComponent+failedComponent+unknownComponentPhase == totalComponents {
if failedComponent > 0 {
return RestoreFailed
}
return RestorePhaseUnknown
}

return RestoreRunning
Expand Down
13 changes: 7 additions & 6 deletions apis/core/v1alpha1/restoresession_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,16 @@ type RestoreSessionStatus struct {
}

// RestorePhase represents the current state of the restore process
// +kubebuilder:validation:Enum=Pending;Running;Failed;Succeeded;Invalid
// +kubebuilder:validation:Enum=Pending;Running;Failed;Succeeded;Invalid;Unknown
type RestorePhase string

const (
RestorePending RestorePhase = "Pending"
RestoreRunning RestorePhase = "Running"
RestoreFailed RestorePhase = "Failed"
RestoreSucceeded RestorePhase = "Succeeded"
RestoreInvalid RestorePhase = "Invalid"
RestorePending RestorePhase = "Pending"
RestoreRunning RestorePhase = "Running"
RestoreFailed RestorePhase = "Failed"
RestoreSucceeded RestorePhase = "Succeeded"
RestoreInvalid RestorePhase = "Invalid"
RestorePhaseUnknown RestorePhase = "Unknown"
)

// ComponentRestoreStatus represents the restore status of individual components
Expand Down
3 changes: 2 additions & 1 deletion apis/storage/v1alpha1/snapshot_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ type Component struct {

// VolumeSnapshotterStats specifies the "VolumeSnapshotter" driver specific information
// +optional
VolumeSnapshotterStats *VolumeSnapshotterStats `json:"volumeSnapshotterStats,omitempty"`
VolumeSnapshotterStats []VolumeSnapshotterStats `json:"volumeSnapshotterStats,omitempty"`

// WalSegments specifies a list of wall segment for individual component
WalSegments []WalSegment `json:"walSegments,omitempty"`
Expand Down Expand Up @@ -235,6 +235,7 @@ type ResticStats struct {

// VolumeSnapshotterStats specifies the "VolumeSnapshotter" driver specific information
type VolumeSnapshotterStats struct {
PvcName string `json:"pvcName,omitempty"`
VolumeSnapshotName string `json:"volumeSnapshotName,omitempty"`
}

Expand Down
4 changes: 2 additions & 2 deletions apis/storage/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crds/addons.kubestash.com_addons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ spec:
- enum:
- Restic
- WalG
- VolumeSnapshotter
description: 'Driver specifies the underlying tool that will
be used to upload the data to the backend storage. Valid values
are: - "Restic": The underlying tool is [restic](https://restic.net/).
Expand Down Expand Up @@ -2367,6 +2368,7 @@ spec:
- enum:
- Restic
- WalG
- VolumeSnapshotter
description: 'Driver specifies the underlying tool that will
be used to upload the data to the backend storage. Valid values
are: - "Restic": The underlying tool is [restic](https://restic.net/).
Expand Down
2 changes: 2 additions & 0 deletions crds/core.kubestash.com_restoresessions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23294,6 +23294,7 @@ spec:
- Failed
- Succeeded
- Invalid
- Unknown
type: string
type: object
description: Components represents the individual component restore
Expand Down Expand Up @@ -23460,6 +23461,7 @@ spec:
- Failed
- Succeeded
- Invalid
- Unknown
type: string
targetFound:
description: TargetFound specifies whether the restore target exist
Expand Down
14 changes: 10 additions & 4 deletions crds/storage.kubestash.com_snapshots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,16 @@ spec:
volumeSnapshotterStats:
description: VolumeSnapshotterStats specifies the "VolumeSnapshotter"
driver specific information
properties:
volumeSnapshotName:
type: string
type: object
items:
description: VolumeSnapshotterStats specifies the "VolumeSnapshotter"
driver specific information
properties:
pvcName:
type: string
volumeSnapshotName:
type: string
type: object
type: array
walSegments:
description: WalSegments specifies a list of wall segment for
individual component
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module kubestash.dev/apimachinery

go 1.18
go 1.20

require (
github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2
Expand Down

0 comments on commit 15eae58

Please sign in to comment.