-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
GCE: Updating instance groups interface to accept all named ports at once #1463
Conversation
Reviewed 10 of 10 files at r1. controllers/gce/backends/backends_test.go, line 264 at r1 (raw file):
Can you please update the unit test to exercise your new code using multiple ports? Could you combine these two pool.Add() calls? controllers/gce/controller/utils_test.go, line 81 at r1 (raw file):
Is it useful or valuable to verify the length of cm.fakeIGs.Ports? controllers/gce/instances/instances_test.go, line 72 at r1 (raw file):
same here, perhaps add a test that exercises multiple ports. Comments from Reviewable |
9a8789d
to
456c558
Compare
Review status: 8 of 11 files reviewed at latest revision, 3 unresolved discussions. controllers/gce/backends/backends_test.go, line 264 at r1 (raw file): Previously, G-Harmon wrote…
The line below this is calling Add with multiple ports. controllers/gce/controller/utils_test.go, line 81 at r1 (raw file): Previously, G-Harmon wrote…
Good point, done. controllers/gce/instances/instances_test.go, line 72 at r1 (raw file): Previously, G-Harmon wrote…
Done. Figured there were no port specific tests. Comments from Reviewable |
Thanks @G-Harmon for the review. Have updated code as per comments. PTAL |
controllers/gce/backends/backends.go
Outdated
defer func() { b.snapshotter.Add(portKey(p.Port), be) }() | ||
|
||
var err error | ||
func (b *Backends) Add(svcPorts []ServicePort, igs []*compute.InstanceGroup) 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.
What do you think about renaming this func to 'Sync'?
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.
Sync will imply that we will add missing ones and delete extras. But this one adds and not deletes. Thats the reason I prefer add over sync
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.
But we also update backend services.
controllers/gce/backends/backends.go
Outdated
// addWithIGs will get or create a Backend for the given port. | ||
// It assumes that the instance groups have been created and required named port has been added. | ||
// If not, then Add should be called instead. | ||
func (b *Backends) addWithIGs(p ServicePort, igs []*compute.InstanceGroup) 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.
How about naming "syncBackendService"?
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.
renamed to addBackendService. Same argument as above about sync vs add.
controllers/gce/instances/fakes.go
Outdated
@@ -151,20 +150,19 @@ func (f *FakeInstanceGroups) RemoveInstancesFromInstanceGroup(name, zone string, | |||
|
|||
func (f *FakeInstanceGroups) SetNamedPortsOfInstanceGroup(igName, zone string, namedPorts []*compute.NamedPort) error { | |||
found := false | |||
for _, ig := range f.instanceGroups { | |||
if ig.Name == igName && ig.Zone == zone { | |||
var ig *compute.InstanceGroup |
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.
Can remove the above found variable and use ig == nil
for the "failed to find..." 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.
Done
glog.V(3).Infof("Instance group %v already has named port %+v", ig.Name, np) | ||
found = true | ||
break | ||
continue |
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.
glog.V(3).Infof("Instance group %v already has named port %+v", ig.Name, np)
occurs very frequently. Recommend we bump the level to 5. Thoughts?
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.
Sure. You look at logs a lot more than me, so happy to do whatever you say :)
Updated to 5.
if np.Port == port { | ||
existingPorts[np.Port] = true | ||
} | ||
newPorts := []*compute.NamedPort{} |
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: var newPorts []*compute.NamedPort
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
Done reviewing. PTAL at my comments but looks great otherwise. |
Looks like CI failed building the tests: https://travis-ci.org/kubernetes/ingress/jobs/283895016 |
ef37b4e
to
4c463a7
Compare
|
||
// node pool syncs kube-nodes, this will add them to both igs. | ||
lbc.CloudClusterManager.instancePool.Sync([]string{"n1", "n2", "n3"}) | ||
gotZonesToNode := cm.fakeIGs.GetInstancesByZone() | ||
|
||
if cm.fakeIGs.Ports[0] != testPort { |
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.
Removed this since we already have a dedicated test for testing ports on instance groups. No need to duplicate the check here.
Thanks @nicksardo ! |
4c463a7
to
3dcdc26
Compare
Renamed Add to Ensure as discussed |
Follow up from #1033.
Updating the BackendPool (for backend services) and NodePool (for instance groups) interfaces so that all named ports can be added to an instance group at once. This removes unnecessary API calls where for each named port, we were first fetching the instance group and then setting the named port on it. With this change, we should fetch the instance group once and then set all named ports in a single API call.
Have also removed BackendPool.Sync method since Add does the same now.
Sync was also misleading since it only added backend services and didnt delete them. Add is more explicit.
cc @nicksardo @csbell @G-Harmon