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

Bug 1537367 - missing last_operation for bindings #677

Merged
merged 2 commits into from Jan 25, 2018
Merged

Conversation

jmrodri
Copy link
Contributor

@jmrodri jmrodri commented Jan 23, 2018

Missing last_operation for the async binds. The service_instance method would work because our jobs are the same. But OSB platforms will want to call the last_operation binding.

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 23, 2018
@jmrodri
Copy link
Contributor Author

jmrodri commented Jan 23, 2018

@mhrivnak Have a looksie

@rthallisey
Copy link
Contributor

related: #475

@rthallisey rthallisey added the 3.9 | release-1.1 Kubernetes 1.9 | Openshift 3.9 | Broker release-1.1 label Jan 23, 2018
bindingUUID := uuid.Parse(params["binding_uuid"])
if bindingUUID == nil {
writeResponse(w, http.StatusBadRequest, broker.ErrorResponse{Description: "invalid binding_uuid"})
return
Copy link
Member

Choose a reason for hiding this comment

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

It would be an improvement to also check for existence of the binding in etcd. Since we have no mechanism to clean up JobState records, they could live on even if a BindInstance has been removed. In that case, I think this function would find the JobState and return a response as if the BindInstance still existed or was in-progress.

It may be an edge case that a client would call this endpoint after a binding was deleted, but it's probably worth supporting for the sake of correctness.

req := broker.LastOperationRequest{}

// operation is rqeuired
// operation is required
Copy link
Member

Choose a reason for hiding this comment

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

Speaking of this comment, the code below actually makes it optional. It just logs a warning but continues its lookup using just the service ID. I think it would be better to start enforcing what this comment says, and make it required, if not for the service last operation, at least for this case of a binding last operation.

If we let it continue without the operation, I'm not sure how it would behave. Maybe it would just fail to lookup the state? Or would it grab some other JobState for the same service ID, but not necessarily the right one? Either way, it's better to not let it get that far.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point.

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 returns an error

< HTTP/1.1 400 Bad Request                          
< Content-Type: application/json                    
< Date: Tue, 23 Jan 2018 16:33:31 GMT               
< Content-Length: 124                               
< Set-Cookie: d05351dd24520dce41f310fcfc112523=2808fe5497bbaeea73011198cb5cc014; path=/; HttpOnly; Secure                                                                                                          
<                                                   
{                                                   
  "description": "operation not supplied for a last_operation with instance_uuid [3aae62b1-f990-43de-89b6-25ad2c69e4e1]"                                                                                            
} 

@jmrodri
Copy link
Contributor Author

jmrodri commented Jan 23, 2018

@mhrivnak addressed both of your comments.

if op := r.FormValue("operation"); op != "" {
req.Operation = op
} else {
log.Warning(fmt.Sprintf("operation not supplied, relying solely on the instance_uuid [%s]", instanceUUID))
errmsg := fmt.Sprintf("operation not supplied for a last_operation with instance_uuid [%s]", instanceUUID)
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to shuffle this around to something like this, to factor out the else?

if op := r.FormValue("operation"); op == "" {
  // do error stuff
  return
}
req.Operation = op
...

Copy link
Member

@mhrivnak mhrivnak left a comment

Choose a reason for hiding this comment

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

One little suggestion I'll leave in your hands, but otherwise LGTM.

@@ -692,13 +694,38 @@ func (h handler) lastoperation(w http.ResponseWriter, r *http.Request, params ma
return
}

// we have a binding job
if strings.Index(r.URL.Path, "/service_bindings/") > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

strings.Contains might be more helpful when reading this? it is basically just a wrapper around what you are doing though so meh.

Copy link
Contributor

Choose a reason for hiding this comment

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

Using strings.Contains would make the code read a little better.

Copy link
Contributor

@rthallisey rthallisey left a comment

Choose a reason for hiding this comment

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

Agree with Shawn's point. Other than that it lgtm.

@@ -692,13 +694,38 @@ func (h handler) lastoperation(w http.ResponseWriter, r *http.Request, params ma
return
}

// we have a binding job
if strings.Index(r.URL.Path, "/service_bindings/") > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Using strings.Contains would make the code read a little better.

@jmrodri jmrodri merged commit 5a31cc9 into master Jan 25, 2018
@rthallisey rthallisey deleted the lastoperation branch January 25, 2018 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 | release-1.1 Kubernetes 1.9 | Openshift 3.9 | Broker release-1.1 size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants