Skip to content

Commit

Permalink
Merge pull request #22 from avoltz/echairez/dont-block-already-provis…
Browse files Browse the repository at this point in the history
…ioned-calls

pvc_annotator: remove already being provisioned check
  • Loading branch information
chaireze authored Jul 12, 2023
2 parents ba0a18e + 70423b7 commit 5982ae7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
4 changes: 0 additions & 4 deletions pkg/blob/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,6 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe

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
24 changes: 1 addition & 23 deletions pkg/edgecache/cachevolume/pvc_annotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package cachevolume

import (
"errors"
"fmt"

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

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

type BlobAuth struct {
Expand Down Expand Up @@ -82,16 +80,6 @@ func (c *PVCAnnotator) requestAuthIsValid(auth string) bool {
return slices.Contains(validStorageAuthentications, auth)
}

func (c *PVCAnnotator) needsToBeProvisioned(pvc *v1.PersistentVolumeClaim) bool {
// check if pv connected to the pvc has already been passed to be created
pvState, pvStateOk := pvc.ObjectMeta.Annotations[createVolumeAnnotation]
if pvStateOk && pvState == "no" {
return false
}

return true
}

func (c *PVCAnnotator) buildAnnotations(pv *v1.PersistentVolume, cfg config.AzureAuthConfig, providedAuth BlobAuth) (map[string]string, error) {
annotations := map[string]string{
createVolumeAnnotation: "yes",
Expand Down Expand Up @@ -135,22 +123,12 @@ func (c *PVCAnnotator) buildAnnotations(pv *v1.PersistentVolume, cfg config.Azur
}

func (c *PVCAnnotator) SendProvisionVolume(pv *v1.PersistentVolume, cloudConfig config.AzureAuthConfig, providedAuth BlobAuth) error {
pvc, err := blobcsiutil.GetPVCByName(c.client, pv.Spec.ClaimRef.Name, pv.Spec.ClaimRef.Namespace)
if err != nil {
return err
}

if valid := c.requestAuthIsValid(providedAuth.authType); !valid {
err := fmt.Errorf("requested storage auth %s is not a member of valid auths %+v", providedAuth.authType, validStorageAuthentications)
klog.Error(err)
return err
}

if prepare := c.needsToBeProvisioned(pvc); !prepare {
klog.Info("pv is already being provisioned")
return ErrVolumeAlreadyBeingProvisioned
}

annotations, err := c.buildAnnotations(pv, cloudConfig, providedAuth)
if err != nil {
return err
Expand Down

0 comments on commit 5982ae7

Please sign in to comment.