/
backup_session_types.go
172 lines (150 loc) · 6.74 KB
/
backup_session_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
Copyright AppsCode Inc. and Contributors
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.
*/
package v1beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kmapi "kmodules.xyz/client-go/api/v1"
)
const (
ResourceKindBackupSession = "BackupSession"
ResourceSingularBackupSession = "backupsession"
ResourcePluralBackupSession = "backupsessions"
)
// +genclient
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=backupsessions,singular=backupsession,categories={stash,appscode,all}
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Invoker-Type",type="string",JSONPath=".spec.invoker.kind"
// +kubebuilder:printcolumn:name="Invoker-Name",type="string",JSONPath=".spec.invoker.name"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"
// +kubebuilder:printcolumn:name="Duration",type="string",JSONPath=".status.sessionDuration"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
type BackupSession struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec BackupSessionSpec `json:"spec,omitempty"`
Status BackupSessionStatus `json:"status,omitempty"`
}
type BackupSessionSpec struct {
// Invoker refers to the BackupConfiguration or BackupBatch being used to invoke this backup session
// +optional
Invoker BackupInvokerRef `json:"invoker,omitempty"`
}
// +kubebuilder:validation:Enum=Pending;Skipped;Running;Succeeded;Failed;Unknown
type BackupSessionPhase string
const (
BackupSessionPending BackupSessionPhase = "Pending"
BackupSessionSkipped BackupSessionPhase = "Skipped"
BackupSessionRunning BackupSessionPhase = "Running"
BackupSessionSucceeded BackupSessionPhase = "Succeeded"
BackupSessionFailed BackupSessionPhase = "Failed"
BackupSessionUnknown BackupSessionPhase = "Unknown"
)
// +kubebuilder:validation:Enum=Succeeded;Failed
type HostBackupPhase string
const (
HostBackupSucceeded HostBackupPhase = "Succeeded"
HostBackupFailed HostBackupPhase = "Failed"
)
// +kubebuilder:validation:Enum=Pending;Succeeded;Running;Failed
type TargetPhase string
const (
TargetBackupPending TargetPhase = "Pending"
TargetBackupSucceeded TargetPhase = "Succeeded"
TargetBackupRunning TargetPhase = "Running"
TargetBackupFailed TargetPhase = "Failed"
)
type BackupSessionStatus struct {
// Phase indicates the overall phase of the backup process for this BackupSession. Phase will be "Succeeded" only if
// phase of all hosts are "Succeeded". If any of the host fail to complete backup, Phase will be "Failed".
// +optional
Phase BackupSessionPhase `json:"phase,omitempty"`
// SessionDuration specify total time taken to complete current backup session (sum of backup duration of all targets)
// +optional
SessionDuration string `json:"sessionDuration,omitempty"`
// Targets specify the backup status of individual targets
// +optional
Targets []BackupTargetStatus `json:"targets,omitempty"`
// Conditions shows condition of different operations/steps of the backup process
// +optional
Conditions []kmapi.Condition `json:"conditions,omitempty"`
}
type BackupTargetStatus struct {
// Ref refers to the backup target
// +optional
Ref TargetRef `json:"ref,omitempty"`
// TotalHosts specifies total number of hosts for this target that will be backed up for a BackupSession
// +optional
TotalHosts *int32 `json:"totalHosts,omitempty"`
// Phase indicates backup phase of this target
// +optional
Phase TargetPhase `json:"phase,omitempty"`
// Stats shows statistics of individual hosts for this backup session
// +optional
Stats []HostBackupStats `json:"stats,omitempty"`
// PreBackupActions specifies a list of actions that the backup process should execute before taking backup
// +optional
PreBackupActions []string `json:"preBackupActions,omitempty"`
// PostBackupActions specifies a list of actions that the backup process should execute after taking backup
// +optional
PostBackupActions []string `json:"postBackupActions,omitempty"`
}
type HostBackupStats struct {
// Hostname indicate name of the host that has been backed up
// +optional
Hostname string `json:"hostname,omitempty"`
// Phase indicates backup phase of this host
// +optional
Phase HostBackupPhase `json:"phase,omitempty"`
// Snapshots specifies the stats of individual snapshots that has been taken for this host in current backup session
// +optional
Snapshots []SnapshotStats `json:"snapshots,omitempty"`
// Duration indicates total time taken to complete backup for this hosts
// +optional
Duration string `json:"duration,omitempty"`
// Error indicates string value of error in case of backup failure
// +optional
Error string `json:"error,omitempty"`
}
type SnapshotStats struct {
// Name indicates the name of the backup snapshot created for this host
Name string `json:"name,omitempty"`
// Path indicates the directory that has been backed up in this snapshot
Path string `json:"path,omitempty"`
// TotalSize indicates the size of data to backup in target directory
TotalSize string `json:"totalSize,omitempty"`
// Uploaded indicates size of data uploaded to backend for this snapshot
Uploaded string `json:"uploaded,omitempty"`
// ProcessingTime indicates time taken to process the target data
ProcessingTime string `json:"processingTime,omitempty"`
// FileStats shows statistics of files of this snapshot
FileStats FileStats `json:"fileStats,omitempty"`
}
type FileStats struct {
// TotalFiles shows total number of files that has been backed up
TotalFiles *int64 `json:"totalFiles,omitempty"`
// NewFiles shows total number of new files that has been created since last backup
NewFiles *int64 `json:"newFiles,omitempty"`
// ModifiedFiles shows total number of files that has been modified since last backup
ModifiedFiles *int64 `json:"modifiedFiles,omitempty"`
// UnmodifiedFiles shows total number of files that has not been changed since last backup
UnmodifiedFiles *int64 `json:"unmodifiedFiles,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type BackupSessionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []BackupSession `json:"items,omitempty"`
}