vmware-tanzu / velero

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

failed to restore resource status with a crd which has no subresource status #7993

Open nfyxhan opened 1 month ago

nfyxhan commented 1 month ago

What steps did you take and what happened:

defined a custom resource named Foo with no subresource


---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    controller-gen.kubebuilder.io/version: v0.4.1
  creationTimestamp: null
  name: foo.sample.com
spec:
  group: sample.com
  names:
    kind: Foo
    listKind: FooList
    plural: foos
    singular: foo
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - jsonPath: .spec.sample
      name: sample
      type: string
    - jsonPath: .status.phase
      name: phase
      type: string
    - jsonPath: .metadata.creationTimestamp
      name: age
      type: date
    name: v1
    schema:
      openAPIV3Schema:
        description: Foo is the Schema for the foos API
        properties:
          apiVersion:
            description: 'APIVersion defines the versioned schema of this representation
              of an object. Servers should convert recognized schemas to the latest
              internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
            type: string
          kind:
            description: 'Kind is a string value representing the REST resource this
              object represents. Servers may infer this from the endpoint the client
              submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
            type: string
          metadata:
            type: object
          spec:
            description: FooSpec defines the desired state of Foo
            properties:
              sample:
                type: string
            type: object
          status:
            description: FooFStatus defines the observed state of Foo
            properties:
              phase:
                type: string
            required:
            - health
            type: object
        type: object
    served: true
    storage: true
    subresources: {}
status:
  acceptedNames:
    kind: ""
    plural: ""
  conditions: []
  storedVersions: []

What did you expect to happen:

restore Foo with status

Environment:

Client: Version: v1.13.2 Git commit: 4d961fb6fec384ed7f3c1b7c65c818106107f5a6-dirty Server: Version: v1.13.2

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.

Lyndon-Li commented 1 month ago

dup with #6016

blackpiglet commented 1 month ago

I haven't figured out how to reset or delete the status section of the CR yet, but, IMO, even the CR without a status subresource can also status field. The status is treated as part of the resource spec, so it's also possible to delete that status part from CR. It's better that we can find a way not just to ignore the resource when it doesn't have a status subresource.