Skip to content

Commit

Permalink
nodeserver: safe exit when pvc is already being provisioned
Browse files Browse the repository at this point in the history
  • Loading branch information
chaireze committed Jul 11, 2023
1 parent 441e632 commit f0088fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion pkg/blob/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,13 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe

annotator := cv.NewPVCAnnotator(d.cloud.KubeClient)
providedAuth := cv.NewBlobAuth(accountName, containerName, secretName, secretNamespace, storageAuthType)
if err := annotator.SendProvisionVolume(pv, d.cloud.Config.AzureAuthConfig, providedAuth); err != nil {

err = annotator.SendProvisionVolume(pv, d.cloud.Config.AzureAuthConfig, providedAuth)
if err != nil {
if err == cv.VolumeAlreadyBeingProvisioned {
return &csi.NodeStageVolumeResponse{}, nil
}

return nil, err
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/edgecache/cachevolume/pvc_annotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package cachevolume

import (
"errors"
"fmt"

"golang.org/x/exp/maps"
Expand All @@ -41,7 +42,8 @@ const (
)

var (
validStorageAuthentications = []string{"WorkloadIdentity", "AccountKey"}
validStorageAuthentications = []string{"WorkloadIdentity", "AccountKey"}
VolumeAlreadyBeingProvisioned = errors.New("pv is already being provisioned")

Check warning on line 46 in pkg/edgecache/cachevolume/pvc_annotator.go

View workflow job for this annotation

GitHub Actions / Go Lint

error-naming: error var VolumeAlreadyBeingProvisioned should have name of the form ErrFoo (revive)
)

type BlobAuth struct {
Expand Down Expand Up @@ -145,9 +147,8 @@ func (c *PVCAnnotator) SendProvisionVolume(pv *v1.PersistentVolume, cloudConfig
}

if prepare := c.needsToBeProvisioned(pvc); !prepare {
err := fmt.Errorf("pv is already being provisioned")
klog.Error(err)
return err
klog.Info("pv is already being provisioned")
return VolumeAlreadyBeingProvisioned
}

annotations, err := c.buildAnnotations(pv, cloudConfig, providedAuth)
Expand Down

0 comments on commit f0088fc

Please sign in to comment.