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

sort ingress by namespace and name when ingress.CreationTimestamp identical #4409

Merged
merged 1 commit into from
Aug 19, 2019

Conversation

nic-6443
Copy link
Contributor

@nic-6443 nic-6443 commented Aug 7, 2019

What this PR does / why we need it:
Because store.ListIngresses() sort Ingresses using the CreationTimestamp field and s.listers.IngressWithAnnotation.List() use map as backend cache , So when the list contains more than one Ingress with the same creationTimestamp, the sorting results are unstable.

// ListIngresses returns the list of Ingresses
func (s *k8sStore) ListIngresses(filter IngressFilterFunc) []*ingress.Ingress {
	for _, item := range s.listers.IngressWithAnnotation.List() {
                //Irrelevant logic ignored
		ingresses = append(ingresses, ing)
	}

	// sort Ingresses using the CreationTimestamp field
	sort.SliceStable(ingresses, func(i, j int) bool {
		ir := ingresses[i].CreationTimestamp
		jr := ingresses[j].CreationTimestamp
		return ir.Before(&jr)
	})

	return ingresses
}

For the reasons mentioned above, the output of Server.rootLocation logic will be equally unstable, resulting in slight differences in nginx.conf generated each time, triggering repeated meaningless nginx reload.
Server.rootLocation generate in controller.createServers()

for _, ing := range data {
         anns := ing.ParsedAnnotations
	for _, rule := range ing.Spec.Rules {
		if _, ok := servers[host]; ok {
			// server already configured
			continue
		}
		loc := &ingress.Location{
			Path:         rootLocation,
			IsDefBackend: true
		}

                //Because of the unstable order, anns may point to  different ingress.annotaions
		locationApplyAnnotations(loc, anns) 

		servers[host] = &ingress.Server{
			Locations: []*ingress.Location{
				loc,
			}
		}
	}
}

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 7, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @ProNic-QY. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 7, 2019
@aledbf
Copy link
Member

aledbf commented Aug 7, 2019

@ProNic-QY please don't assign PRs manually

@aledbf
Copy link
Member

aledbf commented Aug 7, 2019

Also, please sign the CLA

@aledbf aledbf unassigned bowei Aug 7, 2019
@nic-6443
Copy link
Contributor Author

nic-6443 commented Aug 8, 2019

I signed it

@aledbf
Copy link
Member

aledbf commented Aug 8, 2019

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 8, 2019
@nic-6443 nic-6443 force-pushed the master branch 3 times, most recently from d71a9dc to dce398f Compare August 8, 2019 02:06
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 8, 2019
@codecov-io
Copy link

codecov-io commented Aug 8, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@443886e). Click here to learn what that means.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #4409   +/-   ##
=========================================
  Coverage          ?   59.78%           
=========================================
  Files             ?       89           
  Lines             ?     7020           
  Branches          ?        0           
=========================================
  Hits              ?     4197           
  Misses            ?     2389           
  Partials          ?      434
Impacted Files Coverage Δ
internal/ingress/controller/store/store.go 61.64% <33.33%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 443886e...70614f4. Read the comment docs.

@ElvinEfendi
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 8, 2019
@aledbf
Copy link
Member

aledbf commented Aug 8, 2019

/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 Aug 8, 2019
@nic-6443
Copy link
Contributor Author

nic-6443 commented Aug 16, 2019

@aledbf Why remove this PR from 0.26.0?

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 18, 2019
@aledbf aledbf removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 19, 2019
@aledbf
Copy link
Member

aledbf commented Aug 19, 2019

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aledbf, ElvinEfendi, ProNic-QY

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

@k8s-ci-robot k8s-ci-robot merged commit 6697203 into kubernetes:master Aug 19, 2019
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants