@@ -21,7 +21,6 @@ import (
21
21
"fmt"
22
22
"os"
23
23
"path/filepath"
24
- "strconv"
25
24
"strings"
26
25
27
26
"github.com/container-storage-interface/spec/lib/go/csi"
@@ -68,22 +67,14 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
68
67
69
68
ephemeralVolume := req .GetVolumeContext ()["csi.storage.k8s.io/ephemeral" ] == "true"
70
69
if ephemeralVolume {
71
- // See https://github.com/kubernetes/cloud-provider-openstack/issues/1493
72
- klog .Warningf ("CSI inline ephemeral volumes support is deprecated in 1.24 release." )
73
- return nodePublishEphemeral (req , ns )
70
+ // See https://github.com/kubernetes/cloud-provider-openstack/issues/2599
71
+ return nil , status .Error (codes .Unimplemented , "CSI inline ephemeral volumes support is removed in 1.31 release." )
74
72
}
75
73
76
74
// In case of ephemeral volume staging path not provided
77
75
if len (source ) == 0 {
78
76
return nil , status .Error (codes .InvalidArgument , "NodePublishVolume Staging Target Path must be provided" )
79
77
}
80
- _ , err := ns .Cloud .GetVolume (volumeID )
81
- if err != nil {
82
- if cpoerrors .IsNotFound (err ) {
83
- return nil , status .Error (codes .NotFound , "Volume not found" )
84
- }
85
- return nil , status .Errorf (codes .Internal , "GetVolume failed with error %v" , err )
86
- }
87
78
88
79
mountOptions := []string {"bind" }
89
80
if req .GetReadonly () {
@@ -121,105 +112,6 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
121
112
return & csi.NodePublishVolumeResponse {}, nil
122
113
}
123
114
124
- func nodePublishEphemeral (req * csi.NodePublishVolumeRequest , ns * nodeServer ) (* csi.NodePublishVolumeResponse , error ) {
125
-
126
- var size int
127
- var err error
128
-
129
- volID := req .GetVolumeId ()
130
- volName := fmt .Sprintf ("ephemeral-%s" , volID )
131
- properties := map [string ]string {"cinder.csi.openstack.org/cluster" : ns .Driver .cluster }
132
- capacity , ok := req .GetVolumeContext ()["capacity" ]
133
-
134
- volAvailability , err := ns .Metadata .GetAvailabilityZone ()
135
- if err != nil {
136
- return nil , status .Errorf (codes .Internal , "retrieving availability zone from MetaData service failed with error %v" , err )
137
- }
138
-
139
- size = 1 // default size is 1GB
140
- if ok && strings .HasSuffix (capacity , "Gi" ) {
141
- size , err = strconv .Atoi (strings .TrimSuffix (capacity , "Gi" ))
142
- if err != nil {
143
- klog .V (3 ).Infof ("Unable to parse capacity: %v" , err )
144
- return nil , status .Errorf (codes .Internal , "Unable to parse capacity %v" , err )
145
- }
146
- }
147
-
148
- // Check type in given param, if not, use ""
149
- volumeType , ok := req .GetVolumeContext ()["type" ]
150
- if ! ok {
151
- volumeType = ""
152
- }
153
-
154
- evol , err := ns .Cloud .CreateVolume (volName , size , volumeType , volAvailability , "" , "" , "" , properties )
155
-
156
- if err != nil {
157
- klog .V (3 ).Infof ("Failed to Create Ephemeral Volume: %v" , err )
158
- return nil , status .Errorf (codes .Internal , "Failed to create Ephemeral Volume %v" , err )
159
- }
160
-
161
- // Wait for volume status to be Available, before attaching
162
- if evol .Status != openstack .VolumeAvailableStatus {
163
- targetStatus := []string {openstack .VolumeAvailableStatus }
164
- err := ns .Cloud .WaitVolumeTargetStatus (evol .ID , targetStatus )
165
- if err != nil {
166
- return nil , status .Error (codes .Internal , err .Error ())
167
- }
168
- }
169
-
170
- klog .V (4 ).Infof ("Ephemeral Volume %s is created" , evol .ID )
171
-
172
- // attach volume
173
- // for attach volume we need to have information about node.
174
- nodeID , err := ns .Metadata .GetInstanceID ()
175
- if err != nil {
176
- msg := "nodePublishEphemeral: Failed to get Instance ID: %v"
177
- klog .V (3 ).Infof (msg , err )
178
- return nil , status .Errorf (codes .Internal , msg , err )
179
- }
180
-
181
- _ , err = ns .Cloud .AttachVolume (nodeID , evol .ID )
182
- if err != nil {
183
- msg := "nodePublishEphemeral: attach volume %s failed with error: %v"
184
- klog .V (3 ).Infof (msg , evol .ID , err )
185
- return nil , status .Errorf (codes .Internal , msg , evol .ID , err )
186
- }
187
-
188
- err = ns .Cloud .WaitDiskAttached (nodeID , evol .ID )
189
- if err != nil {
190
- return nil , status .Error (codes .Internal , err .Error ())
191
- }
192
-
193
- m := ns .Mount
194
-
195
- devicePath , err := getDevicePath (evol .ID , m )
196
- if err != nil {
197
- return nil , status .Errorf (codes .Internal , "Unable to find Device path for volume: %v" , err )
198
- }
199
-
200
- targetPath := req .GetTargetPath ()
201
-
202
- // Verify whether mounted
203
- notMnt , err := m .IsLikelyNotMountPointAttach (targetPath )
204
- if err != nil {
205
- return nil , status .Error (codes .Internal , err .Error ())
206
- }
207
-
208
- // Volume Mount
209
- if notMnt {
210
- // set default fstype is ext4
211
- fsType := "ext4"
212
- // Mount
213
- err = m .Mounter ().FormatAndMount (devicePath , targetPath , fsType , nil )
214
- if err != nil {
215
- return nil , status .Error (codes .Internal , err .Error ())
216
- }
217
- }
218
-
219
- return & csi.NodePublishVolumeResponse {}, nil
220
-
221
- }
222
-
223
115
func nodePublishVolumeForBlock (req * csi.NodePublishVolumeRequest , ns * nodeServer , mountOptions []string ) (* csi.NodePublishVolumeResponse , error ) {
224
116
klog .V (4 ).Infof ("NodePublishVolumeBlock: called with args %+v" , protosanitizer .StripSecrets (* req ))
225
117
@@ -274,7 +166,6 @@ func (ns *nodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
274
166
ephemeralVolume := false
275
167
276
168
vol , err := ns .Cloud .GetVolume (volumeID )
277
-
278
169
if err != nil {
279
170
280
171
if ! cpoerrors .IsNotFound (err ) {
@@ -459,16 +350,7 @@ func (ns *nodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag
459
350
return nil , status .Error (codes .InvalidArgument , "NodeUnstageVolume Staging Target Path must be provided" )
460
351
}
461
352
462
- _ , err := ns .Cloud .GetVolume (volumeID )
463
- if err != nil {
464
- if cpoerrors .IsNotFound (err ) {
465
- klog .V (4 ).Infof ("NodeUnstageVolume: Unable to find volume: %v" , err )
466
- return nil , status .Error (codes .NotFound , "Volume not found" )
467
- }
468
- return nil , status .Errorf (codes .Internal , "GetVolume failed with error %v" , err )
469
- }
470
-
471
- err = ns .Mount .UnmountPath (stagingTargetPath )
353
+ err := ns .Mount .UnmountPath (stagingTargetPath )
472
354
if err != nil {
473
355
return nil , status .Errorf (codes .Internal , "Unmount of targetPath %s failed with error %v" , stagingTargetPath , err )
474
356
}
0 commit comments