types

package
v0.0.0-...-2d35685 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package types contains shared types used across OADP VM File Restore CRDs.

This package provides reusable API types for VirtualMachineBackupsDiscovery and VirtualMachineFileRestore resources, ensuring consistency in backup discovery and file restoration workflows.

Shared Types

Condition Constants (conditions.go):

  • ConditionTypeProgressing, ConditionTypeAvailable, ConditionTypeDegraded, ConditionTypeReady
  • Standard Kubernetes conditions used by both CRDs
  • Follow Kubernetes API conventions for status representation

Backup Discovery (backup_discovery.go):

  • VeleroBackupInfo: Metadata about discovered Velero backups
  • InvalidBackupInfo: Information about backups that don't contain the VM
  • BackupDiscoveryStatus: Status enum for backup discovery progress
  • BackupDiscoveryProgress: Detailed per-backup discovery tracking

PVC Information (pvc.go):

  • PVCInfo: PVC metadata from backups (UID, name, namespace, size)
  • Used to track persistent volume claims across backup discovery and restoration

Time Handling (time.go):

  • FlexibleTime: Custom time type supporting both RFC3339 and date-only formats
  • Enables user-friendly time range filtering in backup discovery

Versioning

All types in this package are versioned as part of the v1alpha1 API. When creating new API versions (v1beta1, v1), these types may be:

  • Reused across versions if the schema remains unchanged
  • Copied and modified in the new version's types package
  • Converted between versions using conversion functions

Design Principles

Types in this package follow these design principles:

  • DRY (Don't Repeat Yourself): Shared types are defined once and reused
  • Velero Alignment: Status enums and patterns match Velero's phase model
  • Kubernetes Conventions: Follows standard K8s API patterns and condition types
  • API Compatibility: All types are designed for JSON serialization in CRD schemas

For more information about the overall status lifecycle and phase/condition relationships, see docs/design/crd_status_lifecycle.md in the project root.

Index

Constants

View Source
const (
	// ConditionTypeProgressing indicates whether an operation is actively running.
	// Status=True: Operation is in progress (Phase: InProgress)
	// Status=False: Operation is not running (Phase: New, Completed, PartiallyFailed, Failed, Deleting)
	//
	// Common reasons for VirtualMachineBackupsDiscovery:
	//   - "DiscoveryStarted", "ScanningBackups", "DiscoveryCompleted", "DiscoveryFailed"
	//
	// Common reasons for VirtualMachineFileRestore:
	//   - "Validating", "CreatingRestores", "WaitingForRestores", "SettingUpFileServing",
	//     "RestoreCompleted", "ValidationFailed"
	ConditionTypeProgressing = "Progressing"

	// ConditionTypeAvailable indicates whether a resource has usable data/functionality.
	// Status=True: Resource is usable (Phase: Completed or PartiallyFailed)
	// Status=False: Resource is not usable (Phase: New, InProgress, Failed, Deleting)
	//
	// For VirtualMachineBackupsDiscovery:
	//   - Available=True means "at least one valid backup was found"
	//   - Available=False means "no valid backups found yet" or "discovery failed"
	//
	// For VirtualMachineFileRestore:
	//   - Available=True means "files are accessible via file serving resources"
	//   - Available=False means "files not yet available" or "all restores failed"
	//
	// Common reasons:
	//   - "ValidBackupsFound", "FileServingReady" (when True)
	//   - "InProgress", "WaitingForRestores", "Failed", "NoValidBackupsFound" (when False)
	//
	// KEY DISTINCTION:
	//   - PartiallyFailed phase → Available=True (some data is usable)
	//   - Failed phase → Available=False (nothing usable)
	ConditionTypeAvailable = "Available"

	// ConditionTypeDegraded indicates partial failures or suboptimal conditions occurred.
	// Status=True: Some operations failed (Phase: PartiallyFailed or Failed)
	// Status=False: All operations succeeded (Phase: Completed)
	//
	// IMPORTANT: Degraded=True does NOT always mean unusable!
	//
	// When Available=True AND Degraded=True (Phase: PartiallyFailed):
	//   - Resource is FUNCTIONAL and USABLE
	//   - Some operations failed, but others succeeded
	//   - Users should investigate but can still use the resource
	//
	// Example scenarios:
	//   - VirtualMachineBackupsDiscovery: Found 3 valid backups, but 2 failed to scan
	//   - VirtualMachineFileRestore: 2 of 3 Velero Restores succeeded
	//
	// Common reasons:
	//   - "PartialFailure", "SomeBackupsInvalid", "SomeRestoresFailed" (when True)
	//   - "AllOperationsSucceeded", "NoFailures", "AllBackupsValid", "AllRestoresSucceeded" (when False)
	ConditionTypeDegraded = "Degraded"

	// ConditionTypeReady is a summary condition indicating overall usability.
	// Status=True: Resource is usable for its purpose (Phase: Completed or PartiallyFailed)
	// Status=False: Resource is not usable yet or failed (Phase: New, InProgress, Failed, Deleting)
	//
	// Calculation: Ready = Available (True if resource has usable data)
	//
	// This means:
	//   - Ready=True for Phase Completed (perfect, no issues)
	//   - Ready=True for Phase PartiallyFailed (degraded but usable)
	//   - Ready=False for Phase Failed (not usable)
	//
	// Common reasons:
	//   - "DiscoveryComplete", "RestoreComplete" (when True)
	//   - "InProgress", "Failed", "Deleting" (when False)
	//
	// Use Case: Simple readiness check for automation
	ConditionTypeReady = "Ready"
)

Standard Kubernetes condition types used across OADP VM File Restore CRDs. These follow Kubernetes API conventions and are the primary source of truth for resource state. Both VirtualMachineBackupsDiscovery and VirtualMachineFileRestore use these identical condition types.

View Source
const (
	// Shared Progressing reasons
	ReasonInProgress = "InProgress"
	ReasonFailed     = "Failed"

	// Shared Available reasons
	ReasonNotStarted = "NotStarted"

	// Shared Degraded reasons
	ReasonNoFailures      = "NoFailures"
	ReasonCriticalFailure = "CriticalFailure"
	ReasonPartialFailure  = "PartialFailure"

	// Shared Ready reasons
	ReasonNotReady        = "NotReady"
	ReasonCompleted       = "Completed"
	ReasonPartiallyFailed = "PartiallyFailed"
)

Common condition reasons used across both VirtualMachineBackupsDiscovery and VirtualMachineFileRestore

View Source
const (
	// Progressing condition reasons
	ReasonInitialized                   = "Initialized"
	ReasonValidating                    = "Validating"
	ReasonValidationCompleted           = "ValidationCompleted"
	ReasonValidationFailed              = "ValidationFailed"
	ReasonPartialValidationFailed       = "PartialValidationFailed"
	ReasonDiscoveringPVCs               = "DiscoveringPVCs"
	ReasonWaitingForDiscovery           = "WaitingForDiscovery"
	ReasonNamespaceReady                = "NamespaceReady"
	ReasonWaitingForRestores            = "WaitingForRestores"
	ReasonRestoresCompleted             = "RestoresCompleted"
	ReasonCredentialsReady              = "CredentialsReady"
	ReasonWaitingForRoute               = "WaitingForRoute"
	ReasonRestoresCompletedWithFailures = "RestoresCompletedWithFailures"
	ReasonRestoresFailed                = "RestoresFailed"
	ReasonFileServerCreated             = "FileServerCreated"

	// Available condition reasons
	ReasonDiscoveryInProgress   = "DiscoveryInProgress"
	ReasonPreparingRestores     = "PreparingRestores"
	ReasonRestoresInProgress    = "RestoresInProgress"
	ReasonFileServerPending     = "FileServerPending"
	ReasonFileServerAvailable   = "FileServerAvailable"
	ReasonPartialRestoreSuccess = "PartialRestoreSuccess"
	ReasonAllRestoresFailed     = "AllRestoresFailed"

	// Degraded condition reasons
	ReasonSomeRestoresFailed = "SomeRestoresFailed"
)

VirtualMachineFileRestore specific condition reasons

Variables

This section is empty.

Functions

This section is empty.

Types

type BackupDiscoveryProgress

type BackupDiscoveryProgress struct {
	VeleroBackupInfo `json:",inline"`
	// Current status of backup discovery for this backup.
	Status BackupDiscoveryStatus `json:"status"`
	// Human-readable message about the discovery status.
	// +kubebuilder:validation:MaxLength=1024
	Message string `json:"message,omitempty"`
	// When this backup's discovery status was last updated.
	LastUpdated *metav1.Time `json:"lastUpdated,omitempty"`
}

BackupDiscoveryProgress contains detailed information about backup discovery progress +k8s:deepcopy-gen=true

func (*BackupDiscoveryProgress) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupDiscoveryProgress.

func (*BackupDiscoveryProgress) DeepCopyInto

func (in *BackupDiscoveryProgress) DeepCopyInto(out *BackupDiscoveryProgress)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type BackupDiscoveryState

type BackupDiscoveryState string

BackupDiscoveryState provides a more granular state tracking for backup-level file restore and extraction outcomes. +k8s:deepcopy-gen=true

const (
	BackupDiscoveryStateAvailable         BackupDiscoveryState = "available"
	BackupDiscoveryStateBackupDeleted     BackupDiscoveryState = "backup-deleted"
	BackupDiscoveryStateBackupMissing     BackupDiscoveryState = "backup-missing"
	BackupDiscoveryStateUnsupportedPlugin BackupDiscoveryState = "unsupported-plugin"
	BackupDiscoveryStateExtractionFailed  BackupDiscoveryState = "extraction-failed"
)

type BackupDiscoveryStatus

type BackupDiscoveryStatus string

BackupDiscoveryStatus represents the status of backup discovery for a specific backup. These statuses match Velero's phase model for consistency. +k8s:deepcopy-gen=true +kubebuilder:validation:Enum=New;InProgress;Completed;Skipped;Failed

const (
	// BackupDiscoveryStatusNew indicates the backup discovery has not started yet
	BackupDiscoveryStatusNew BackupDiscoveryStatus = "New"

	// BackupDiscoveryStatusInProgress indicates the backup is currently being analyzed
	BackupDiscoveryStatusInProgress BackupDiscoveryStatus = "InProgress"

	// BackupDiscoveryStatusCompleted indicates the backup analysis is complete and VM was found
	BackupDiscoveryStatusCompleted BackupDiscoveryStatus = "Completed"

	// BackupDiscoveryStatusSkipped indicates the backup was skipped (e.g., doesn't contain the VM)
	BackupDiscoveryStatusSkipped BackupDiscoveryStatus = "Skipped"

	// BackupDiscoveryStatusFailed indicates the backup analysis failed
	BackupDiscoveryStatusFailed BackupDiscoveryStatus = "Failed"
)

type FlexibleTime

type FlexibleTime string

FlexibleTime supports both date-only (YYYY-MM-DD) and full RFC3339 (YYYY-MM-DDTHH:MM:SSZ) formats +kubebuilder:validation:Type=string

func (FlexibleTime) GetEndOfDay

func (ft FlexibleTime) GetEndOfDay() (FlexibleTime, error)

GetEndOfDay returns a FlexibleTime set to the end of the day (23:59:59.999999999Z) for the same date as the receiver

func (FlexibleTime) Time

func (ft FlexibleTime) Time() (time.Time, error)

Time returns the parsed time.Time value

type InvalidBackupInfo

type InvalidBackupInfo struct {
	VeleroBackupInfo `json:",inline"`

	// Reason why this backup doesn't contain the VM or couldn't be processed.
	// +kubebuilder:validation:MaxLength=1024
	Reason string `json:"reason,omitempty"`
}

InvalidBackupInfo contains information about a backup that doesn't contain the VM +k8s:deepcopy-gen=true

func (*InvalidBackupInfo) DeepCopy

func (in *InvalidBackupInfo) DeepCopy() *InvalidBackupInfo

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InvalidBackupInfo.

func (*InvalidBackupInfo) DeepCopyInto

func (in *InvalidBackupInfo) DeepCopyInto(out *InvalidBackupInfo)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type PVCInfo

type PVCInfo struct {
	// UID of the PVC at the time of the backup
	PVCUID string `json:"pvcUID"`

	// Name of the PVC at the time of the backup
	PVCName string `json:"pvcName"`

	// Namespace of the PVC at the time of the backup
	PVCNamespace string `json:"pvcNamespace"`

	// Size of the PVC in human-readable format (e.g., "5Gi", "30Gi")
	// +optional
	Size string `json:"size,omitempty"`
}

PVCInfo represents a PVC from a backup and all restores associated with it. The combination of PVCUID + PVCName ensures uniqueness across multiple backups.

type VeleroBackupInfo

type VeleroBackupInfo struct {
	// Name of the backup resource.
	Name string `json:"name"`

	// Namespace is the namespace of the backup resource
	Namespace string `json:"namespace"`

	// When the backup was taken (from backup.status.completionTimestamp).
	// For synced backups, this reflects when the backup actually completed, not when it was imported.
	// +optional
	CreatedAt *metav1.Time `json:"createdAt,omitempty"`

	// PVCs contains the list of PVCs available in this backup
	// For a given VM
	// This field is populated during file restore processing
	// +optional
	PVCs []PVCInfo `json:"pvcs,omitempty"`
}

VeleroBackupInfo contains information about a discovered backup +k8s:deepcopy-gen=true

func (*VeleroBackupInfo) DeepCopy

func (in *VeleroBackupInfo) DeepCopy() *VeleroBackupInfo

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VeleroBackupInfo.

func (*VeleroBackupInfo) DeepCopyInto

func (in *VeleroBackupInfo) DeepCopyInto(out *VeleroBackupInfo)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL