Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pvc_annotator: remove already being provisioned check #22

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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