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

BackendService Naming #239

Closed
wants to merge 3 commits into from
Closed

Conversation

agau4779
Copy link
Contributor

  • Use NEG naming schema for NEG Backends associated with NEG-enabled ServicePorts. Rely on garbage collection to remove Backends with the incorrect naming schema.
  • Instead of md5 hash, use a sha256 hash of concatenated values for NEG name suffix
  • Use BackendService name as the key in BackendPool.snapshotter

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 25, 2018
@agau4779
Copy link
Contributor Author

/assign bowei nicksardo

@nicksardo
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 25, 2018
beGa, err = b.cloud.GetGlobalBackendService(nodePortBsName)
if err != nil {
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Move the API call and error handling out of the conditions and only choose between the names.


if p.NEGEnabled {
beName = b.namer.NEG(p.SvcName.Namespace, p.SvcName.Name, p.SvcTargetPort)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be calculated a few times in ensureBackendService. Move to top and use it everywhere?

beGa, err := b.cloud.GetGlobalBackendService(b.namer.Backend(port))
if err != nil {
return nil, err
func (b *Backends) Get(port ServicePort, isAlpha bool) (*BackendService, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this function just takes the backend name?

@agau4779
Copy link
Contributor Author

/assign freehan

func (n *Namer) ParseNEGName(name string) *NameComponents {
l := strings.Split(name, "-")
return &NameComponents{
ClusterName: l[1],
Copy link
Contributor

@nicksardo nicksardo Apr 25, 2018

Choose a reason for hiding this comment

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

ParseNegName should gracefully handle non-neg named things, including things that aren't valid names like "ABC". Please add a unit test case for NameBelongsToCluster with unexpected names like that.

// Ensuring these ports again without first Garbage Collecting goes over
// the set quota. Expect an error here, until GC is called.
err := pool.Ensure(tc.newPorts, nil)
if tc.expectSyncErr && err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't capture the case of getting an error and not expecting an error.

if tc.expectSyncErr != (err != nil) {

// the set quota. Expect an error here, until GC is called.
err := pool.Ensure(tc.newPorts, nil)
if tc.expectSyncErr && err == nil {
t.Errorf("Expect initial sync to go over quota, but received no error")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: use standardized error messages
t.Errorf("Ensure(%v, nil) = %v, want err? %v", tc.newPorts, err, tc.expectSyncErr)

}

if err := pool.Ensure(tc.oldPorts, nil); err != nil {
t.Errorf("Expected backend pool to add node ports, err: %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.

nit: start using standard pattern

t.Errorf("Ensure(%v, nil) = %v, want nil", tc.oldPorts, err)

@agau4779 agau4779 force-pushed the backendsvc-naming branch from 3d851d7 to d2ac975 Compare May 4, 2018 18:28
@@ -189,8 +189,7 @@ func (h *HealthChecks) getHealthCheckLink(port int64, alpha bool) (string, error
}

// Delete deletes the health check by port.
func (h *HealthChecks) Delete(port int64) error {
name := h.namer.Backend(port)
func (h *HealthChecks) Delete(name string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't there need to be more work for the healthchecker to not use nodeport?

@agau4779 agau4779 force-pushed the backendsvc-naming branch from c7cc11c to 9e97151 Compare May 9, 2018 16:55
@nicksardo nicksardo closed this May 10, 2018
k8s-github-robot pushed a commit to kubernetes/kubernetes that referenced this pull request May 14, 2018
Automatic merge from submit-queue (batch tested with PRs 55511, 63372, 63400, 63100, 63769). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

[GCE] check for new backend naming scheme

**What this PR does / why we need it**:
Checks for both the old Backend naming scheme (Nodeport in the name) and the new naming scheme (same scheme used to name NEGs). We need to check for both, in order for both the tests against Ingress head (once kubernetes/ingress-gce#239 gets merged) and tests against prior Ingress versions to pass. 

See kubernetes/ingress-gce#239 .

**Release note**:
```release-note
NONE
```
@agau4779 agau4779 deleted the backendsvc-naming branch February 6, 2019 19:54
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. 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.

5 participants