-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fix filter namespaces in template router #15916
Fix filter namespaces in template router #15916
Conversation
@knobunc @rajatchopra @imcsk8 PTAL |
[test] |
Do we have a test for this? |
LGTM |
On Tue, Aug 22, 2017 at 7:08 PM, Clayton Coleman ***@***.***> wrote:
Do we have a test for this?
I will add a test case.
… —
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#15916 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABM0hj5EIMymobfYOsxNLuH8-mnudD_Rks5sa4megaJpZM4O_ZJe>
.
|
c2c7b2f
to
308d1d3
Compare
308d1d3
to
2e7ec8f
Compare
2e7ec8f
to
82899ce
Compare
Updates:
|
/retest |
1 similar comment
/retest |
82899ce
to
8c26d55
Compare
/test extended_templates extended_conformance_gce |
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.
/lgtm
Squash the commits maybe?
Points to be addressed in a subsequent PR:
- We should not need to parse the ServiceUnit key anywhere. We should have the Namespace and unmodified Name as the fields, and the key be generated one way.
- Also the delimiter should be made programmable (useful for nginx e.g.)
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
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.
Generally good. I just have a bunch of minor questions. Thanks
@@ -19,6 +20,10 @@ import ( | |||
unidlingapi "github.com/openshift/origin/pkg/unidling/api" | |||
) | |||
|
|||
const ( |
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.
Can we have a comment that says what this is used for please
pkg/router/template/plugin.go
Outdated
@@ -197,14 +202,28 @@ func (p *TemplatePlugin) Commit() error { | |||
|
|||
// endpointsKey returns the internal router key to use for the given Endpoints. | |||
func endpointsKey(endpoints *kapi.Endpoints) string { | |||
return fmt.Sprintf("%s/%s", endpoints.Namespace, endpoints.Name) | |||
return fmt.Sprintf("%s%s%s", endpoints.Namespace, endpointsKeySeparator, endpoints.Name) |
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.
Should this just call endpointsKeyFromParts?
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.
Yes, I added endpointsKeyFromParts later out of necessity and didn't release it can be reused here.
pkg/router/template/plugin.go
Outdated
} | ||
|
||
// peerServiceKey may be used by the underlying router when handling endpoints to identify | ||
// endpoints that belong to its peers. THIS MUST FOLLOW THE KEY STRATEGY OF endpointsKey. It | ||
// receives a NamespacedName that is created from the service that is added by the oadm command | ||
func peerEndpointsKey(namespacedName ktypes.NamespacedName) string { | ||
return fmt.Sprintf("%s/%s", namespacedName.Namespace, namespacedName.Name) | ||
return fmt.Sprintf("%s%s%s", namespacedName.Namespace, endpointsKeySeparator, namespacedName.Name) |
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 too... and then there's no risk of divergence
pkg/router/template/plugin_test.go
Outdated
return route.Spec.Host + "-" + route.Spec.Path | ||
// getKey create an identifier for the route consisting of host-path | ||
func getKey(route *routeapi.Route) string { | ||
return route.Spec.Host + routeKeySeparator + route.Spec.Path |
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.
Any idea why this doesn't use sprintf? Or why the other ones don't do it this way?
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.
And should this call routeKeyFromParts?
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.
fmt.Sprintf and ' + ' are used in several places and looks like we don't care which one we use.
Yes, we could call routeKeyFromParts
routeFile = "routes.json" | ||
certDir = "certs" | ||
caCertDir = "cacerts" | ||
defaultCertName = "default" | ||
|
||
caCertPostfix = "_ca" | ||
destCertPostfix = "_pod" | ||
|
||
// '-' is not used because namespace can contain dashes | ||
// '_' is not used as this could be part of the name in 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.
Should we say why / can't be used? The comment below implies that / can't be used because it needs to be written to disk.
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.
ok, I will mention about '/'
Colon instead of underscore is used to uniquely identify ServiceAliasConfig(route for a service).
…gin and router code Get the endpoints and route key related information from one place, this will be less prone to errors and easy to modify in the future if needed.
8c26d55
to
f088be6
Compare
Commits are broken down to differentiate between actual bug fix and refactor work. |
@knobunc @rajatchopra Updated, PTAL |
@pravisankar: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
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.
Great! Thanks.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: knobunc, pravisankar, rajatchopra The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue (batch tested with PRs 15853, 15916, 16017, 16027, 16043) |
Colon instead of underscore is used to uniquely identify ServiceAliasConfig(route for a service).