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

Pass service/port tuple separate from ServicePort #270

Merged
merged 1 commit into from
May 15, 2018

Conversation

nicksardo
Copy link
Contributor

Changes:

  • Users can now configure the default backend service port by flag - defaults to "http".
  • Controller checks that the default backend service exists and has the specified port name.
  • Now only the ServicePortID is passed to the LBC - the nodeport is no longer cached.
  • TranslateIngress may now return an error. This will occur if the default backend service does not exist at sync-time.

@nicksardo nicksardo requested a review from rramkumar1 May 15, 2018 16:10
@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 May 15, 2018
return nil
}
negName := b.namer.NEG(port.SvcName.Namespace, port.SvcName.Name, port.SvcTargetPort)
negName := b.namer.NEG(sp.ID.Service.Namespace, sp.ID.Service.Name, sp.SvcTargetPort)
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 use the new BackendName function here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this name is used for both the NEG and the BackendService. I'll be redundantly clear and use BackendName for when we get the backendservice; however, I think this line is still appropriate for the NEG.

urlMap := lbc.Translator.TranslateIngress(ing, lbc.CloudClusterManager.defaultBackendSvcPort)
urlMap, err := lbc.Translator.TranslateIngress(ing, lbc.CloudClusterManager.defaultBackendSvcPortID)
if err != nil {
return fmt.Errorf("error while evaluating the ingress spec: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@@ -103,8 +104,10 @@ controller only works with default zones.`)
must serve a 200 page on this path.`)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would maybe add one line that says that default-backend-service and default-backend-service-port are mandatory.

return namer.NEG(sp.ID.Service.Namespace, sp.ID.Service.Name, sp.SvcTargetPort)
}

// BackendToServicePortID creates a ServicePortID struct from an IngressBackend struct and namespace.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Remove the word struct from the comment.

@@ -62,6 +63,18 @@ func IsHTTPErrorCode(err error, code int) bool {
return ok && apiErr.Code == code
}

// ToNamespacedName returns a types.NamespacedName struct parsed from namespace/name.
func ToNamespacedName(s string) (r types.NamespacedName, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Tiny test for this?

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 15, 2018
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 15, 2018
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@nicksardo
Copy link
Contributor Author

Fixed a small typo in the test.

@nicksardo nicksardo added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 15, 2018
@nicksardo nicksardo merged commit 285e110 into kubernetes:master May 15, 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.

3 participants