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 taint function and taints property to Node #530

Merged
merged 6 commits into from
Dec 17, 2024

Conversation

thomasjpfan
Copy link
Contributor

@thomasjpfan thomasjpfan commented Dec 7, 2024

Addresses part of #326

This PR adds:

  • A taints property, so nodes.taints gives you access to the taints.
  • A taint function to add a taint
  • A nice to have effect="NoSchedule-" that remove the taint. This is consistent with how kubectl works for removing a taint.

Copy link

codecov bot commented Dec 7, 2024

Codecov Report

Attention: Patch coverage is 96.96970% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.14%. Comparing base (87063fc) to head (e128abb).
Report is 153 commits behind head on main.

Files with missing lines Patch % Lines
kr8s/tests/test_objects.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #530      +/-   ##
==========================================
+ Coverage   94.61%   95.14%   +0.52%     
==========================================
  Files          29       30       +1     
  Lines        3141     4077     +936     
==========================================
+ Hits         2972     3879     +907     
- Misses        169      198      +29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

kr8s/_objects.py Outdated
Comment on lines 844 to 846
await self.async_patch(
{"spec": {"taints": [{"effect": effect, "key": key, "value": value}]}}
)
Copy link
Member

Choose a reason for hiding this comment

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

If there are already taints will this not replace them all with this new taint? We might need to do "op": "add" here instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.

Looking at kubectl taint nodes ... my-key=value1:NoSchedule -v10, I see it makes two calls, one to get all the taints, and another one update it. I updated this PR to copy what kubectl does.

Copy link
Member

@jacobtomlinson jacobtomlinson left a comment

Choose a reason for hiding this comment

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

Awesome thanks @thomasjpfan

kr8s/_objects.py Show resolved Hide resolved
@jacobtomlinson jacobtomlinson merged commit 537de43 into kr8s-org:main Dec 17, 2024
13 checks passed
@jacobtomlinson jacobtomlinson added the enhancement New feature or request label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request kr8s tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants