-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
… 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>
@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>
… 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>
@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>
@adleong Can you please have a look now. :) |
pkg/profiles/openapi.go
Outdated
@@ -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") |
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.
@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?
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.
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.
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/profiles/openapi.go
Outdated
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) |
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 can simply be var responses *spec.Responses
. Declaring a variable will automatically initialize it with the zero value (nil).
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.
@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>
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.
Thanks! ⭐
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.
nice work @kohsheen1234 !
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>
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