Use a read-timeout client for non-watch operations - #324
Conversation
in consistency with remainder codebase Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
for crates and testing Fixes: trusted-execution-clusters#227 Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
Reviewer's GuideIntroduce a dual Kubernetes client abstraction with read timeouts for non-watch operations while keeping separate watch clients for long-lived streams, refactor operator/tests/utilities to use it, tighten controller behaviors, and improve logging and CI observability. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The
KubeClientsstruct currently uses fairly generic field names (clientandwatch); consider renaming these to something more self-describing (e.g.request_client/watch_client) to make call-site intent clearer and avoid confusion when both are in scope. - Several paths now clone full
KubeClientsinstances when only one client is used (e.g. inlaunch_keygen_controller,launch_rv_*_controller, and test helpers); you could reduce unnecessary cloning by passing references or extracting just the needed client to keep ownership and lifetimes simpler.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `KubeClients` struct currently uses fairly generic field names (`client` and `watch`); consider renaming these to something more self-describing (e.g. `request_client` / `watch_client`) to make call-site intent clearer and avoid confusion when both are in scope.
- Several paths now clone full `KubeClients` instances when only one client is used (e.g. in `launch_keygen_controller`, `launch_rv_*_controller`, and test helpers); you could reduce unnecessary cloning by passing references or extracting just the needed client to keep ownership and lifetimes simpler.
## Individual Comments
### Comment 1
<location path="operator/src/register_server.rs" line_range="182-183" />
<code_context>
);
return Ok(Action::await_change());
}
+ Err(e) => {
+ let err = anyhow!("{e}").into();
+ return Err(finalizer::Error::<ControllerError>::CleanupFailed(err));
+ }
</code_context>
<issue_to_address>
**issue:** Wrapping `e` with `anyhow!("{e}")` discards the original error context and backtrace.
In the new `Err(e)` branch, converting `e` to `anyhow!("{e}")` before wrapping it in `finalizer::Error::CleanupFailed` loses the original structured error. Prefer propagating `e` directly (e.g. `finalizer::Error::CleanupFailed(e.into())`) so callers and logs preserve its full context and backtrace.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
SpaceFace02
left a comment
There was a problem hiding this comment.
Thanks for the PR! I have a few small suggestions
| /// (Controllers, Reflectors, `await_condition`). | ||
| #[derive(Clone)] | ||
| pub struct KubeClients { | ||
| pub client: Client, |
There was a problem hiding this comment.
nit: Like Sourcery mentioned, the naming could be changed to something less generic.
There was a problem hiding this comment.
nit: Also I don't know what would be the ideal way to name this, whether it should have the 's' in the end, indicating a plural. It is one object after all, with different functionalities available
Signed-off-by: Jakob Naucke <jnaucke@redhat.com> Assisted-by: AI
so that status is updated in a timely manner Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
Default kube-rs client has no read timeout so that watch operations are supported. Some non-watch operations have been seen to hang. Use a timeout of 30 seconds for such operations. Introduce a structure to pass both clients where needed. Signed-off-by: Jakob Naucke <jnaucke@redhat.com> Assisted-by: AI
GET on trustedexecutionclusters is known to fail occasionally. This should return an error, which will lead to a requeue. Thus, also increase base deletion timeout to 120s (30s timeout on failure, 60s requeue). Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
Jakob-Naucke
left a comment
There was a problem hiding this comment.
Several paths now clone full KubeClients instances when only one client is used (e.g. in launch_keygen_controller, launch_rv_*_controller, and test helpers); you could reduce unnecessary cloning by passing references or extracting just the needed client to keep ownership and lifetimes simpler.
@sourcery-ai these all use both
2d7d477 to
1ec63fe
Compare
SpaceFace02
left a comment
There was a problem hiding this comment.
LGTM 👍
nit: Also I don't know what would be the ideal way to name this, whether it should have the 's' in the end, indicating a plural. It is one object after all, with different functionalities available
Minor nit (but that shouldn't stop this PR from getting merged)
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Jakob-Naucke, SpaceFace02 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Default kube-rs client has no read timeout so that watch operations are supported. Some non-watch operations have been seen to hang. Use a timeout of 30 seconds for such operations.
Introduce a structure to pass both clients where needed.
This yielded all successful runs for many hours on GHA CI and 4 passes on the notoriously flaky OpenShift CI.
Also:
warn!in ak-regFixes: #227
@iroykaufman I also tested this with #248, here's the rerere cache already in case we merge this first: rerere-timed-client.tar.gz
Summary by Sourcery
Introduce a dual Kubernetes client setup with read timeouts for non-watch operations while preserving non-timed clients for watch-based controllers and tests, and update logging, controllers, tests, and CI accordingly.
New Features:
Bug Fixes:
Enhancements:
CI:
Tests: