Skip to content

Commit

Permalink
feat(backup): update k8s/crds.yaml
Browse files Browse the repository at this point in the history
ref: longhorn/longhorn 5411

Signed-off-by: James Lu <james.lu@suse.com>
  • Loading branch information
mantissahz committed Oct 29, 2024
1 parent 5ce0cad commit d1bc090
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
26 changes: 17 additions & 9 deletions k8s/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,9 @@ spec:
ownerID:
type: string
realSize:
description: Real size of image in bytes, which may be smaller than the size
when the file is a sparse file. Will be zero until known (e.g. while a backing image is uploading)
description: Real size of image in bytes, which may be smaller than
the size when the file is a sparse file. Will be zero until known
(e.g. while a backing image is uploading)
format: int64
type: integer
size:
Expand All @@ -574,8 +575,9 @@ spec:
uuid:
type: string
virtualSize:
description: Virtual size of image in bytes, which may be larger than physical
size. Will be zero until known (e.g. while a backing image is uploading)
description: Virtual size of image in bytes, which may be larger than
physical size. Will be zero until known (e.g. while a backing image
is uploading)
format: int64
type: integer
type: object
Expand Down Expand Up @@ -653,8 +655,9 @@ spec:
backing image backup
properties:
backingImage:
description: The backing image name..
nullable: true
description: |-
The backing image name.
Required
type: string
backupTargetName:
description: The backup target name.
Expand All @@ -677,6 +680,7 @@ spec:
Required
type: boolean
required:
- backingImage
- userCreated
type: object
status:
Expand Down Expand Up @@ -732,7 +736,8 @@ spec:
description: Record the secret if this backup backing image is encrypted
type: string
secretNamespace:
description: Record the secret namespace if this backup backing image is encrypted
description: Record the secret namespace if this backup backing image
is encrypted
type: string
size:
description: The backing image size.
Expand Down Expand Up @@ -878,6 +883,7 @@ spec:
- full
- incremental
- ""
type: string
backupTargetName:
description: The backup target name.
nullable: true
Expand Down Expand Up @@ -1120,7 +1126,8 @@ spec:
the backup target.
type: string
readOnly:
description: ReadOnly indicates if it can create a backup on the remote backup target or not.
description: ReadOnly indicates if it can create a backup on the remote
backup target or not.
type: boolean
syncRequestedAt:
description: The time to request run sync the remote backup target.
Expand Down Expand Up @@ -4214,7 +4221,8 @@ spec:
- gzip
type: string
backupTargetName:
description: 'The backup target name that the volume will be backed up to or is synced.'
description: The backup target name that the volume will be backed
up to or is synced.
type: string
dataEngine:
enum:
Expand Down
9 changes: 4 additions & 5 deletions webhook/resources/backup/mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ func (b *backupMutator) Create(request *admission.Request, newObj runtime.Object
}

if backup.Spec.BackupTargetName == "" {
backupTargetName := types.DefaultBackupTargetName
if volume, err := b.ds.GetVolumeRO(volumeName); err == nil {
backupTargetName = volume.Spec.BackupTargetName
volume, err := b.ds.GetVolumeRO(volumeName)
if err != nil {
return nil, werror.NewInvalidError(errors.Wrapf(err, "failed to get volume %v", volumeName).Error(), "")
}
backup.Spec.BackupTargetName = backupTargetName
patchOps = append(patchOps, fmt.Sprintf(`{"op": "replace", "path": "/spec/backupTargetName", "value": "%s"}`, backupTargetName))
patchOps = append(patchOps, fmt.Sprintf(`{"op": "replace", "path": "/spec/backupTargetName", "value": "%s"}`, volume.Spec.BackupTargetName))
}

labels := backup.Labels
Expand Down

0 comments on commit d1bc090

Please sign in to comment.