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 12, 2023
1 parent 441e632 commit 6c8e6b0
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.ErrVolumeAlreadyBeingProvisioned {
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"}
ErrVolumeAlreadyBeingProvisioned = errors.New("pv is already being provisioned")
)

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 ErrVolumeAlreadyBeingProvisioned
}

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

0 comments on commit 6c8e6b0

Please sign in to comment.