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

Support for configuring service profile retries(x-linkerd-retryable) via openapi spec #4052

Merged
merged 10 commits into from
Feb 18, 2020

Conversation

kohsheen1234
Copy link
Contributor

Retry policy is manually written in yaml file and patched it into the service profile

Added support for configuring service profile retries(x-linkerd-retryable) via openapi spec

Fixes #2073

Signed-off-by: Kohsheen Tiku kohsheen.t@gmail.com

… service profile

Added support for configuring service profile retries(x-linkerd-retryable) via openapi spec

Fixes linkerd#2073

Signed-off-by: Kohsheen Tiku <kohsheen.t@gmail.com>
pkg/profiles/openapi.go Outdated Show resolved Hide resolved
pkg/profiles/openapi.go Outdated Show resolved Hide resolved
pkg/profiles/openapi.go Outdated Show resolved Hide resolved
pkg/profiles/openapi_test.go Outdated Show resolved Hide resolved
… service profile

Added support for configuring service profile retries(x-linkerd-retryable) via openapi spec

Fixes linkerd#2073

Signed-off-by: Kohsheen Tiku <kohsheen.t@gmail.com>
@kohsheen1234
Copy link
Contributor Author

@adleong I have made the required changes. Can you please review the changes.

… service profile

Added support for configuring service profile retries(x-linkerd-retryable) via openapi spec

Fixes linkerd#2073

Signed-off-by: Kohsheen Tiku <kohsheen.t@gmail.com>
… service profile

Added support for configuring service profile retries(x-linkerd-retryable) via openapi spec

Fixes linkerd#2073

Signed-off-by: Kohsheen Tiku <kohsheen.t@gmail.com>
pkg/profiles/openapi_test.go Outdated Show resolved Hide resolved
pkg/profiles/openapi.go Outdated Show resolved Hide resolved
… service profile

Added support for configuring service profile retries(x-linkerd-retryable) via openapi spec

Fixes linkerd#2073

Signed-off-by: Kohsheen Tiku <kohsheen.t@gmail.com>
… service profile

Added support for configuring service profile retries(x-linkerd-retryable) via openapi spec

Fixes linkerd#2073

Signed-off-by: Kohsheen Tiku <kohsheen.t@gmail.com>
… service profile

Added support for configuring service profile retries(x-linkerd-retryable) via openapi spec

Fixes linkerd#2073

Signed-off-by: Kohsheen Tiku <kohsheen.t@gmail.com>
@kohsheen1234
Copy link
Contributor Author

@adleong Can you have a look now. I have made the recommended changes. :)

… service profile

Added support for configuring service profile retries(x-linkerd-retryable) via openapi spec

Fixes linkerd#2073

Signed-off-by: Kohsheen Tiku <kohsheen.t@gmail.com>
… service profile

Added support for configuring service profile retries(x-linkerd-retryable) via openapi spec

Fixes linkerd#2073

Signed-off-by: Kohsheen Tiku <kohsheen.t@gmail.com>
@kohsheen1234
Copy link
Contributor Author

@adleong Can you please have a look now. :)

@@ -71,31 +75,38 @@ func swaggerToServiceProfile(swagger spec.Swagger, namespace, name, clusterDomai
path := path.Join(swagger.BasePath, relPath)
pathRegex := pathToRegex(path)
if item.Delete != nil {
spec := mkRouteSpec(path, pathRegex, http.MethodDelete, item.Delete.Responses)
retryable, _ := item.Delete.VendorExtensible.Extensions.GetBool("x-linkerd-retryable")
Copy link
Contributor

Choose a reason for hiding this comment

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

@kohsheen1234 Is it safe to ignore the second return value if it is false? What are the implications of continuing to use retryable if [GetBool](https://github.com/go-openapi/spec/blob/master/info.go#L47) returns a false value?

Copy link
Member

Choose a reason for hiding this comment

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

If the key is not present, the first value will default to false: https://github.com/go-openapi/spec/blob/master/info.go#L44

I think this is the desired behavior for us. If the extension is absent, we will default to not being retryable.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

pkg/profiles/openapi.go Show resolved Hide resolved
func mkRouteSpec(path, pathRegex string, method string, responses *spec.Responses) *sp.RouteSpec {
func mkRouteSpec(path, pathRegex string, method string, operation *spec.Operation) *sp.RouteSpec {
retryable := false
var responses = (*spec.Responses)(nil)
Copy link
Member

Choose a reason for hiding this comment

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

This can simply be var responses *spec.Responses. Declaring a variable will automatically initialize it with the zero value (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.

@adleong Thank you, this seems like a better way.:+1: I have made the change

… service profile

Added support for configuring service profile retries(x-linkerd-retryable) via openapi spec

Fixes linkerd#2073

Signed-off-by: Kohsheen Tiku <kohsheen.t@gmail.com>
Copy link
Member

@adleong adleong left a comment

Choose a reason for hiding this comment

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

Thanks! ⭐

Copy link
Contributor

@cpretzer cpretzer left a comment

Choose a reason for hiding this comment

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

nice work @kohsheen1234 !

@cpretzer cpretzer merged commit dea8b8c into linkerd:master Feb 18, 2020
adleong pushed a commit that referenced this pull request Mar 10, 2020
This change is in a similar vein to #4052 which provided support for
configuring service profile retries via a vendor extension of
`x-linkerd-retryable`, when generating from an openapi specification.

This change is very similar to the final version of that pull request,
and adds a timeout value based on `x-linkerd-timeout`.

At this point I believe that if the timeout is not specified then the
default provided by linkerd of 30s will apply anyway, but won't
explicitly be reflected in the service profile, which I'm somewhat okay
with as a current state, but I think there's a potential future
improvement that the default timeout is always shown when generating
from an open api spec, but that's more to make it clear and obvious that
that timeout exists.

Signed-off-by: Lewis Cowper <lewis.cowper@googlemail.com>
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.

add support for configuring service profile retries via openapi spec
4 participants