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
Multi-plan support #298
Conversation
|
Going to fix the ol' linter |
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.
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() | |||
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.
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.
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.
Much better, didn't know about this. TY @shawn-hurley
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.
Logged an issue to update the request layer, #303
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.
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.
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.
@jmrodri Are you satisfied with this after your investigation?
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.
@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)) |
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.
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.
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.
I think I like saying "I expect this to run for every spec" up front.
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.
@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.
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.
@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:") | |||
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.
👍
pkg/registries/registry.go
Outdated
| go func(s *apb.Spec) { | ||
| ok, failReason := validateSpecPlans(s) | ||
| out <- resultT{ok, s, failReason} | ||
| wg.Done() |
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 should defer this, things could break if an unexpected panic happens.
|
Updated based on feedback. |
|
Realizing this requires some decent testing changes. Working on that. Will continue to send @jmrodri rude stickers. |
pkg/apb/types.go
Outdated
| @@ -39,9 +47,8 @@ type Spec struct { | |||
| Metadata map[string]interface{} `json:"metadata,omitempty"` | |||
|
|
|||
| // required, optional, unsupported | |||
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.
This comment looks out of place now.
pkg/broker/broker.go
Outdated
| "PlanID from provision request is blank. " + | ||
| "Provision requests must specify PlanIDs" | ||
| a.log.Error(errMsg) | ||
| return nil, errors.New(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.
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.
|
closes #297 |
8ee318c
to
f28a74d
Compare
* 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
No description provided.