Skip to content

Commit 2e54a60

Browse files
committed
Fix API review comments for CnsNodeVMBatachAttachment API
1 parent 9d4ed85 commit 2e54a60

File tree

11 files changed

+201
-169
lines changed

11 files changed

+201
-169
lines changed

pkg/apis/cnsoperator/cnsnodevmbatchattachment/v1alpha1/cnsnodebatchvmattachment_types.go

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,39 @@ import (
2121
)
2222

2323
// DiskMode describes the desired mode to use when attaching the volume.
24+
// +kubebuilder:validation:Enum=independent_persistent;persistent;independent_nonpersistent
2425
type DiskMode string
2526

2627
const (
27-
// By setting DiskMode to independent_persistent, a virtual machine's disk is not captured in snapshots and
28+
// IndependentPersistent is the diskMode in which, a virtual machine's disk is not captured in snapshots and
2829
// changes are permanently written to the disk, regardless of snapshot operations.
2930
IndependentPersistent DiskMode = "independent_persistent"
30-
// Changes are immediately and permanently written to the virtual disk.
31+
// Persistent diskMode changes are immediately and permanently written to the virtual disk.
3132
Persistent DiskMode = "persistent"
3233
// Changes to virtual disk are made to a redo log and discarded at power off.
3334
// It is not affected by snapshots.
3435
IndependentNonPersistent = "independent_nonpersistent"
3536
)
3637

37-
// The sharing mode of the virtual disk.
38+
// SharingMode is the sharing mode of the virtual disk.
39+
// +kubebuilder:validation:Enum=sharingMultiWriter;sharingNone
3840
type SharingMode string
3941

4042
const (
41-
// The virtual disk is shared between multiple virtual machines.
43+
// SharingMultiWriter: The virtual disk is shared between multiple virtual machines.
4244
SharingMultiWriter SharingMode = "sharingMultiWriter"
43-
// The virtual disk is not shared.
45+
// SharingNone: The virtual disk is not shared.
4446
SharingNone SharingMode = "sharingNone"
4547
)
4648

47-
// CnsNodeVmBatchAttachmentSpec defines the desired state of CnsNodeVmBatchAttachment
49+
// CnsNodeVMBatchAttachmentSpec defines the desired state of CnsNodeVMBatchAttachment
4850
// +k8s:openapi-gen=true
49-
type CnsNodeVmBatchAttachmentSpec struct {
51+
type CnsNodeVMBatchAttachmentSpec struct {
52+
// +required
53+
5054
// NodeUUID indicates the UUID of the node where the volume needs to be attached to.
5155
// Here NodeUUID is the instance UUID of the node.
52-
NodeUUID string `json:"nodeuuid"`
56+
NodeUUID string `json:"nodeUUID"`
5357

5458
// +listType=map
5559
// +listMapKey=name
@@ -65,21 +69,31 @@ type VolumeSpec struct {
6569
}
6670

6771
type PersistentVolumeClaimSpec struct {
72+
// +required
73+
6874
// ClaimName is the PVC name.
6975
ClaimName string `json:"claimName"`
76+
// +optional
77+
7078
// DiskMode is the desired mode to use when attaching the volume
7179
DiskMode DiskMode `json:"diskMode,omitempty"`
72-
// SharingMode indicates the shraring mode if the virtual disk while attaching.
80+
// +optional
81+
82+
// SharingMode indicates the sharing mode if the virtual disk while attaching.
7383
SharingMode SharingMode `json:"sharingMode,omitempty"`
84+
// +optional
85+
7486
// ControllerKey is the object key for the controller object for this device.
7587
ControllerKey string `json:"controllerKey,omitempty"`
88+
// +optional
89+
7690
// UnitNumber of this device on its controller.
7791
UnitNumber string `json:"unitNumber,omitempty"`
7892
}
7993

80-
// CnsNodeVmBatchAttachmentStatus defines the observed state of CnsNodeVmBatchAttachment
94+
// CnsNodeVMBatchAttachmentStatus defines the observed state of CnsNodeVMBatchAttachment
8195
// +k8s:openapi-gen=true
82-
type CnsNodeVmBatchAttachmentStatus struct {
96+
type CnsNodeVMBatchAttachmentStatus struct {
8397
// Error is the overall error status for the instance.
8498
Error string `json:"error,omitempty"`
8599
// +listType=map
@@ -98,6 +112,7 @@ type VolumeStatus struct {
98112
type PersistentVolumeClaimStatus struct {
99113
// ClaimName is the PVC name.
100114
ClaimName string `json:"claimName"`
115+
// Attached indicates the attach status of a PVC.
101116
// If volume is not attached, Attached will be set to false.
102117
// If volume is attached, Attached will be set to true.
103118
// If volume is detached successfully, its entry will be removed from VolumeStatus.
@@ -106,30 +121,33 @@ type PersistentVolumeClaimStatus struct {
106121
Error string `json:"error,omitempty"`
107122
// CnsVolumeID is the volume ID for the PVC.
108123
CnsVolumeID string `json:"cnsVolumeId,omitempty"`
109-
// Diskuuid is the ID obtained when volume is attached to a VM.
110-
Diskuuid string `json:"diskuuid,omitempty"`
124+
// DiskUUID is the ID obtained when volume is attached to a VM.
125+
DiskUUID string `json:"DiskUUID,omitempty"`
111126
}
112127

113128
// +genclient
114129
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
115130

116131
// +k8s:openapi-gen=true
117132
// +kubebuilder:subresource:status
133+
// +kubebuilder:object:root=true
134+
// +kubebuilder:resource:shortName=batchattach
135+
// +kubebuilder:printcolumn:name="NodeUUID",type="string",JSONPath=".spec.nodeUUID"
118136

119-
// CnsNodeVmBatchAttachment is the Schema for the cnsnodevmbatchattachments API
120-
type CnsNodeVmBatchAttachment struct {
137+
// CnsNodeVMBatchAttachment is the Schema for the cnsnodevmbatchattachments API
138+
type CnsNodeVMBatchAttachment struct {
121139
metav1.TypeMeta `json:",inline"`
122140
metav1.ObjectMeta `json:"metadata,omitempty"`
123141

124-
Spec CnsNodeVmBatchAttachmentSpec `json:"spec,omitempty"`
125-
Status CnsNodeVmBatchAttachmentStatus `json:"status,omitempty"`
142+
Spec CnsNodeVMBatchAttachmentSpec `json:"spec,omitempty"`
143+
Status CnsNodeVMBatchAttachmentStatus `json:"status,omitempty"`
126144
}
127145

128146
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
129147

130-
// CnsNodeVmBatchAttachmentList contains a list of CnsNodeVmBatchAttachment
131-
type CnsNodeVmBatchAttachmentList struct {
148+
// CnsNodeVMBatchAttachmentList contains a list of CnsNodeVMBatchAttachment
149+
type CnsNodeVMBatchAttachmentList struct {
132150
metav1.TypeMeta `json:",inline"`
133151
metav1.ListMeta `json:"metadata,omitempty"`
134-
Items []CnsNodeVmBatchAttachment `json:"items"`
152+
Items []CnsNodeVMBatchAttachment `json:"items"`
135153
}

pkg/apis/cnsoperator/cnsnodevmbatchattachment/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/cnsoperator/config/cns.vmware.com_cnsnodevmbatchattachments.yaml

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,22 @@ metadata:
88
spec:
99
group: cns.vmware.com
1010
names:
11-
kind: CnsNodeVmBatchAttachment
12-
listKind: CnsNodeVmBatchAttachmentList
11+
kind: CnsNodeVMBatchAttachment
12+
listKind: CnsNodeVMBatchAttachmentList
1313
plural: cnsnodevmbatchattachments
14+
shortNames:
15+
- batchattach
1416
singular: cnsnodevmbatchattachment
1517
scope: Namespaced
1618
versions:
17-
- name: v1alpha1
19+
- additionalPrinterColumns:
20+
- jsonPath: .spec.nodeUUID
21+
name: NodeUUID
22+
type: string
23+
name: v1alpha1
1824
schema:
1925
openAPIV3Schema:
20-
description: CnsNodeVmBatchAttachment is the Schema for the cnsnodevmbatchattachments
26+
description: CnsNodeVMBatchAttachment is the Schema for the cnsnodevmbatchattachments
2127
API
2228
properties:
2329
apiVersion:
@@ -38,13 +44,13 @@ spec:
3844
metadata:
3945
type: object
4046
spec:
41-
description: CnsNodeVmBatchAttachmentSpec defines the desired state of
42-
CnsNodeVmBatchAttachment
47+
description: CnsNodeVMBatchAttachmentSpec defines the desired state of
48+
CnsNodeVMBatchAttachment
4349
properties:
44-
nodeuuid:
50+
nodeUUID:
4551
description: |-
4652
NodeUUID indicates the UUID of the node where the volume needs to be attached to.
47-
Here NodeUUID is the bios UUID of the node.
53+
Here NodeUUID is the instance UUID of the node.
4854
type: string
4955
volumes:
5056
description: VolumeSpec reflects the desired state for each volume.
@@ -67,10 +73,17 @@ spec:
6773
diskMode:
6874
description: DiskMode is the desired mode to use when attaching
6975
the volume
76+
enum:
77+
- independent_persistent
78+
- persistent
79+
- independent_nonpersistent
7080
type: string
7181
sharingMode:
72-
description: SharingMode indicates the shraring mode if
73-
the virtual disk while attaching.
82+
description: SharingMode indicates the sharing mode if the
83+
virtual disk while attaching.
84+
enum:
85+
- sharingMultiWriter
86+
- sharingNone
7487
type: string
7588
unitNumber:
7689
description: UnitNumber of this device on its controller.
@@ -87,12 +100,12 @@ spec:
87100
- name
88101
x-kubernetes-list-type: map
89102
required:
90-
- nodeuuid
103+
- nodeUUID
91104
- volumes
92105
type: object
93106
status:
94-
description: CnsNodeVmBatchAttachmentStatus defines the observed state
95-
of CnsNodeVmBatchAttachment
107+
description: CnsNodeVMBatchAttachmentStatus defines the observed state
108+
of CnsNodeVMBatchAttachment
96109
properties:
97110
error:
98111
description: Error is the overall error status for the instance.
@@ -108,8 +121,13 @@ spec:
108121
description: PersistentVolumeClaim contains details about the
109122
volume's current state.
110123
properties:
124+
DiskUUID:
125+
description: DiskUUID is the ID obtained when volume is
126+
attached to a VM.
127+
type: string
111128
attached:
112129
description: |-
130+
Attached indicates the attach status of a PVC.
113131
If volume is not attached, Attached will be set to false.
114132
If volume is attached, Attached will be set to true.
115133
If volume is detached successfully, its entry will be removed from VolumeStatus.
@@ -120,10 +138,6 @@ spec:
120138
cnsVolumeId:
121139
description: CnsVolumeID is the volume ID for the PVC.
122140
type: string
123-
diskuuid:
124-
description: Diskuuid is the ID obtained when volume is
125-
attached to a VM.
126-
type: string
127141
error:
128142
description: Error indicates the error which may have occurred
129143
during attach/detach.
@@ -151,4 +165,4 @@ status:
151165
kind: ""
152166
plural: ""
153167
conditions: []
154-
storedVersions: []
168+
storedVersions: []

pkg/apis/cnsoperator/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var EmbedCnsNodeVmAttachmentCRFile embed.FS
88
const EmbedCnsNodeVmAttachmentCRFileName = "cns.vmware.com_cnsnodevmattachments.yaml"
99

1010
//go:embed cns.vmware.com_cnsnodevmbatchattachments.yaml
11-
var EmbedCnsNodeVmBatchAttachmentCRFile embed.FS
11+
var EmbedCnsNodeVMBatchAttachmentCRFile embed.FS
1212

1313
const EmbedCnsNodeVmABatchttachmentCRFileName = "cns.vmware.com_cnsnodevmbatchattachments.yaml"
1414

pkg/apis/cnsoperator/register.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ var (
5151
CnsNodeVMAttachmentSingular = "cnsnodevmattachment"
5252
// CnsNodeVMAttachmentPlural is plural of CnsNodeVmAttachment
5353
CnsNodeVMAttachmentPlural = "cnsnodevmattachments"
54-
// CnsNodeVmBatchAttachmentPlural is plural of CnsNodeVmBatchAttachment
55-
CnsNodeVmBatchAttachmentPlural = "cnsnodevmbatchattachments"
54+
// CnsNodeVMBatchAttachmentPlural is plural of CnsNodeVMBatchAttachment
55+
CnsNodeVMBatchAttachmentPlural = "cnsnodevmbatchattachments"
5656
// CnsVolumeMetadataSingular is Singular of CnsVolumeMetadata
5757
CnsVolumeMetadataSingular = "cnsvolumemetadata"
5858
// CnsVolumeMetadataPlural is plural of CnsVolumeMetadata
@@ -133,8 +133,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
133133

134134
scheme.AddKnownTypes(
135135
SchemeGroupVersion,
136-
&cnsnodevmbatchattachmentv1alpha1.CnsNodeVmBatchAttachment{},
137-
&cnsnodevmbatchattachmentv1alpha1.CnsNodeVmBatchAttachmentList{},
136+
&cnsnodevmbatchattachmentv1alpha1.CnsNodeVMBatchAttachment{},
137+
&cnsnodevmbatchattachmentv1alpha1.CnsNodeVMBatchAttachmentList{},
138138
)
139139

140140
scheme.AddKnownTypes(

0 commit comments

Comments
 (0)