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

Adding BucketAccess Add Functionality, Fix cmd controller and pass co… #15

Merged
merged 1 commit into from
Dec 14, 2020

Conversation

brahmaroutu
Copy link
Contributor

@brahmaroutu brahmaroutu commented Dec 9, 2020

…ntext to command

Fixes #10
Fixes #8

/assign @wlan0
/ping @rrati @jeffvance

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 9, 2020
@brahmaroutu brahmaroutu added this to the Demo 1 milestone Dec 9, 2020
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 {

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?

Copy link
Contributor Author

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.

@brahmaroutu brahmaroutu force-pushed the controller_code_ba branch 2 times, most recently from 978d658 to 8f3f158 Compare December 9, 2020 05:24
// 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. is this interpretation of err always correct? could this err also be that a field is missing in the BAC?
  2. "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)

Copy link
Contributor Author

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)

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.

Copy link
Contributor Author

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."

Copy link
Contributor Author

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
Copy link

@jeffvance jeffvance Dec 9, 2020

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?

Copy link
Contributor Author

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 {

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

Copy link
Contributor Author

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 {

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
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}
}
}
return nil

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

Copy link
Contributor Author

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 {
Copy link

@jeffvance jeffvance Dec 9, 2020

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.

Copy link
Contributor Author

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.

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?

Copy link
Contributor Author

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.
Copy link

@jeffvance jeffvance Dec 9, 2020

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.

Copy link
Contributor Author

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 == "" {
Copy link

@jeffvance jeffvance Dec 9, 2020

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?

Copy link
Contributor Author

@brahmaroutu brahmaroutu Dec 9, 2020

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) {

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 10, 2020
@wlan0
Copy link
Contributor

wlan0 commented Dec 14, 2020

LGTM

@wlan0
Copy link
Contributor

wlan0 commented Dec 14, 2020

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 14, 2020
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 09366ec into kubernetes-sigs:master Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Development

Successfully merging this pull request may close these issues.

Ctx not being passed into signal handler BucketAccessRequest Add
4 participants