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

Add annotationFilter to Ambassador Hosts #2043

Conversation

RicardoNalesAmato
Copy link

@RicardoNalesAmato RicardoNalesAmato commented Apr 9, 2021

This commit allows users to filter the Host resources based on
a given annotation using --annotation-filter.

This commit uses the same AnnotationFilter that is
already available (so a new type was not added) and already used
by many other source types.

@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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 9, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: RicardoNalesAmato
To complete the pull request process, please assign njuettner after the PR has been reviewed.
You can assign the PR to them by writing /assign @njuettner in a comment when ready.

The full list of commands accepted by this bot can be found 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 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 Apr 9, 2021
@seanmalloy
Copy link
Member

/kind feature

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 9, 2021
Copy link
Contributor

@Raffo Raffo left a comment

Choose a reason for hiding this comment

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

Can we add tests to this PR to test the filtering functionality?

@RicardoNalesAmato
Copy link
Author

Can we add tests to this PR to test the filtering functionality?

Sure, I'll add that as soon as possible.

@RicardoNalesAmato RicardoNalesAmato force-pushed the add-ambassador-id-filter branch 2 times, most recently from 12ac3e6 to 846f7b1 Compare April 16, 2021 00:55
Copy link
Member

@njuettner njuettner left a comment

Choose a reason for hiding this comment

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

Hello hello 👋🏻 , in general I'm fine merging this, however I'd like to see some tests added to the changes you made. Do you mind adding some tests to see if that works like expected?
Thank you ❤️

@k8s-triage-robot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 26, 2021
@RicardoNalesAmato
Copy link
Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 29, 2021
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 27, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 9, 2021
@RicardoNalesAmato
Copy link
Author

RicardoNalesAmato commented Jan 25, 2022

@njuettner @Raffo I completely forgot about this PR! I will be adding the tests this week. Are you guys still ok with merging this?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 26, 2022
@KyleMartin901
Copy link

Sorry I was just searching the PRs for Ambassador and came across this one. I also created a PR for this feature as I only searched the issues 🤦‍♂️ to see if anyone else had issues with the annotation filter not working. I have added a bunch of tests to my PR so you can steal them if you would like. #2633

@RicardoNalesAmato
Copy link
Author

Sorry I was just searching the PRs for Ambassador and came across this one. I also created a PR for this feature as I only searched the issues 🤦‍♂️ to see if anyone else had issues with the annotation filter not working. I have added a bunch of tests to my PR so you can steal them if you would like. #2633

Thanks @KyleMartin901 . If the implementation is the same and you've already added the tests I'd say let's try to get your PR merged instead.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 2, 2022
This commit allows users to filter the Host resources based on
a given annotation using `--annotation-filter`.

This commit uses the same `AnnotationFilter` that is
already available (so a new type was not added) and already used
by many other source types.

Signed-off-by: Ricardo Nales Amato <ricardo.amato@tradeshift.com>
@KyleMartin901
Copy link

@RicardoNalesAmato, our implementation is nearly identical. The filterByAnnotations function is identical and so is our addition of the annotationFilter to the NewAmbassadorHostSource we just implemented the Endpoints function a bit differently to get the same result.

I am happy either way if we use yours or mine would just love to have it fixed so won't have to maintain a fork with the patch 😀 You were first and have interacted with the team so happy to just have the tests added to your implementation so you maintain the credit for your work.

@RicardoNalesAmato
Copy link
Author

@RicardoNalesAmato, our implementation is nearly identical. The filterByAnnotations function is identical and so is our addition of the annotationFilter to the NewAmbassadorHostSource we just implemented the Endpoints function a bit differently to get the same result.

I am happy either way if we use yours or mine would just love to have it fixed so won't have to maintain a fork with the patch 😀 You were first and have interacted with the team so happy to just have the tests added to your implementation so you maintain the credit for your work.

Thanks, @KyleMartin901! I'll copy your tests later today and will ping the team afterwards.

@alebedev87
Copy link
Contributor

@RicardoNalesAmato : any particular reason why annotations are used for the filtering on the resources? Except for the historical one :)
The labels are better suited for filtering on Kube resources, the sources like service, ingress, etc. were enabled for the label filtering.

@KyleMartin901
Copy link

KyleMartin901 commented May 16, 2022

@alebedev87 currently the label filter doesn't support the Ambassador Host resource type are you suggesting modifying the PR to allow the Host resource type via the label filter?

For me, I missed that the label filter had been added as an option I was modelling my implementation off of the 3rd party sources like the Isto Gateway, and Contour HTTP Proxy that didn't have it enabled and I had only been using the annotation filter so totally missed it 😞.

I copied the existing implementations of 3rd party sources like the Isto Gateway, Contour HTTP Proxy etc. Should all the 3rd party sources be added to the label filter each individually by essentially copying what was done for service and ingress as done in the PR d91b7e6

@KyleMartin901
Copy link

@alebedev87 I just pushed an update to my PR f10f6eb so it now includes the label filter is that what you were looking for.

@alebedev87
Copy link
Contributor

@KyleMartin901 : yes f10f6eb commit looks like what I meant by the label filtering.

However when I looked at the unit tests and saw that AmbassadorHost uses ingress.class annotation, kinda similar to the old way of specifying the ingress class for Ingress resource (before a dedicated API field appeared). I believe that the annotation filter of ExternalDNS was done partially for the reason to be able to filter Ingresses by the ingress class in the annotation. I'm wondering whether AmbassadorHost uses ingress.class annotation the same way Ingress used to. Then it may indeed make sense to keep the filtering by the annotation or think about the API enhancement for AmbassadorHost.
My guess is that the other implementations copied the ingress one without a lot of thinking of whether of they wanted to filter this way and whether it actually makes any sense to use not indexed part of the metadata.

@RicardoNalesAmato
Copy link
Author

Hey @KyleMartin901 I was more busy than I expected last week and forgot to update this PR. Would you like to go with your PR instead as I see you’ve made some more changes, or shall I copy them to this one?

@alebedev87 In our case having that annotation greatly reduced the complexity of our Nginx to Ambassador migration. I believe that is the main reason why all other implementations Did the same thing. Could we perhaps move forward with this solution and refine it at a later date?

@KyleMartin901
Copy link

@RicardoNalesAmato i don't mind as long as we can get either one added I'll be super happy. If you don't have time I'm happy to go with mine but also happy if you want to cherry-pick the label implementation and just add the annotation tests.

@KyleMartin901
Copy link

@alebedev87 if you have any more information on what you like done to be able to get my PR merged in so an AmbassadorHost is able to be filtered would be awesome.

I used the ingress.class annotation within the tests just so the tests matched the other sources and the examples used for the AWS provider as I presumed most people would be looking at those for how it should be used, so I used them to keep it constant within the External DNS project.

The Ambassador Host resource itself doesn't use the ingress.class annotation to create an ingress route you must define an Ambassador Host and an Ambassador Mapping resource for any ingress to be created.

@alebedev87
Copy link
Contributor

@KyleMartin901: cool, thanks for addressing my remark! I left a small review.
@RicardoNalesAmato : can we close this PR since we have Kyle's one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests-missing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants