Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Verification and Permission Issues in Static Bucket Creation and Deletion #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
32 changes: 30 additions & 2 deletions pkg/bucket/bucket_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,36 @@ func (b *BucketListener) Add(ctx context.Context, inputBucket *v1alpha1.Bucket)
var bucketID string

if bucket.Spec.ExistingBucketID != "" {
bucketReady = true
bucketID = bucket.Spec.ExistingBucketID
//如果bucket
req := &cosi.DriverCreateBucketRequest{
Parameters: bucket.Spec.Parameters,
Name: bucket.ObjectMeta.Name,
}

rsp, err := b.provisionerClient.DriverCreateBucket(ctx, req)
if err != nil {
if status.Code(err) != codes.PermissionDenied {
//events.FailedCreateBucket indicates that the corresponding bucket does not exist on the storage
return b.recordError(inputBucket, v1.EventTypeWarning, events.FailedCreateBucket, fmt.Errorf("failed to create bucket: %w", err))
}
}

if rsp == nil {
err = consts.ErrInternal
klog.V(3).ErrorS(err, "Internal Error from driver",
"bucket", bucket.ObjectMeta.Name)
return fmt.Errorf("%w for Bucket %v", err, bucket.Name)
}

if rsp.BucketId != "" {
bucketID = rsp.BucketId
bucketReady = true
} else {
klog.V(3).ErrorS(err, "DriverCreateBucket returned an empty bucketID",
"bucket", bucket.ObjectMeta.Name)
return fmt.Errorf("%w for Bucket %v", consts.ErrEmptyBucketID, bucket.Name)
}

if bucket.Spec.Parameters == nil {
bucketClass, err := b.bucketClasses().Get(ctx, bucket.Spec.BucketClassName, metav1.GetOptions{})
if kubeerrors.IsNotFound(err) {
Expand Down