-
Notifications
You must be signed in to change notification settings - Fork 303
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
Conversation
agau4779
commented
Apr 25, 2018
- 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
/assign bowei nicksardo |
/ok-to-test |
pkg/backends/backends.go
Outdated
beGa, err = b.cloud.GetGlobalBackendService(nodePortBsName) | ||
if err != nil { | ||
return nil, err | ||
} |
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.
Move the API call and error handling out of the conditions and only choose between the names.
pkg/backends/backends.go
Outdated
|
||
if p.NEGEnabled { | ||
beName = b.namer.NEG(p.SvcName.Namespace, p.SvcName.Name, p.SvcTargetPort) | ||
} |
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 seems to be calculated a few times in ensureBackendService
. Move to top and use it everywhere?
pkg/backends/backends.go
Outdated
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) { |
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.
Maybe this function just takes the backend name?
/assign freehan |
pkg/utils/namer.go
Outdated
func (n *Namer) ParseNEGName(name string) *NameComponents { | ||
l := strings.Split(name, "-") | ||
return &NameComponents{ | ||
ClusterName: l[1], |
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.
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.
d84ee6e
to
7da4b49
Compare
pkg/backends/backends_test.go
Outdated
// 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 { |
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.
Doesn't capture the case of getting an error and not expecting an error.
if tc.expectSyncErr != (err != nil) {
pkg/backends/backends_test.go
Outdated
// 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") |
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.
Nit: use standardized error messages
t.Errorf("Ensure(%v, nil) = %v, want err? %v", tc.newPorts, err, tc.expectSyncErr)
pkg/backends/backends_test.go
Outdated
} | ||
|
||
if err := pool.Ensure(tc.oldPorts, nil); err != nil { | ||
t.Errorf("Expected backend pool to add node ports, err: %v", err) |
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.
nit: start using standard pattern
t.Errorf("Ensure(%v, nil) = %v, want nil", tc.oldPorts, err)
3d851d7
to
d2ac975
Compare
@@ -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 { |
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.
Doesn't there need to be more work for the healthchecker to not use nodeport?
c7cc11c
to
9e97151
Compare
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 ```