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 ability to warn and filter out bad specs. #571

Merged
merged 2 commits into from Dec 7, 2017

Conversation

shawn-hurley
Copy link
Contributor

Describe what this PR does and why we need it:
Will add debug messages when a type from an APB parameter is not defined, and remove from the services for catalog.
Changes proposed in this pull request

  • add error handling to SpecToService

Which issue this PR fixes (This will close that issue when PR gets merged)
fixes #388

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 27, 2017
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 6fc5faf on shawn-hurley:issue-388 into ** on openshift:master**.

Copy link
Member

@djzager djzager left a comment

Choose a reason for hiding this comment

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

LGTM. One nitpick.

services[i] = SpecToService(spec)
ser, err := SpecToService(spec)
if err != nil {
a.log.Debugf("no adding spec to list of services due to error transforming to service - %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

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

debugf for an error?

Copy link
Member

Choose a reason for hiding this comment

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

😎

@coveralls
Copy link

coveralls commented Nov 27, 2017

Coverage Status

Changes Unknown when pulling ed476c8 on shawn-hurley:issue-388 into ** on openshift:master**.

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.

I think I'll need to look this one over again. on the surface looks good, but something is weird about it to me.

service := SpecToService(&spec)
service, err := SpecToService(&spec)
if err != nil {
a.log.Debugf("spec was not added due to issue with transformation to serivce - %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we intend to log an error as DEBUG? seems odd.

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 that warning might be better. This is an APB gave us bad data which we have not treated as an error before I don't think it should be Errorf IMO

}
return []schema.PrimitiveType{schema.UnspecifiedType}
return nil, fmt.Errorf("Could not find the parameter type for: %v", paramType)
Copy link
Contributor

Choose a reason for hiding this comment

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

so what sparked this patch originally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#388 sparked this patch.

The basics of the issue are that the UnspecifiedType does not marshall into json, therefore the only things I can think to do are:

  1. either catch this by converting all specs to services during load time of the specs

  2. When /catalog is called and we convert specs to services we catch that error/unspecified type and do not add it to the list of services but do not blow up the entire response.

  3. blow up the entire response w/ a 500.

I choose to go down this route because if we can not gracefully handle the Unspecified type in the response then I think we should treat that as an error.

for _, pd := range params {
k := pd.Name

t, err := getType(pd.Type)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just check to see if the type is UnspecifiedType? I'm not sure I like the error on the getType. Is it really an error on getType? It looked for one, didn't fine a good one, said it was unspecified.

t := getType(pd.Type)
if t == []schema.PrimitiveType{schema.UnspecifiedType} {
    return properties
}

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 it is reasonable that an ununderstandable type is an error. Especially since we can not use that type for it's intended purpose. If you feel strongly though, I can change the initial error here instead of in getType function.

@jmrodri jmrodri merged commit 6b7be38 into openshift:master Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tech-debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing type field on parameter causes empty catalog request
6 participants