Kubernetes: UpdateStatus() for custom resources not working

Created on 27 Oct 2017  ·  1Comment  ·  Source: kubernetes/kubernetes

/kind bug
/sig api-machinery
@kubernetes/sig-api-machinery-bugs

What happened:
My custom resource type has a status field. I have generated client for it using genclient.
Here is the defination of my CRD type:

// +genclient
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Recovery struct {
    metav1.TypeMeta   `json:",inline,omitempty"`
    metav1.ObjectMeta `json:"metadata,omitempty"`
    Spec              RecoverySpec   `json:"spec,omitempty"`
    Status            RecoveryStatus `json:"status,omitempty"`
}

The generated UpdateStatus() function:

// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().

func (c *recoveries) UpdateStatus(recovery *v1alpha1.Recovery) (result *v1alpha1.Recovery, err error) {
    result = &v1alpha1.Recovery{}
    err = c.client.Put().
        Namespace(c.ns).
        Resource("recoveries").
        Name(recovery.Name).
        SubResource("status").
        Body(recovery).
        Do().
        Into(result)
    return
}

Now when I call UpdateStatus() for a Recovery object (stash-mduabx) it gives following error:

the server could not find the requested resource (put recoveries.stash.appscode.com stash-mduabx)

And the log of api call:

PUT https://192.168.99.100:8443/apis/stash.appscode.com/v1alpha1/namespaces/test-stash/recoveries/stash-mduabx/status 404 Not Found in 11 milliseconds

What you expected to happen:
It should update the status field.

How to reproduce it:
Define a CRD type with status field and generate client for it using genclient. Create a object of that type using kubectl. Now get the object from go program and call UpdateStatus() for the object.

Environment:

  • Kubernetes version: 1.7.5
arecustom-resources kinbug siapi-machinery

Most helpful comment

The client generates a status method because there is a status field, but that does not mean the server has support for that method.

https://github.com/kubernetes/community/pull/913 is a proposal to add server support for status subresources for CRD objects.

>All comments

The client generates a status method because there is a status field, but that does not mean the server has support for that method.

https://github.com/kubernetes/community/pull/913 is a proposal to add server support for status subresources for CRD objects.

Was this page helpful?
0 / 5 - 0 ratings