openshift/openshift-restclient-python

0.9.x no longer patches existing object correctly

mmazur opened this issue · 4 comments

I have an object called VirtualMachineInstanceReplicaSet/myvmir. I want to increase its spec.replicas from 1 to 2. Here's how I'd do it:

[mmazur@klapek work1]$ cat ansible_scale.yml
---
- name: Comprehensive kubevirt_vm testing
  hosts: localhost
  connection: local
  tasks:
  - name: scale
    k8s:
      inline:
        apiVersion: kubevirt.io/v1alpha3
        kind: VirtualMachineInstanceReplicaSet
        metadata:
          name: myvmir
          namespace: default
        spec:
          replicas: 2

Running ansible-playbook on this with openshift-0.8.9 kubernetes-8.0.2 urllib3-1.24.3, everything works as expected and I get "changed": true, (…), "method": "patch" in the result.

But then I upgrade to kubernetes-9.0.1 openshift-0.9.2 and running the same gets me an apply instead of a patch and an assorted webhook validation error:

(…)
    "msg": "Failed to apply object: b'{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"admission webhook \\\\\"virtualmachinereplicaset-validator.kubevirt.io\\\\\" denied the request: spec.selector in body is required, spec.template in body is required\",\"reason\":\"Invalid\",\"details\":{\"causes\":[{\"message\":\"spec.selector in body is required\"},{\"message\":\"spec.template in body is required\"}]},\"code\":422}\\n'",
    "reason": "Unprocessable Entity",
    "status": 422

Granted, this might be an overreaction on the admission webhook's part and this should work the same both for apply and patch, not sure. In any event, any chance I can force 0.9.x to try to patch instead of apply?

Right, so after some further reading it seems to me like this constitutes a major change in ansible behavior if I'm getting an apply instead of a patch.

I've raised ansible/ansible#62632 to turn off defaulting to apply. But I'd still like to see why apply is failing in your case.

Yup, moving the discussion to ansible (ansible/ansible#62661) and closing this.