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

PatchParams dry-run doesn't seems to work #511

Closed
shigedangao opened this issue May 5, 2021 · 4 comments · Fixed by #512
Closed

PatchParams dry-run doesn't seems to work #511

shigedangao opened this issue May 5, 2021 · 4 comments · Fixed by #512
Labels
api Api abstraction related bug Something isn't working

Comments

@shigedangao
Copy link

Hello,

First of all I want to thank you all for this wonderful library. I'm pretty new in Rust and I'm currently trying to use the PatchParams in order to use the dry-run feature. I'm currently following this example Example. However I'm encountering an error which you can find below

PatchOptions.meta.k8s.io "" is invalid: dryRun: Unsupported value: []string{"true"}: supported values: "All": Invalid (ErrorResponse { status: "Failure", message: "PatchOptions.meta.k8s.io \"\" is invalid: dryRun: Unsupported value: []string{\"true\"}: supported values: \"All\"", reason: "Invalid", code: 422 })

Below is the code I'm using for my experiment

let patch: Value = serde_json::from_str(&output).unwrap();

let params = PatchParams::apply("kubectl").dry_run();
let patch = Patch::Apply(&patch);

let client = Client::try_default()
    .await
    .map_err(|err| KubeError { message: err.to_string() })?;

let dep: Api<Deployment> = Api::namespaced(client, "default"); 
let res = dep.patch("rusty", &params, &patch)
     .await
     .map_err(|err| KubeError { message: err.to_string() })?;

The error seems to indicate that the dryRun is sending the value true instead of All. However I don't really know if it's tight to a kubernetes version or not. What do you think ? (My tests are done on k3d, and GKE v1.17.17-gke.3700)

Analysis of the issue & trying to resolve the issue

From what I could found, it seems that the dryRun value is set to true by the populate_qp method (located in the kube/src/api/params.rs). Locally I edited the library and changed the value from true to All and seems to work.

@clux
Copy link
Member

clux commented May 5, 2021

Oh, that's almost certainly an oversight. We have the correct serialization to do this in DeleteParams already (in params.rs), but it's not ported to PatchParams. Thanks for the report, this should be an easy fix!

@clux clux added api Api abstraction related bug Something isn't working labels May 5, 2021
@clux
Copy link
Member

clux commented May 5, 2021

Pr in #512, untested but think it should work. Will verify tomorrow.

@shigedangao
Copy link
Author

@clux seems good to me ! 💯

@clux clux closed this as completed in #512 May 6, 2021
clux added a commit that referenced this issue May 6, 2021
patchparams should use correct ser for dry-run bool - fixes #511
@clux
Copy link
Member

clux commented May 15, 2021

Released in 0.53.0. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Api abstraction related bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants