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 label selector to exclude deployments and cronjobs #220

Merged
merged 12 commits into from Dec 5, 2022

Conversation

dirk39
Copy link
Contributor

@dirk39 dirk39 commented Nov 12, 2022

Hello, with this PR we want to fix issue #172. We noticed that the behaviour of the Cronjob selector differs from the deployment. Do you think we can replicate the deployment behaviour in the cronjob? So we can add the matchLabels functionality.

Open Source Saturday

@dirk39 dirk39 changed the title Adding label selector to exclude deployments feat: adding label selector to exclude deployments Nov 12, 2022
@ludusrusso
Copy link
Contributor

LGTM

@coveralls
Copy link

coveralls commented Nov 12, 2022

Pull Request Test Coverage Report for Build 3614548454

  • 51 of 56 (91.07%) changed or added relevant lines in 6 files are covered.
  • 45 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.5%) to 85.868%

Changes Missing Coverage Covered Lines Changed/Added Lines %
controllers/sleepinfo/cronjobs/testutil.go 2 3 66.67%
api/v1alpha1/sleepinfo_webhook.go 4 6 66.67%
controllers/sleepinfo/cronjobs/cronjobs.go 14 16 87.5%
Files with Coverage Reduction New Missed Lines %
controllers/sleepinfo/sleepinfo_controller.go 45 70.56%
Totals Coverage Status
Change from base Build 3436741837: 0.5%
Covered Lines: 875
Relevant Lines: 1019

💛 - Coveralls

Copy link
Member

@davidebianchi davidebianchi left a comment

Choose a reason for hiding this comment

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

Hi @dirk39, thank you for the PR. Great work!

I didn't know the Open Source Saturday meetup, very interesting!

Here a couple of comments.

The implementation of the CronJob differs because it uses the FieldSelector query, do you mean this? This should be more performant, as it permits to get only the resources needed. It is not possible to add this filter using the FieldSelector?
Otherwise, yes I suppose that it is possible to change the implementation to add this filter.

@dirk39
Copy link
Contributor Author

dirk39 commented Nov 12, 2022

Hi @davidebianchi , the general idea was to uniform the behavior of the deployment and cronjob filter. I think that the deployment solution is easier to maintain but if you prefer I can have a look to the fieldSelector to see if they support the labelMatch.

@davidebianchi
Copy link
Member

CronJobs have been made after Deployments, so when I developed the Deployments I didn't know the fieldSelector. But with the labels, there might be a large number of Deployments and CronJobs to exclude so it could be better to use it. So yes, if you want to see for the support it would be better, but also this implementation is ok for me.

dirk39 and others added 3 commits November 13, 2022 17:10
Co-authored-by: ludusrusso <ludus.russo@gmail.com>
items

Co-authored-by: ludusrusso <ludus.russo@gmail.com>
@davidebianchi
Copy link
Member

Hi @dirk39, is it the introduction of labelSelector finished? I see that the last commit contains is in wip.

@davidebianchi davidebianchi added the enhancement New feature or request label Nov 26, 2022
@dirk39
Copy link
Contributor Author

dirk39 commented Nov 26, 2022

Hi @davidebianchi , I've introduced the labelselector for the cronjob but I have to add tests to validate the solution.

Signed-off-by: Andrea Quintino <andrea.quintino@alirahealth.com>
Signed-off-by: Andrea Quintino <andrea.quintino@alirahealth.com>
@dirk39
Copy link
Contributor Author

dirk39 commented Dec 4, 2022

Hi @davidebianchi, I'm sorry for my delay. I've added unit and e2e tests for the CJ. Let me know if it looks good to you

@davidebianchi davidebianchi changed the title feat: adding label selector to exclude deployments Add label selector to exclude deployments and cronjobs Dec 5, 2022
Copy link
Member

@davidebianchi davidebianchi left a comment

Choose a reason for hiding this comment

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

LGTM!

Thanks for the contribution, great work!

@davidebianchi davidebianchi merged commit b17d187 into kube-green:main Dec 5, 2022
@dirk39 dirk39 deleted the feature/label-selector branch December 5, 2022 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants