-
Notifications
You must be signed in to change notification settings - Fork 299
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
do not sync IG when not necessary #1105
Conversation
Can you fill out the commit message with details about what is being fixed? |
LGTM But I will let @bowei to tag it - he is more familiar with the codebase than me. |
@bowei Updated the commit message. |
Added testing. Ready for another round. |
pkg/controller/controller.go
Outdated
@@ -398,6 +373,9 @@ func (lbc *LoadBalancerController) SyncBackends(state interface{}) error { | |||
|
|||
// Get the zones our groups live in. | |||
zones, err := lbc.Translator.ListZones() | |||
if err != nil { | |||
klog.Errorf("Failed to list zones: %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.
Isn't this a problem to go onto the rest of the flow if we aren't able to get a list of the zones?
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.
fixed
BTW -- can we have commits message that follow this: https://chris.beams.io/posts/git-commit/ For trick change like this, it's worthwhile explaining a bit more about these changes. |
/hold |
Updated commit message. |
if err = updateAnnotations(lbc.ctx.KubeClient, ing.Name, ing.Namespace, ing.Annotations); err != nil { | ||
// Only sync instance group when IG is used for this ingress | ||
if len(nodePorts(ingSvcPorts)) > 0 { | ||
if err := lbc.syncInstanceGroup(syncState.ing, ingSvcPorts); 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.
log 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.
log which ingress this was looking at syncState.ing.
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.
fix this later, you should always use the right type vs %v (%s:%s)
pkg/controller/controller.go
Outdated
@@ -421,6 +399,40 @@ func (lbc *LoadBalancerController) SyncBackends(state interface{}) error { | |||
return nil | |||
} | |||
|
|||
// syncInstanceGroup creates instance groups, syncs instances, sets named ports and updates instance group annotation | |||
func (lbc *LoadBalancerController) syncInstanceGroup(ing *v1beta1.Ingress, ingSvcPorts []utils.ServicePort) error { | |||
igs, err := lbc.instancePool.EnsureInstanceGroupsAndPorts(lbc.ctx.ClusterNamer.InstanceGroup(), nodePorts(ingSvcPorts)) |
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.
log the action taking place here
klog.V(2).Infof(
ns, name of ingress
svc ports,
need to log major actions |
Fix the comments. |
pkg/controller/controller.go
Outdated
// This short-circuit will stop the syncer from moving to next step. | ||
return ingsync.ErrSkipBackendsSync | ||
} else { | ||
klog.V(2).Infof("Skip syncing instance groups") |
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.
log the identity of the ingress object that this is considering
syncState.ing
if err = updateAnnotations(lbc.ctx.KubeClient, ing.Name, ing.Namespace, ing.Annotations); err != nil { | ||
// Only sync instance group when IG is used for this ingress | ||
if len(nodePorts(ingSvcPorts)) > 0 { | ||
if err := lbc.syncInstanceGroup(syncState.ing, ingSvcPorts); 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.
log which ingress this was looking at syncState.ing.
pkg/controller/controller.go
Outdated
|
||
// TODO: Remove this after deprecation | ||
if utils.IsGCEMultiClusterIngress(ing) { | ||
klog.Warningf("kubemci is used for ingress %v+", ing) |
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 is with the +
pkg/controller/controller_test.go
Outdated
@@ -176,6 +178,37 @@ func TestIngressSyncError(t *testing.T) { | |||
} | |||
} | |||
|
|||
// TestNegOnlyIngress asserts that `sync` will not create IG when there is only NEG backends for the ingress | |||
func TestNegOnlyIngress(t *testing.T) { |
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.
TestNEGOnlyIngress
pkg/controller/controller_test.go
Outdated
Ports: []api_v1.ServicePort{{Port: 80}}, | ||
}) | ||
negAnnotation := annotations.NegAnnotation{Ingress: true} | ||
svc.Annotations = map[string]string{} |
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.
combine
svc.Annotations = map[string]string{
annotations.NEGAnnotationKey: annotations.NegAnnotation{Ingress: true}.String(),
}
pkg/controller/controller_test.go
Outdated
|
||
ig, err := lbc.instancePool.Get(lbc.ctx.ClusterNamer.InstanceGroup(), fakeZone) | ||
if err != nil && !utils.IsHTTPErrorCode(err, http.StatusNotFound) { | ||
t.Errorf("lbc.ctx.Cloud.ListInstanceGroups(%v) = %v, %v, want [], nil", fakeZone, ig, 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.
want [], http.StatusNotFound
Fixed. Ready. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bowei, freehan 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 |
Cherrypick #1105 into Release-1.9
No description provided.