Skip to content

UpdateStatus() for custom resources not working #54672

@diptadas

Description

@diptadas

/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/custom-resourceskind/bugCategorizes issue or PR as related to a bug.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions