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

Document potential silent failure when patching resources #1262

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jmintb
Copy link
Contributor

@jmintb jmintb commented Jul 22, 2023

Based on experiments performed in #1153 it appears to be possible to submit an invalid patch and not receive an error.
This PR documents this behavior and also serves to discuss and verify what is happening. The relevant thread starts here.

Example taking form the updated docs:

use k8s_openapi::api::core::v1::{Pod, PodSpec};
use kube::{Api, api::{PatchParams, Patch}};

  async fn wrapper() -> Result<(), Box<dyn std::error::Error>> {
  let client = kube::Client::try_default().await?;
 let pods: Api<Pod> = Api::namespaced(client, "apps");
 let pp = PatchParams::default();

 let invalid_patch: PodSpec = serde_json::from_value(serde_json::json!({
                 "activeDeadlineSeconds": 5
 }))?;

 // This will have no effect on mypod.
 pods.patch("mypod", &pp, &Patch::Strategic(invalid_patch)).await?;

 let valid_patch: Pod = serde_json::from_value(serde_json::json!({
           "spec": {
                 "activeDeadlineSeconds": 5
            }
 }))?;

 // This will set activeDeadlineSeconds to 5.
 pods.patch("mypod", &pp, &Patch::Strategic(valid_patch)).await?;

  Ok(())
 }

@jmintb
Copy link
Contributor Author

jmintb commented Jul 22, 2023

I am not sure why examples/dynamic_watcher.rs is marked as changed here.

@jmintb
Copy link
Contributor Author

jmintb commented Jul 22, 2023

I am not sure why examples/dynamic_watcher.rs is marked as changed here.

A local git diff seems to disagree 🤔

image

@jmintb
Copy link
Contributor Author

jmintb commented Jul 22, 2023

Okay I clearly messed something up, will fix the commits.

@codecov
Copy link

codecov bot commented Jul 22, 2023

Codecov Report

Merging #1262 (b9ca591) into main (a9f1a4f) will increase coverage by 0.01%.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1262      +/-   ##
==========================================
+ Coverage   73.28%   73.30%   +0.01%     
==========================================
  Files          75       75              
  Lines        6057     6057              
==========================================
+ Hits         4439     4440       +1     
+ Misses       1618     1617       -1     
Impacted Files Coverage Δ
kube-core/src/params.rs 81.68% <ø> (ø)

... and 1 file with indirect coverage changes

Signed-off-by: Jessie Chatham Spencer <jessie@teainspace.com>
@jmintb jmintb changed the title Document potential silent failure when patching sub resources Document potential silent failure when patching resources Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant