-
Notifications
You must be signed in to change notification settings - Fork 74
/
localvolumemigrate_types.go
91 lines (71 loc) · 3.65 KB
/
localvolumemigrate_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
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
VolumeMigrateCompletedAnnoKey = "hwameistor.io/volume-migrate-state"
MigrateStarted = "migrateStarted"
MigrateCompleted = "migrateCompleted"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// LocalVolumeMigrateSpec defines the desired state of LocalVolumeMigrate
type LocalVolumeMigrateSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
// Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
// *** custom section of the operations ***
VolumeName string `json:"volumeName"`
// source NodeNames
SourceNode string `json:"sourceNode"`
// suggested target NodeNames
TargetNodesSuggested []string `json:"targetNodesSuggested"`
// *** common section of all the operations ***
// +kubebuilder:default:=true
MigrateAllVols bool `json:"migrateAllVols,omitempty"`
// +kubebuilder:default:=false
Abort bool `json:"abort,omitempty"`
}
// LocalVolumeMigrateStatus defines the observed state of LocalVolumeMigrate
type LocalVolumeMigrateStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
// Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
// record the volume's replica number, it will be set internally
OriginalReplicaNumber int64 `json:"originalReplicaNumber,omitempty"`
// record the node where the specified replica is migrated to
TargetNode string `json:"targetNode,omitempty"`
// record all the volumes to be migrated
Volumes []string `json:"volumes,omitempty"`
// State of the operation, e.g. submitted, started, completed, abort, ...
State State `json:"state,omitempty"`
// error message to describe some states
Message string `json:"message,omitempty"`
}
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// LocalVolumeMigrate is the Schema for the localvolumemigrates API
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=localvolumemigrates,scope=Cluster,shortName=lvmigrate
// +kubebuilder:printcolumn:name="volume",type=string,JSONPath=`.spec.volumeName`,description="Name of the volume to be migrated"
// +kubebuilder:printcolumn:name="from",type=string,JSONPath=`.spec.sourceNode`,description="Node name of the volume replica to be migrated"
// +kubebuilder:printcolumn:name="to",type=string,JSONPath=`.status.targetNode`,description="Node name of the new volume replica"
// +kubebuilder:printcolumn:name="state",type=string,JSONPath=`.status.state`,description="State of the migration"
// +kubebuilder:printcolumn:name="age",type=date,JSONPath=`.metadata.creationTimestamp`
type LocalVolumeMigrate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec LocalVolumeMigrateSpec `json:"spec,omitempty"`
Status LocalVolumeMigrateStatus `json:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// LocalVolumeMigrateList contains a list of LocalVolumeMigrate
type LocalVolumeMigrateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []LocalVolumeMigrate `json:"items"`
}
func init() {
SchemeBuilder.Register(&LocalVolumeMigrate{}, &LocalVolumeMigrateList{})
}