Skip to content

Commit

Permalink
Unstable 1.25 workaround for #997 via #1008
Browse files Browse the repository at this point in the history
Signed-off-by: clux <sszynrae@gmail.com>
  • Loading branch information
clux committed Sep 21, 2022
1 parent a65c249 commit a69b20b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -146,6 +146,11 @@ jobs:
# github-token: ${{ secrets.GITHUB_TOKEN }}
k3d-args: "--no-lb --no-rollback --k3s-arg --disable=traefik,servicelb,metrics-server@server:*"

# Set a hacky workaround evar for https://github.com/kubernetes/kubernetes/issues/111985
- name: Workaround upstream Kubernetes 1.25 bug
if: matrix.k8s == 'latest'
run: echo "KUBE_UNSTABLE_V1_25_DELETE=1" >> $GITHUB_ENV

# Real CI work starts here
- name: Build workspace
run: cargo build
Expand Down
22 changes: 22 additions & 0 deletions kube-core/src/request.rs
Expand Up @@ -151,6 +151,28 @@ impl Request {

let data = if dp.is_default() {
vec![] // default serialize needs to be empty body
} else if std::env::var("KUBE_UNSTABLE_V1_25_DELETE").is_ok() {
// The kube-apiserver in Kubernetes v1.25.0 has broken deserialization of non-default delete options
// So we have to wrap our DeleteParams inside a kind/apiVersion struct to work around it.
// See https://github.com/kubernetes/kubernetes/issues/111985
// This workaround breaks on older Kubernetes versions so it has to be opt-in.

// NB: This is a hack that we plan on removing in the next kube release
// when upstream hopefully resolves the issue.
#[derive(serde::Serialize)]
#[serde(rename_all = "camelCase")]
struct KindWrapper<'a> {
api_version: &'a str,
kind: &'a str,
#[serde(flatten)]
data: serde_json::Value,
}
let kind_wrapped_dp = KindWrapper {
api_version: "meta.k8s.io/v1",
kind: "DeleteOptions",
data: serde_json::to_value(&dp).map_err(Error::SerializeBody)?,
};
serde_json::to_vec(&kind_wrapped_dp).map_err(Error::SerializeBody)?
} else {
serde_json::to_vec(&dp).map_err(Error::SerializeBody)?
};
Expand Down

0 comments on commit a69b20b

Please sign in to comment.