-
Notifications
You must be signed in to change notification settings - Fork 28
Adding BucketAccess Add Functionality, Fix cmd controller and pass co… #15
Adding BucketAccess Add Functionality, Fix cmd controller and pass co… #15
Conversation
pkg/util/util.go
Outdated
@@ -65,6 +71,25 @@ func GetUUID() string { | |||
return string(uuid.NewUUID()) | |||
} | |||
|
|||
func ReadConfigData(kubeClient kubeclientset.Interface, configMapRef *v1.ObjectReference) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should there be an err
as part of the func return? Otherwise how does caller know the difference between an empty CM and a GET or Marshal error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks for the review.
978d658
to
8f3f158
Compare
// Provisioning is 100% finished / not in progress. | ||
switch err { | ||
case util.ErrInvalidBucketAccessClass: | ||
glog.V(5).Infof("Bucket access class specified does not exist. Stop provisioning, removing bucket access request %s from bucket access requests in progress", bucketAccessRequest.UID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- is this interpretation of
err
always correct? could this err also be that a field is missing in the BAC? - "Stop provisioning, removing bucket access request %s from bucket access requests in progress". This msg makes me think that the controller will next "stop provisioning", which is not correct.
What if each msg just interprets the returned err and at the end append the msg about provisioning stopped? Eg.
switch err {
case util.ErrInvalidBucketAccessClass:
errmsg = sprintf("Bucket access class error: %v", err)
case util.ErrBucketAccessAlreadyExists:
errmsg = sprintf("Bucket access already exist: %v", err)
...
}
err = nil
errmsg = sprintf("%s\nProvisioning stopped.", errmsg)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some errors that are not recoverable. There is no point in keeping the BAR in the queue.
glog.V(5).Infof("Bucket access class specified does not exist. Stop provisioning, removing bucket access request %s from bucket access requests in progress", bucketAccessRequest.UID) | ||
err = nil | ||
case util.ErrBucketAccessAlreadyExists: | ||
glog.V(5).Infof("Bucket access already exist for this bucket request. Stop provisioning, removing bucket access request %s from bucket access requests in progress", bucketAccessRequest.UID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"removing bucket access request %s from bucket access requests in progress" is not understandable to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lack of better wording... I am trying to say
"Bucket access already exist for this bucket request. Stop provisioning, removing bucket access request br1 from bucket access requests in progress"
can also be changed to
"Bucket access already exist for this bucket request br1."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the wording
switch err { | ||
case util.ErrInvalidBucketAccessClass: | ||
glog.V(5).Infof("Bucket access class specified does not exist. Stop provisioning, removing bucket access request %s from bucket access requests in progress", bucketAccessRequest.UID) | ||
err = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is this case not an error? Don't we want to keep the BAR in the work-queue and retry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an error that is not recoverable and we will not retry. We just print the error and ignore this from the queue and stop retrying.
return nil | ||
} | ||
|
||
func (b *bucketAccessRequestListener) FindBucketAccess(ctx context.Context, br *v1alpha1.BucketAccessRequest) *v1alpha1.BucketAccess { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/br/bar/ in arg list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
if err != nil { | ||
return nil | ||
} | ||
if len(bucketAccessList.Items) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
if err != nil || len(bucketAccessList.Items) <=0 {
return nil
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
} | ||
} | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if do above then this return should be deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you still need the return here
} | ||
if len(bucketAccessList.Items) > 0 { | ||
for _, bucketaccess := range bucketAccessList.Items { | ||
if bucketaccess.Spec.BucketAccessRequest == br.Name { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to the KEP, BA.Spec.BucketAccessRequest is an ObjectReference
containing name, namespace and UID. Did that change?
Comparing names is insufficient since the same BAR name can appear in different namespaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
bucketaccess := b.FindBucketAccess(ctx, bucketAccessRequest) | ||
if bucketaccess != nil { | ||
// bucketaccess has been already provisioned, nothing to do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there really nothing left to do? What about setting BA.status? What about verifying various fields (like bindings) to make sure things look coherent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BA found based on a match criteria. I am not sure what other fields you would like to verify. Can you be more specific.
|
||
bucketAccessClass, err := b.bucketClient.ObjectstorageV1alpha1().BucketAccessClasses().Get(ctx, bucketAccessClassName, metav1.GetOptions{}) | ||
if bucketAccessClass == nil { | ||
// bucket has been already provisioned, nothing to do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If BAC is nil then the BAR did not specify the BAC or the BAC has been deleted. Why is the conclusion that the bucket has already been provisioned? Note: returning this err is treated like nil, implying success.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the comment.
return err | ||
} | ||
|
||
if bucketRequest.Spec.BucketInstanceName == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what code updates the BR.bucketInstanceName? It should not be the sidecar. Assuming the central controller does this, then that implies that BR binding has to occur before BA binding. Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct.
bucketaccess.Spec.Parameters = util.CopySS(bucketAccessClass.Parameters) | ||
|
||
bucketaccess, err = b.bucketClient.ObjectstorageV1alpha1().BucketAccesses().Create(context.Background(), bucketaccess, metav1.CreateOptions{}) | ||
if err == nil || apierrs.IsAlreadyExists(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the err is "already exists" then there is probably more work to do for idempotency. We need to do some checks to make sure the existing BA is what we expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
8f3f158
to
e27b7f3
Compare
…ntext to command Fixes kubernetes-retired#10 Fixes kubernetes-retired#8
e27b7f3
to
84ffaba
Compare
LGTM |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brahmaroutu, wlan0 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…ntext to command
Fixes #10
Fixes #8
/assign @wlan0
/ping @rrati @jeffvance