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

do not sync IG when not necessary #1105

Merged
merged 2 commits into from
May 27, 2020
Merged

Conversation

freehan
Copy link
Contributor

@freehan freehan commented May 19, 2020

No description provided.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 19, 2020
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 19, 2020
@bowei
Copy link
Member

bowei commented May 19, 2020

Can you fill out the commit message with details about what is being fixed?
How was this tested?

@wojtek-t
Copy link
Member

LGTM

But I will let @bowei to tag it - he is more familiar with the codebase than me.

@freehan
Copy link
Contributor Author

freehan commented May 19, 2020

@bowei Updated the commit message.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 19, 2020
@freehan
Copy link
Contributor Author

freehan commented May 19, 2020

Added testing. Ready for another round.

@@ -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)
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@bowei
Copy link
Member

bowei commented May 20, 2020

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.
The commit messages help the reviewer as well as those who are going to be maintaining the code

@bowei
Copy link
Member

bowei commented May 20, 2020

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 20, 2020
@freehan
Copy link
Contributor Author

freehan commented May 20, 2020

Updated commit message.
Fix the comments.
Ready for another round.

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 {
Copy link
Member

Choose a reason for hiding this comment

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

log error

Copy link
Member

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.

Copy link
Member

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)

@@ -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))
Copy link
Member

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,

@bowei
Copy link
Member

bowei commented May 21, 2020

need to log major actions

@freehan
Copy link
Contributor Author

freehan commented May 21, 2020

Fix the comments.
Ready for another round.

// This short-circuit will stop the syncer from moving to next step.
return ingsync.ErrSkipBackendsSync
} else {
klog.V(2).Infof("Skip syncing instance groups")
Copy link
Member

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 {
Copy link
Member

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.


// TODO: Remove this after deprecation
if utils.IsGCEMultiClusterIngress(ing) {
klog.Warningf("kubemci is used for ingress %v+", ing)
Copy link
Member

Choose a reason for hiding this comment

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

What is with the +

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

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

TestNEGOnlyIngress

Ports: []api_v1.ServicePort{{Port: 80}},
})
negAnnotation := annotations.NegAnnotation{Ingress: true}
svc.Annotations = map[string]string{}
Copy link
Member

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(),
}


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)
Copy link
Member

Choose a reason for hiding this comment

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

want [], http.StatusNotFound

@freehan
Copy link
Contributor Author

freehan commented May 27, 2020

Fixed. Ready.

@bowei
Copy link
Member

bowei commented May 27, 2020

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 27, 2020
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@freehan freehan removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 27, 2020
@k8s-ci-robot k8s-ci-robot merged commit 26a9897 into kubernetes:master May 27, 2020
k8s-ci-robot added a commit that referenced this pull request May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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