-
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
Refactor Backend GC #810
Refactor Backend GC #810
Conversation
Hi @spencerhance. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/ok-to-test |
/assign @bowei |
pkg/backends/syncer.go
Outdated
} | ||
ilbBackends, err := s.backendPool.List(key, lbfeatures.L7ILBVersion(lbfeatures.BackendService)) | ||
if err != nil { | ||
return fmt.Errorf("error listing L7-ILB backends: %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.
More accurate to say "Error listing regional backends: %v"
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.
Done
ba8ffd7
to
48a133c
Compare
05a57f1
to
6ff08ff
Compare
if _, err := composite.GetBackendService(fakeGCE, key, features.VersionFromServicePort(&sp)); err != nil { | ||
return fmt.Errorf("Expected to find backend for port %v, err: %v", sp.NodePort, 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.
Don't we need to check things in p.all not in p.existing don't exist?
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.
Done
pkg/backends/syncer_test.go
Outdated
} | ||
// Make sure it was deleted | ||
if len(p.all) == beginLen { | ||
return fmt.Errorf("Error: %v does not exist in p.all", dp) |
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.
Error:
is redundant -- fmt.Errof("%v does not exist in p.all", dp)
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.
Done
pkg/backends/syncer_test.go
Outdated
// portset helps keep track of service ports during GC tests | ||
type portset struct { | ||
all []utils.ServicePort | ||
existing []utils.ServicePort |
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.
might want to make this a map
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.
Done
pkg/backends/syncer_test.go
Outdated
|
||
// Delete ports from existing that are not in 'all' | ||
func (p *portset) gc() { | ||
p.existing = p.all |
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.
p.existing = []utils.ServicePort{}
? It's kind of strange for gc() to /add/ stuff
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.
Ended up removing gc() since I think it's less confusing to just use add() and delete()
pkg/backends/syncer_test.go
Outdated
for i, sp := range p.all { | ||
if dp == sp { | ||
// Delete it | ||
p.all = append(p.all[:i], p.all[i:]...) |
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.
Why does all
change? doesn't it never change?
pkg/backends/syncer_test.go
Outdated
if err := syncer.Sync(svcNodePorts); err != nil { | ||
t.Fatalf("Expected syncer to add backends with error, err: %v", err) | ||
if err := syncer.Sync(ps.all); err != nil { | ||
t.Fatalf("error syncing backends: %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.
t.Fatalf("syncer.Sync(%+v) = %v; want nil", ps.all, 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.
You will want to follow this format for most of the unit test checks
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.
Done
if err != nil { | ||
return fmt.Errorf("error GCing regional Backends: %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.
this is a TODO, but we may want to consider continuing on error so a single error does not block all GC operations
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.
tracking here: #797
pkg/backends/syncer_test.go
Outdated
// portset helps keep track of service ports during GC tests | ||
type portset struct { | ||
// all represents the set all of service ports in the test | ||
all map[utils.ServicePort]struct{} |
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.
usually sets are represented by map[T]bool
then map[X] == false is natural
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.
done. Also i'm a fan, I didn't realize how go handled keys that aren't present.
pkg/backends/syncer_test.go
Outdated
return fmt.Errorf("Error creating key for backend service %s: %v", beName, err) | ||
} | ||
|
||
// Make sure it exists |
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.
comment is probably redundant, but if you are going to put this, put it inside the brace so that the comment for the different cases are at the same indent level.
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.
done
pkg/backends/syncer_test.go
Outdated
// Make sure it exists | ||
if found { | ||
if _, err := composite.GetBackendService(fakeGCE, key, features.VersionFromServicePort(&sp)); err != nil { | ||
return fmt.Errorf("Expected to find backend for port %+v, err: %v", sp.NodePort, 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.
"backend for port %+v should exist, but got %v"
"backend for port %+v should not exist, but get %v"
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.
done
pkg/backends/syncer_test.go
Outdated
return &ps | ||
} | ||
|
||
func (p *portset) existingSlice() []utils.ServicePort { |
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.
existingPorts
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.
done
pkg/healthchecks/healthchecks.go
Outdated
if err != nil { | ||
return fmt.Errorf("Error converting newHC to composite: %v", err) | ||
} | ||
key, err := composite.CreateKey(cloud, newHC.Name, features.L7ILBScope()) | ||
key, err := composite.CreateKey(cloud, mergedHC.Name, meta.Regional) |
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.
is there a reason why we went back to meta.Regional?
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.
I thought it seemed redundant but I reverted it back
pkg/healthchecks/healthchecks.go
Outdated
@@ -314,7 +313,17 @@ func (h *HealthChecks) getILB(name string) (*HealthCheck, error) { | |||
if err != nil { | |||
return nil, err | |||
} | |||
return NewHealthCheck(alphaHC) | |||
|
|||
newHC, err := NewHealthCheck(alphaHC) |
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.
call alphaHC gceHC and you won't have to change the name again when the version changes.
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.
done
045c134
to
d78aecc
Compare
- Refactor backends GC so that we don't need ListAllBackendServices() anymore. That way, if one of the api calls fails, it won't block the others. - Refactor backends GC unit tests - Fix a ILB health check update() bug
d78aecc
to
462b73c
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bowei, spencerhance The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
looks like the CI had issues. |
/retest |
Refactor backends GC so that we don't need ListAllBackendServices() anymore. That way, if one of the api calls fails, it won't block the others.