-
Notifications
You must be signed in to change notification settings - Fork 27
/
nebularestore_types.go
146 lines (123 loc) · 5.43 KB
/
nebularestore_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
/*
Copyright 2023 Vesoft Inc.
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 v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/vesoft-inc/nebula-go/v3/nebula"
)
// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName="nr"
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.phase`,description="The current status of the restore"
// +kubebuilder:printcolumn:name="RESTORED-CLUSTER",type=string,JSONPath=`.status.clusterName`,description="The name of restored nebula cluster"
// +kubebuilder:printcolumn:name="Started",type=date,JSONPath=`.status.timeStarted`,description="The time at which the restore was started"
// +kubebuilder:printcolumn:name="Completed",type=date,JSONPath=`.status.timeCompleted`,description="The time at which the restore was completed"
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
type NebulaRestore struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec RestoreSpec `json:"spec,omitempty"`
Status RestoreStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// NebulaRestoreList contains a list of NebulaRestore.
type NebulaRestoreList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NebulaRestore `json:"items"`
}
// RestoreConditionType represents a valid condition of a Restore.
type RestoreConditionType string
const (
// RestoreComplete means the restore has successfully executed and the
// backup data has been loaded into nebula cluster.
RestoreComplete RestoreConditionType = "Complete"
// RestoreMetadComplete means metad pods have been rebuilt from the backup data
RestoreMetadComplete RestoreConditionType = "MetadComplete"
// RestoreStoragedCompleted means storaged pods have been rebuilt from the backup data
RestoreStoragedCompleted RestoreConditionType = "StoragedComplete"
// RestoreFailed means the restore has failed.
RestoreFailed RestoreConditionType = "Failed"
// RestoreInvalid means invalid restore CR.
RestoreInvalid RestoreConditionType = "Invalid"
)
// RestoreCondition describes the observed state of a Restore at a certain point.
type RestoreCondition struct {
// Type of the condition.
Type RestoreConditionType `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status corev1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
// +optional
Reason string `json:"reason,omitempty"`
// A human-readable message indicating details about the transition.
// +optional
Message string `json:"message,omitempty"`
}
type RestoreConfig struct {
NamespacedObjectReference `json:",inline"`
// The name of the backup file.
BackupName string `json:"backupName,omitempty"`
// Concurrency is used to control the number of concurrent file downloads during data restoration.
// +kubebuilder:default=5
// +optional
Concurrency int32 `json:"concurrency,omitempty"`
// StorageProvider configures where and how backups should be stored.
StorageProvider `json:",inline"`
}
// RestoreSpec contains the specification for a restore of a nebula cluster backup.
type RestoreSpec struct {
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty"`
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// +optional
AutoRemoveFailed bool `json:"autoRemoveFailed,omitempty"`
// +optional
Config *RestoreConfig `json:"config,omitempty"`
}
// RestoreStatus represents the current status of a nebula cluster restore.
type RestoreStatus struct {
// TimeStarted is the time at which the restore was started.
// +nullable
TimeStarted *metav1.Time `json:"timeStarted,omitempty"`
// TimeCompleted is the time at which the restore was completed.
// +nullable
TimeCompleted *metav1.Time `json:"timeCompleted,omitempty"`
// ClusterName is the name of restored nebula cluster.
ClusterName string `json:"clusterName,omitempty"`
// Phase is a user readable state inferred from the underlying Restore conditions
Phase RestoreConditionType `json:"phase,omitempty"`
// +nullable
Conditions []RestoreCondition `json:"conditions,omitempty"`
// +nullable
Partitions map[string][]*nebula.HostAddr `json:"partitions,omitempty"`
// +nullable
Checkpoints map[string]map[string]string `json:"checkpoints,omitempty"`
// The Metad data files download is complete.
MetaDownload bool `json:"metaDownload"`
// The Storaged data files download is complete.
StorageDownload bool `json:"storageDownload"`
}
func init() {
SchemeBuilder.Register(&NebulaRestore{}, &NebulaRestoreList{})
}