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

Refactor translator.ToURLMap to not re-fetch backend services #207

Merged
merged 1 commit into from
Apr 12, 2018

Conversation

rramkumar1
Copy link
Contributor

@rramkumar1 rramkumar1 commented Apr 11, 2018

/assign @nicksardo @MrHohn

Will update tests once approach is LGTM'd.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 11, 2018
@rramkumar1
Copy link
Contributor Author

/cc @MrHohn

@rramkumar1 rramkumar1 force-pushed the translator-refactor-1 branch 3 times, most recently from 8b9fc52 to d99b42f Compare April 11, 2018 19:18
@@ -84,6 +84,9 @@ const (

// schemaVersionV1 is the version 1 naming scheme for NEG
schemaVersionV1 = "1"

// linkPrefix is the prefix for the link of GCE resources.
linkPrefix = "https://www.googleapis.com/compute/v1/projects"
Copy link
Member

Choose a reason for hiding this comment

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

Should we have different prefixes for alpha/beta/ga?

@rramkumar1 rramkumar1 force-pushed the translator-refactor-1 branch 3 times, most recently from 5de9f60 to 3fa5161 Compare April 11, 2018 21:39

// BackendRelativeResourcePath returns a relative path of the link for a
// BackendService given its name.
func BackendRelativeResourcePath(name string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use BackendService to not get confused with BackendService.Backend

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

// BackendComparableGroupPath trims project and compute version from the SelfLink
// for a global BackendService.
// /global/backendServices/[BACKEND_SERVICE_NAME]
func BackendComparableGroupPath(url string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Group was referring to InstanceGroup, which isn't applicable for the BackendService.
Maybe "BackendServiceComparablePath"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

// /global/backendServices/[BACKEND_SERVICE_NAME]
func BackendComparableGroupPath(url string) string {
path_parts := strings.Split(url, "/global/")
return fmt.Sprintf("/global/%s", path_parts[1])
Copy link
Contributor

Choose a reason for hiding this comment

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

We should handle the error case of len(url) != 2... Guessing we return empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@rramkumar1
Copy link
Contributor Author

Adding tests now.

@rramkumar1 rramkumar1 force-pushed the translator-refactor-1 branch 4 times, most recently from 501fbb9 to 8b15093 Compare April 11, 2018 23:25
if a.Service != b.Service {
// Trim down the url's for a.Service and b.Service to a comparable structure
// We do this because we update the UrlMap with relative links (not full) to backends.
if utils.BackendServiceComparablePath(a.Service) != utils.BackendServiceComparablePath(b.Service) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There are two more lines with Service equality checks. 775 and 805.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


// BackendServiceComparablePath trims project and compute version from the SelfLink
// for a global BackendService.
// /global/backendServices/[BACKEND_SERVICE_NAME]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: leading slash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@nicksardo
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 12, 2018
@nicksardo nicksardo merged commit ddfd5b5 into kubernetes:master Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", 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.

4 participants