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 common wait conditions for Deployments, LoadBalancer Services, and Ingress #1710

Merged
merged 3 commits into from
Mar 7, 2025

Conversation

detjensrobert
Copy link
Contributor

Motivation

I've been using this library to create a custom tool to deploy applications, and have been using these conditions via await_condition to wait for those applications to become ready or report failures back to the users.

Since these are generally useful for waiting for these types of services to become available, I'm hoping to contribute these back upstream so that other client-esque applications have these ready to use.

Solution

This adds a few new wait conditions to kube-runtime::wait::conditions for Deployments, LoadBalancer-type Services, and Ingresss to complete or become ready.

The Deployment check (is_deployment_completed()) matches K8S's definition of completed deployments.

LoadBalancer and Ingress resources don't have an associated status condition for 'ready', but they are updated with the LoadBalancer details the backing cloud/etc load balancer has been fully provisioned and is ready. The new is_ingress_provisioned() / is_service_loadbalancer_provisioned() checks wait for that update to set .status.loadBalancer.ingress.(ip|hostname). Non-loadbalancer services are ignored by always returning true i.e. immediately ready.

I did not add tests for these since the existing condition checks do not have any.

@clux clux added the changelog-add changelog added category for prs label Mar 4, 2025
Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

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

These all look great. Thank you very much for these.

Small suggestion on how to unit test them would be appreciated, but otherwise vhappy to merge this.

Comment on lines +274 to +276
if spec.type_ != Some("LoadBalancer".to_string()) {
return true;
}
Copy link
Member

Choose a reason for hiding this comment

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

i guess this is the only questionable thing, and it's not really a fault of yours, but more about us conflating bools and options. i'll think a bit about #1498 after this pr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I don't think there's any better way to handle this at the moment.

Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.2%. Comparing base (4234e8a) to head (31d6907).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1710     +/-   ##
=======================================
+ Coverage   75.8%   76.2%   +0.4%     
=======================================
  Files         84      84             
  Lines       7743    7847    +104     
=======================================
+ Hits        5866    5972    +106     
+ Misses      1877    1875      -2     
Files with missing lines Coverage Δ
kube-runtime/src/wait.rs 93.5% <100.0%> (+18.5%) ⬆️
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@detjensrobert detjensrobert changed the title Add common wait conditions for Deployments, LoadBalancers, and Ingress Add common wait conditions for Deployments, LoadBalancer Services, and Ingress Mar 6, 2025
These are common wait conditions for these resources, and are useful for
waiting for exposed services to become available.

Signed-off-by: Robert Detjens <[email protected]>
These tests run the condition function against included yaml snippets
of objects returned by the K8S API to check against known-state statuses.

Signed-off-by: Robert Detjens <[email protected]>
@detjensrobert detjensrobert force-pushed the extra-wait-conditions branch from cf2d6d0 to 31d6907 Compare March 6, 2025 17:28
@clux clux added this to the 0.99.0 milestone Mar 7, 2025
@clux clux merged commit b27cbcd into kube-rs:main Mar 7, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-add changelog added category for prs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants