Skip to content

Commit

Permalink
chore: volumeSnapshotTemplate -> volumeSnapshot
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Nenciarini <[email protected]>
  • Loading branch information
mnencia committed Aug 23, 2023
1 parent 351b597 commit 636a70e
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 91 deletions.
3 changes: 1 addition & 2 deletions .wordlist-en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ BackupConfiguration
BackupList
BackupMethod
BackupPhase
BackupSnapshotConfig
BackupSnapshotStatus
BackupSource
BackupSpec
Expand Down Expand Up @@ -370,6 +369,7 @@ Valerio
VirtualBox
VolumeSnapshot
VolumeSnapshotClass
VolumeSnapshotConfiguration
WAL
WAL's
WALBackupConfiguration
Expand Down Expand Up @@ -990,7 +990,6 @@ virtualxid
volumeMode
volumeMounts
volumeSnapshot
volumeSnapshotTemplate
volumesnapshot
wal
walSegmentSize
Expand Down
10 changes: 5 additions & 5 deletions api/v1/backup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ const (
type BackupMethod string

const (
// BackupMethodVolumeSnapshotTemplate means using the volume snapshot
// BackupMethodVolumeSnapshot means using the volume snapshot
// Kubernetes feature
BackupMethodVolumeSnapshotTemplate BackupMethod = "volumeSnapshotTemplate"
BackupMethodVolumeSnapshot BackupMethod = "volumeSnapshot"

// BackupMethodBarmanObjectStore means using barman to backup the
// PostgreSQL cluster
Expand All @@ -74,13 +74,13 @@ type BackupSpec struct {
Target BackupTarget `json:"target,omitempty"`

// The backup method to be used, possible options are `barmanObjectStore`
// and `volumeSnapshotTemplate`. Defaults to: `barmanObjectStore`.
// +kubebuilder:validation:Enum=barmanObjectStore;volumeSnapshotTemplate
// and `volumeSnapshot`. Defaults to: `barmanObjectStore`.
// +kubebuilder:validation:Enum=barmanObjectStore;volumeSnapshot
// +kubebuilder:default:=barmanObjectStore
Method BackupMethod `json:"method,omitempty"`
}

// BackupSnapshotStatus the fields exclusive to the volumeSnapshotTemplate method backup
// BackupSnapshotStatus the fields exclusive to the volumeSnapshot method backup
type BackupSnapshotStatus struct {
// The snapshot lists, populated if it is a snapshot type backup
Snapshots []string `json:"snapshots,omitempty"`
Expand Down
10 changes: 5 additions & 5 deletions api/v1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ const (
SnapshotOwnerReferenceCluster SnapshotOwnerReference = "cluster"
)

// BackupSnapshotConfig represents the configuration for the execution of snapshot backups.
type BackupSnapshotConfig struct {
// VolumeSnapshotConfiguration represents the configuration for the execution of snapshot backups.
type VolumeSnapshotConfiguration struct {
// Labels are key-value pairs that will be added to .metadata.labels snapshot resources.
Labels map[string]string `json:"labels,omitempty"`
// Annotations key-value pairs that will be added to .metadata.annotations snapshot resources.
Expand Down Expand Up @@ -1531,12 +1531,12 @@ type BarmanObjectStoreConfiguration struct {
}

// BackupConfiguration defines how the backup of the cluster are taken.
// The supported backup methods are BarmanObjectStore and VolumeSnapshotTemplate.
// The supported backup methods are BarmanObjectStore and VolumeSnapshot.
// For details and examples refer to the Backup and Recovery section of the
// documentation
type BackupConfiguration struct {
// VolumeSnapshotTemplate provides the configuration for the execution of volume snapshot backups.
VolumeSnapshotTemplate *BackupSnapshotConfig `json:"volumeSnapshotTemplate,omitempty"`
// VolumeSnapshot provides the configuration for the execution of volume snapshot backups.
VolumeSnapshot *VolumeSnapshotConfiguration `json:"volumeSnapshot,omitempty"`

// The configuration for the barman-cloud tool suite
BarmanObjectStore *BarmanObjectStoreConfiguration `json:"barmanObjectStore,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions api/v1/scheduledbackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ type ScheduledBackupSpec struct {
Target BackupTarget `json:"target,omitempty"`

// The backup method to be used, possible options are `barmanObjectStore`
// and `volumeSnapshotTemplate`. Defaults to: `barmanObjectStore`.
// +kubebuilder:validation:Enum=barmanObjectStore;volumeSnapshotTemplate
// and `volumeSnapshot`. Defaults to: `barmanObjectStore`.
// +kubebuilder:validation:Enum=barmanObjectStore;volumeSnapshot
// +kubebuilder:default:=barmanObjectStore
Method BackupMethod `json:"method,omitempty"`
}
Expand Down
64 changes: 32 additions & 32 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions config/crd/bases/postgresql.cnpg.io_backups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ spec:
method:
default: barmanObjectStore
description: 'The backup method to be used, possible options are `barmanObjectStore`
and `volumeSnapshotTemplate`. Defaults to: `barmanObjectStore`.'
and `volumeSnapshot`. Defaults to: `barmanObjectStore`.'
enum:
- barmanObjectStore
- volumeSnapshotTemplate
- volumeSnapshot
type: string
target:
description: The policy to decide which instance should perform this
Expand Down
6 changes: 3 additions & 3 deletions config/crd/bases/postgresql.cnpg.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1242,9 +1242,9 @@ spec:
- primary
- prefer-standby
type: string
volumeSnapshotTemplate:
description: VolumeSnapshotTemplate provides the configuration
for the execution of volume snapshot backups.
volumeSnapshot:
description: VolumeSnapshot provides the configuration for the
execution of volume snapshot backups.
properties:
annotations:
additionalProperties:
Expand Down
4 changes: 2 additions & 2 deletions config/crd/bases/postgresql.cnpg.io_scheduledbackups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ spec:
method:
default: barmanObjectStore
description: 'The backup method to be used, possible options are `barmanObjectStore`
and `volumeSnapshotTemplate`. Defaults to: `barmanObjectStore`.'
and `volumeSnapshot`. Defaults to: `barmanObjectStore`.'
enum:
- barmanObjectStore
- volumeSnapshotTemplate
- volumeSnapshot
type: string
schedule:
description: The schedule does not follow the same format used in
Expand Down
10 changes: 5 additions & 5 deletions controllers/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ func (r *BackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
tryFlagBackupAsFailed(ctx, r.Client, &backup, fmt.Errorf("encountered an error while taking the backup: %w", err))
return ctrl.Result{}, nil
}
case apiv1.BackupMethodVolumeSnapshotTemplate:
if cluster.Spec.Backup.VolumeSnapshotTemplate == nil {
case apiv1.BackupMethodVolumeSnapshot:
if cluster.Spec.Backup.VolumeSnapshot == nil {
tryFlagBackupAsFailed(ctx, r.Client, &backup,
errors.New("no volumeSnapshotTemplate section defined on the target cluster"))
errors.New("no volumeSnapshot section defined on the target cluster"))
return ctrl.Result{}, nil
}
if err := startSnapshotBackup(ctx, r.Client, pod, &cluster, &backup); err != nil {
Expand All @@ -239,7 +239,7 @@ func startSnapshotBackup(
) error {
contextLogger := log.FromContext(ctx)

backup.Status.SetAsStarted(targetPod, apiv1.BackupMethodVolumeSnapshotTemplate)
backup.Status.SetAsStarted(targetPod, apiv1.BackupMethodVolumeSnapshot)
if err := postgres.PatchBackupStatusAndRetry(ctx, cli, backup); err != nil {
return err
}
Expand All @@ -253,7 +253,7 @@ func startSnapshotBackup(
return fmt.Errorf("cannot get PVCs: %w", err)
}

snapshotConfig := *cluster.Spec.Backup.VolumeSnapshotTemplate
snapshotConfig := *cluster.Spec.Backup.VolumeSnapshot

snapshotEnrich := func(vs *storagesnapshotv1.VolumeSnapshot) {
switch snapshotConfig.SnapshotOwnerReference {
Expand Down
Loading

0 comments on commit 636a70e

Please sign in to comment.