@@ -68,7 +68,6 @@ package csi
6868import (
6969 "context"
7070 "errors"
71- "fmt"
7271 "os"
7372 "path/filepath"
7473
@@ -171,8 +170,8 @@ func (m *csiBlockMapper) stageVolumeForBlock(
171170 if csiSource .NodeStageSecretRef != nil {
172171 nodeStageSecrets , err = getCredentialsFromSecret (m .k8s , csiSource .NodeStageSecretRef )
173172 if err != nil {
174- return "" , fmt . Errorf ("failed to get NodeStageSecretRef %s/%s: %v" ,
175- csiSource .NodeStageSecretRef .Namespace , csiSource .NodeStageSecretRef .Name , err )
173+ return "" , volumetypes . NewTransientOperationFailure ( log ("failed to get NodeStageSecretRef %s/%s: %v" ,
174+ csiSource .NodeStageSecretRef .Namespace , csiSource .NodeStageSecretRef .Name , err ))
176175 }
177176 }
178177
@@ -223,11 +222,11 @@ func (m *csiBlockMapper) publishVolumeForBlock(
223222 volAttribs := csiSource .VolumeAttributes
224223 podInfoEnabled , err := m .plugin .podInfoEnabled (string (m .driverName ))
225224 if err != nil {
226- return "" , errors . New (log ("blockMapper.publishVolumeForBlock failed to assemble volume attributes: %v" , err ))
225+ return "" , volumetypes . NewTransientOperationFailure (log ("blockMapper.publishVolumeForBlock failed to assemble volume attributes: %v" , err ))
227226 }
228227 volumeLifecycleMode , err := m .plugin .getVolumeLifecycleMode (m .spec )
229228 if err != nil {
230- return "" , errors . New (log ("blockMapper.publishVolumeForBlock failed to get VolumeLifecycleMode: %v" , err ))
229+ return "" , volumetypes . NewTransientOperationFailure (log ("blockMapper.publishVolumeForBlock failed to get VolumeLifecycleMode: %v" , err ))
231230 }
232231 if podInfoEnabled {
233232 volAttribs = mergeMap (volAttribs , getPodInfoAttrs (m .pod , volumeLifecycleMode ))
@@ -237,7 +236,7 @@ func (m *csiBlockMapper) publishVolumeForBlock(
237236 if csiSource .NodePublishSecretRef != nil {
238237 nodePublishSecrets , err = getCredentialsFromSecret (m .k8s , csiSource .NodePublishSecretRef )
239238 if err != nil {
240- return "" , errors . New (log ("blockMapper.publishVolumeForBlock failed to get NodePublishSecretRef %s/%s: %v" ,
239+ return "" , volumetypes . NewTransientOperationFailure (log ("blockMapper.publishVolumeForBlock failed to get NodePublishSecretRef %s/%s: %v" ,
241240 csiSource .NodePublishSecretRef .Namespace , csiSource .NodePublishSecretRef .Name , err ))
242241 }
243242 }
@@ -304,7 +303,7 @@ func (m *csiBlockMapper) SetUpDevice() (string, error) {
304303 attachID := getAttachmentName (csiSource .VolumeHandle , csiSource .Driver , nodeName )
305304 attachment , err = m .k8s .StorageV1 ().VolumeAttachments ().Get (context .TODO (), attachID , meta.GetOptions {})
306305 if err != nil {
307- return "" , errors . New (log ("blockMapper.SetupDevice failed to get volume attachment [id=%v]: %v" , attachID , err ))
306+ return "" , volumetypes . NewTransientOperationFailure (log ("blockMapper.SetupDevice failed to get volume attachment [id=%v]: %v" , attachID , err ))
308307 }
309308 }
310309
@@ -366,7 +365,7 @@ func (m *csiBlockMapper) MapPodDevice() (string, error) {
366365 attachID := getAttachmentName (csiSource .VolumeHandle , csiSource .Driver , nodeName )
367366 attachment , err = m .k8s .StorageV1 ().VolumeAttachments ().Get (context .TODO (), attachID , meta.GetOptions {})
368367 if err != nil {
369- return "" , errors . New (log ("blockMapper.MapPodDevice failed to get volume attachment [id=%v]: %v" , attachID , err ))
368+ return "" , volumetypes . NewTransientOperationFailure (log ("blockMapper.MapPodDevice failed to get volume attachment [id=%v]: %v" , attachID , err ))
370369 }
371370 }
372371
0 commit comments