-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathcommon.go
More file actions
320 lines (258 loc) · 11.7 KB
/
Copy pathcommon.go
File metadata and controls
320 lines (258 loc) · 11.7 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/*
Copyright 2020 The Fluid Authors.
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"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/fluid-cloudnative/fluid/pkg/common"
)
// **************************************************
// * Common structs/constants for runtimes/datasets *
// **************************************************
// Level describes configurations a tier needs. <br>
// Refer to <a href="https://docs.alluxio.io/os/user/stable/en/core-services/Caching.html#configuring-tiered-storage">Configuring Tiered Storage</a> for more info
type Level struct {
// Alias string `json:"alias,omitempty"`
// Medium Type of the tier. One of the three types: `MEM`, `SSD`, `HDD`
// +kubebuilder:validation:Enum=MEM;SSD;HDD
// +required
MediumType common.MediumType `json:"mediumtype"`
// VolumeType is the volume type of the tier. Should be one of the three types: `hostPath`, `emptyDir` and `volumeTemplate`.
// If not set, defaults to hostPath.
// +kubebuilder:default=hostPath
// +kubebuilder:validation:Enum=hostPath;emptyDir
// +optional
VolumeType common.VolumeType `json:"volumeType"`
// VolumeSource is the volume source of the tier. It follows the form of corev1.VolumeSource.
// For now, users should only specify VolumeSource when VolumeType is set to emptyDir.
VolumeSource VolumeSource `json:"volumeSource,omitempty"`
// File paths to be used for the tier. Multiple paths are supported.
// Multiple paths should be separated with comma. For example: "/mnt/cache1,/mnt/cache2".
// +kubebuilder:validation:MinLength=1
// +optional
Path string `json:"path,omitempty"`
// Quota for the whole tier. (e.g. 100Gi)
// Please note that if there're multiple paths used for this tierstore,
// the quota will be equally divided into these paths. If you'd like to
// set quota for each, path, see QuotaList for more information.
// +optional
Quota *resource.Quantity `json:"quota,omitempty"`
// QuotaList are quotas used to set quota on multiple paths. Quotas should be separated with comma.
// Quotas in this list will be set to paths with the same order in Path.
// For example, with Path defined with "/mnt/cache1,/mnt/cache2" and QuotaList set to "100Gi, 50Gi",
// then we get 100GiB cache storage under "/mnt/cache1" and 50GiB under "/mnt/cache2".
// Also note that num of quotas must be consistent with the num of paths defined in Path.
// +optional
// +kubebuilder:validation:Pattern:="^((\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+)))),)+((\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?)$"
QuotaList string `json:"quotaList,omitempty"`
// StorageType common.CacheStoreType `json:"storageType,omitempty"`
// float64 is not supported, https://github.com/kubernetes-sigs/controller-tools/issues/245
// Ratio of high watermark of the tier (e.g. 0.9)
High string `json:"high,omitempty"`
// Ratio of low watermark of the tier (e.g. 0.7)
Low string `json:"low,omitempty"`
}
// TieredStore is a description of the tiered store
type TieredStore struct {
// configurations for multiple tiers
Levels []Level `json:"levels,omitempty"`
}
// RuntimeManagement defines suggestions for runtime controllers to manage the runtime
type RuntimeManagement struct {
// CleanCachePolicy defines the policy of cleaning cache when shutting down the runtime
// +optional
CleanCachePolicy CleanCachePolicy `json:"cleanCachePolicy,omitempty"`
// MetadataSyncPolicy defines the policy of syncing metadata when setting up the runtime. If not set,
// +optional
MetadataSyncPolicy MetadataSyncPolicy `json:"metadataSyncPolicy,omitempty"`
}
// InitUsersSpec is a description of the initialize the users for runtime
type InitUsersSpec struct {
// Image for initialize the users for runtime(e.g. alluxio/alluxio-User init)
Image string `json:"image,omitempty"`
// Image Tag for initialize the users for runtime(e.g. 2.3.0-SNAPSHOT)
ImageTag string `json:"imageTag,omitempty"`
// One of the three policies: `Always`, `IfNotPresent`, `Never`
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
// Environment variables that will be used by initialize the users for runtime
Env map[string]string `json:"env,omitempty"`
// Resources that will be requested by initialize the users for runtime. <br>
// <br>
// Resources are not allowed for ephemeral containers. Ephemeral containers use spare resources
// already allocated to the pod.
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
}
// User explains the user and group to run a Container
type User struct {
// The uid to run the alluxio runtime
UID *int64 `json:"uid"`
// The gid to run the alluxio runtime
GID *int64 `json:"gid"`
// The user name to run the alluxio runtime
UserName string `json:"user"`
// The group name to run the alluxio runtime
GroupName string `json:"group"`
}
// HCFS Endpoint info
type HCFSStatus struct {
// Endpoint for accessing
Endpoint string `json:"endpoint,omitempty"`
// Underlayer HCFS Compatible Version
UnderlayerFileSystemVersion string `json:"underlayerFileSystemVersion,omitempty"`
}
// API Gateway
type APIGatewayStatus struct {
// Endpoint for accessing
Endpoint string `json:"endpoint,omitempty"`
}
// Metadata defines subgroup properties of metav1.ObjectMeta
type Metadata struct {
PodMetadata `json:",inline"`
Selector metav1.GroupKind `json:"selector,omitempty"`
}
// PodMetadata defines subgroup properties of metav1.ObjectMeta
type PodMetadata struct {
// Labels are labels of pod specification
Labels map[string]string `json:"labels,omitempty"`
// Annotations are annotations of pod specification
Annotations map[string]string `json:"annotations,omitempty"`
}
// VolumeSource defines volume source and volume claim template.
type VolumeSource struct {
corev1.VolumeSource `json:",inline"`
}
// CleanCachePolicy defines policies when cleaning cache
type CleanCachePolicy struct {
// Optional duration in seconds the cache needs to clean gracefully. May be decreased in delete runtime request.
// Value must be non-negative integer. The value zero indicates clean immediately via the timeout
// command (no opportunity to shut down).
// If this value is nil, the default grace period will be used instead.
// The grace period is the duration in seconds after the processes running in the pod are sent
// a termination signal and the time when the processes are forcibly halted with timeout command.
// Set this value longer than the expected cleanup time for your process.
// +kubebuilder:default=60
// +optional
GracePeriodSeconds *int32 `json:"gracePeriodSeconds,omitempty"`
// Optional max retry Attempts when cleanCache function returns an error after execution, runtime attempts
// to run it three more times by default. With Maximum Retry Attempts, you can customize the maximum number
// of retries. This gives you the option to continue processing retries.
// +kubebuilder:default=3
// +optional
MaxRetryAttempts *int32 `json:"maxRetryAttempts,omitempty"`
}
// MetadataSyncPolicy defines policies when syncing metadata
type MetadataSyncPolicy struct {
// AutoSync enables automatic metadata sync when setting up a runtime. If not set, it defaults to true.
// +optional
AutoSync *bool `json:"autoSync,omitempty"`
}
func (msb *MetadataSyncPolicy) AutoSyncEnabled() bool {
return msb == nil || msb.AutoSync == nil || *msb.AutoSync
}
// VersionSpec represents the settings for the version that fluid is orchestrating.
type VersionSpec struct {
// Image (e.g. alluxio/alluxio)
Image string `json:"image,omitempty"`
// Image tag (e.g. 2.3.0-SNAPSHOT)
ImageTag string `json:"imageTag,omitempty"`
// One of the three policies: `Always`, `IfNotPresent`, `Never`
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
}
// ************************************************
// * Common structs/constants for data operations *
// ************************************************
type Policy string
const (
// Once run data migrate once, default policy is Once
Once Policy = "Once"
// Cron run data migrate by cron
Cron Policy = "Cron"
// OnEvent run data migrate when event occurs
OnEvent Policy = "OnEvent"
)
// Condition explains the transitions on phase
type Condition struct {
// Type of condition, either `Complete` or `Failed`
Type common.ConditionType `json:"type"`
// Status of the condition, one of `True`, `False` or `Unknown`
Status corev1.ConditionStatus `json:"status"`
// Reason for the condition's last transition
Reason string `json:"reason,omitempty"`
// Message is a human-readable message indicating details about the transition
Message string `json:"message,omitempty"`
// LastProbeTime describes last time this condition was updated.
LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"`
// LastTransitionTime describes last time the condition transitioned from one status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
}
// AffinityPolicy the strategy for the affinity between Data Operation Pods.
type AffinityPolicy string
const (
DefaultAffinityStrategy AffinityPolicy = ""
RequireAffinityStrategy AffinityPolicy = "Require"
PreferAffinityStrategy AffinityPolicy = "Prefer"
)
type AffinityStrategy struct {
// Specifies the dependent preceding operation in a workflow. If not set, use the operation referred to by RunAfter.
// +optional
DependOn *ObjectRef `json:"dependOn,omitempty"`
// Policy one of: "", "Require", "Prefer"
// +optional
Policy AffinityPolicy `json:"policy,omitempty"`
Prefers []Prefer `json:"prefers,omitempty"`
Requires []Require `json:"requires,omitempty"`
}
// Prefer defines the label key and weight for generating a PreferredSchedulingTerm.
type Prefer struct {
Name string `json:"name"`
Weight int32 `json:"weight"`
}
// Require defines the label key for generating a NodeSelectorTerm.
type Require struct {
Name string `json:"name"`
}
type ObjectRef struct {
// API version of the referent operation
// +optional
APIVersion string `json:"apiVersion,omitempty"`
// Kind specifies the type of the referent operation
// +required
// +kubebuilder:validation:Enum=DataLoad;DataBackup;DataMigrate;DataProcess
Kind string `json:"kind"`
// Name specifies the name of the referent operation
// +required
Name string `json:"name"`
// Namespace specifies the namespace of the referent operation.
// +optional
Namespace string `json:"namespace,omitempty"`
}
type OperationRef struct {
ObjectRef `json:",inline"`
// AffinityStrategy specifies the pod affinity strategy with the referent operation.
// +optional
AffinityStrategy AffinityStrategy `json:"affinityStrategy,omitempty"`
}
type WaitingStatus struct {
// OperationComplete indicates if the preceding operation is complete
OperationComplete *bool `json:"operationComplete,omitempty"`
}
type ClientMetrics struct {
// Enabled decides whether to expose client metrics.
Enabled bool `json:"enabled,omitempty"`
// ScrapeTarget decides which fuse component will be scraped by Prometheus.
// It is a list separated by comma where supported items are [MountPod, Sidecar, All (indicates MountPod and Sidecar), None].
// Defaults to None when it is not explicitly set.
ScrapeTarget string `json:"scrapeTarget,omitempty"`
}