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

Multi-plan support #298

Merged
merged 7 commits into from Jul 28, 2017
Merged

Multi-plan support #298

merged 7 commits into from Jul 28, 2017

Conversation

eriknelson
Copy link
Contributor

No description provided.

@eriknelson
Copy link
Contributor Author

Going to fix the ol' linter

Copy link
Contributor

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

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

Having followed the discussion and the testing. I'll ack this, despite the mean sticker @eriknelson sent me.

@@ -174,14 +174,22 @@ func (h handler) deprovision(w http.ResponseWriter, r *http.Request, params map[
writeResponse(w, http.StatusBadRequest, broker.ErrorResponse{Description: "invalid instance_uuid"})
return
}

var async bool
queryparams := r.URL.Query()
Copy link
Contributor

Choose a reason for hiding this comment

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

So small nit, just because your editing this.

I would prefer to use the request.FormValue(). I personally think it is nicer and easier to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much better, didn't know about this. TY @shawn-hurley

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logged an issue to update the request layer, #303

Copy link
Contributor

Choose a reason for hiding this comment

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

But only if they are coming in as a form. If they are json or coming in on the actual url hook. I'd be careful making that change blindly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jmrodri Are you satisfied with this after your investigation?

Copy link
Contributor

Choose a reason for hiding this comment

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

@eriknelson yes FormValue is ok. Weird but it seems to work.


func validateSpecs(log *logging.Logger, inSpecs []*apb.Spec) []*apb.Spec {
var wg sync.WaitGroup
wg.Add(len(inSpecs))
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to call the addition to the wait group as I call the go routines. To me, it makes it more clear what we are supposed to be waiting on. This is still really clear, just throwing it out there for the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I like saying "I expect this to run for every spec" up front.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shawn-hurley I'd like to also talk about this fn. It's not in the scope of this PR, but where do we want to validate what we bring in, and how? There is probably room for the registry to hard vet loaded specs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shawn-hurley coming back to this now that the deprovision fire is (hopefully) out. I think we're talking about how the broker should validate Specs that come in, which IMO is outside the scope of this PR. I would like to lodge a card to consider spec validation explicitly, because it's something we need to address. The broker needs to defend against adapters sending busted Specs, and that's not in the domain of a Plans support feature.

@@ -61,7 +62,7 @@ func (r Registry) LoadSpecs() ([]*apb.Spec, int, error) {
r.log.Debug("Filter applied against registry: %s", r.config.Name)

if len(validNames) != 0 {
r.log.Debugf("Passing APBs:")
r.log.Debugf("APBs passing white/blacklist filter:")
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

go func(s *apb.Spec) {
ok, failReason := validateSpecPlans(s)
out <- resultT{ok, s, failReason}
wg.Done()
Copy link
Contributor

Choose a reason for hiding this comment

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

You should defer this, things could break if an unexpected panic happens.

@eriknelson
Copy link
Contributor Author

Updated based on feedback.

@eriknelson
Copy link
Contributor Author

eriknelson commented Jul 25, 2017

Realizing this requires some decent testing changes. Working on that. Will continue to send @jmrodri rude stickers.

@eriknelson eriknelson changed the title Multi-plan support [DO NOT MERGE] Multi-plan support Jul 25, 2017
pkg/apb/types.go Outdated
@@ -39,9 +47,8 @@ type Spec struct {
Metadata map[string]interface{} `json:"metadata,omitempty"`

// required, optional, unsupported
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment looks out of place now.

"PlanID from provision request is blank. " +
"Provision requests must specify PlanIDs"
a.log.Error(errMsg)
return nil, errors.New(errMsg)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to print errMsg twice. Here's where err gets passed to: https://github.com/openshift/ansible-service-broker/blob/master/pkg/broker/provision_job.go#L50. Same thing for all the custom error messages below.

Because we have the caller capturing and printing error everywhere, I think the only places it makes sense to print a custom error message is if you return nil, err. That way we print both the custom errMsg and the actually error.

@rthallisey
Copy link
Contributor

rthallisey commented Jul 25, 2017

closes #297

@eriknelson eriknelson changed the title [DO NOT MERGE] Multi-plan support Multi-plan support Jul 28, 2017
@eriknelson eriknelson merged commit 96b554c into openshift:master Jul 28, 2017
jianzhangbjz pushed a commit to jianzhangbjz/ansible-service-broker that referenced this pull request May 17, 2018
* Initial buildable refactoring

* Add validations

* Accept and require plan_id for all actions

* Feedback

* Linter fixes

* Update test to be multi-plan compliant

* Updates based on Ryan's feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants