vmware-tanzu / velero

Backup and migrate Kubernetes applications and their persistent volumes
https://velero.io
Apache License 2.0
8.78k stars 1.41k forks source link

Velero CRDs do not have `subresources.status` #8285

Closed mateusoliveira43 closed 1 month ago

mateusoliveira43 commented 1 month ago

What steps did you take and what happened:

When writing code around Velero CRDs I noticed that I can not use controller-runtime StatusClient with them. I get the following error:

k8sClient.Status().Update(ctx, veleroBackup)
// backups.velero.io "name..." not found error

What did you expect to happen:

Developers are able to use controller-runtime StatusClient with Velero CRDs.

Anything else you would like to add:

Issue about similar problem that Velero itself is facing https://github.com/vmware-tanzu/velero/issues/6016

To fix the problem, just need to add the comment +kubebuilder:subresource:status in CRD generation code. Documentation reference: https://book.kubebuilder.io/reference/generating-crd#status

🚨 This change, without other changes, may break Velero, as with it, it does not allow Spec and Status change together. But since it is a anti-pattern, it should be avoided.

Vote on this issue!

This is an invitation to the Velero community to vote on issues, you can see the project's top voted issues listed here.
Use the "reaction smiley face" up to the right of this comment to vote.

ywk253100 commented 1 month ago

This is by design. Because the backup sync controller syncs the backup CRs (both the backup spec and status) from the backup store to the cluster, this is easier to create the CRs (both the spec and status) in one call without enabling the subresource.

kaovilai commented 1 month ago

See also: https://github.com/vmware-tanzu/velero/pull/4972