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

Fix filter namespaces in template router #15916

Merged
merged 3 commits into from
Aug 30, 2017

Conversation

pravisankar
Copy link

Colon instead of underscore is used to uniquely identify ServiceAliasConfig(route for a service).

@openshift-merge-robot openshift-merge-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 23, 2017
@pravisankar
Copy link
Author

@knobunc @rajatchopra @imcsk8 PTAL

@pravisankar
Copy link
Author

[test]

@smarterclayton
Copy link
Contributor

Do we have a test for this?

@imcsk8
Copy link
Contributor

imcsk8 commented Aug 23, 2017

LGTM

@pravisankar
Copy link
Author

pravisankar commented Aug 23, 2017 via email

@openshift-merge-robot openshift-merge-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 24, 2017
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 24, 2017
@pravisankar pravisankar changed the title Fix router FilterNamespaces() Fix filter namespaces in template router Aug 24, 2017
@pravisankar
Copy link
Author

Updates:

  • Removed endpoints and route key format assumptions in the template plugin and router code
  • Added test cases for router FilterNamespaces()

@knobunc @rajatchopra @imcsk8 @smarterclayton PTAL

@pravisankar
Copy link
Author

/retest

1 similar comment
@pravisankar
Copy link
Author

/retest

@pravisankar
Copy link
Author

/test extended_templates extended_conformance_gce

Copy link
Contributor

@rajatchopra rajatchopra left a 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.)

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 28, 2017
@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 28, 2017
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

Copy link
Contributor

@knobunc knobunc left a 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 (
Copy link
Contributor

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

@@ -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)
Copy link
Contributor

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?

Copy link
Author

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.

}

// 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)
Copy link
Contributor

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

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
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Author

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
Copy link
Contributor

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.

Copy link
Author

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).
Ravi Sankar Penta added 2 commits August 29, 2017 09:30
…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.
@openshift-merge-robot openshift-merge-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 29, 2017
@pravisankar
Copy link
Author

Commits are broken down to differentiate between actual bug fix and refactor work.
Only the essential bug fix commit will be back ported to 3.6

@pravisankar
Copy link
Author

@knobunc @rajatchopra Updated, PTAL

@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 29, 2017

@pravisankar: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/extended_templates 82899ce link /test extended_templates

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.

Copy link
Contributor

@knobunc knobunc left a comment

Choose a reason for hiding this comment

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

Great! Thanks.
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 29, 2017
@openshift-merge-robot
Copy link
Contributor

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue (batch tested with PRs 15853, 15916, 16017, 16027, 16043)

@openshift-merge-robot openshift-merge-robot merged commit 22375a5 into openshift:master Aug 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/routing lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants