-
Notifications
You must be signed in to change notification settings - Fork 10
Use a read-timeout client for non-watch operations #324
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
Closed
Jakob-Naucke
wants to merge
7
commits into
trusted-execution-clusters:main
from
Jakob-Naucke:timed-client
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d063668
operator/ak-reg: Use warn!, not eprintln!
Jakob-Naucke 2301527
operator/ak-reg: Fix a log message
Jakob-Naucke c175d35
Add timestamps to logging
Jakob-Naucke 935cca4
gha: run & upload must-gather
Jakob-Naucke f7fef12
rvs: Reconcile images on jobs too
Jakob-Naucke 7ed1df5
Use a read-timeout client for non-watch operations
Jakob-Naucke 1ec63fe
operator/reg: Pass error if cleanup fails
Jakob-Naucke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,31 @@ use anyhow::{Context, Result, anyhow}; | |
| use conditions::*; | ||
| use k8s_openapi::apimachinery::pkg::apis::meta::v1::{Condition, OwnerReference, Time}; | ||
| use kube::{Api, Client, Resource}; | ||
| use std::time::Duration; | ||
|
|
||
| /// Read timeout for non-watch Kubernetes API calls. | ||
| pub const KUBE_READ_TIMEOUT: Duration = Duration::from_secs(30); | ||
|
|
||
| /// Create a [`Client`] with [`KUBE_READ_TIMEOUT`] applied. | ||
| /// | ||
| /// Use this for request/response API calls. For long-lived watch streams, use | ||
| /// [`Client::try_default`] instead so the connection never times out on idle. | ||
| pub async fn timed_client() -> Result<Client> { | ||
| let mut config = kube::Config::infer().await?; | ||
| config.read_timeout = Some(KUBE_READ_TIMEOUT); | ||
| Ok(Client::try_from(config)?) | ||
| } | ||
|
|
||
| /// A pair of Kubernetes clients | ||
| /// | ||
| /// `client` has a read timeout for request/response API calls. | ||
| /// `watch` has no read timeout, keeping it safe for long-lived watch streams | ||
| /// (Controllers, Reflectors, `await_condition`). | ||
|
Comment on lines
+48
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please document when one should use one or the other, it isn't very clear from the comment |
||
| #[derive(Clone)] | ||
| pub struct KubeClients { | ||
| pub request_client: Client, | ||
| pub watch_client: Client, | ||
| } | ||
|
|
||
| #[macro_export] | ||
| macro_rules! update_status { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.