types_volume - OmniCloudOrg/OmniOrchestrator GitHub Wiki
Path: src/types/volume.rs
- struct VolumeMetadata
- struct QoSConfig
- struct BurstConfig
- struct SecurityConfig
- enum KeyManagementType
- struct AccessPolicy
- enum VolumeOperation
- struct BackupPolicy
- enum ConsistencyType
- struct RetentionPolicy
- enum Volume
- struct EphemeralVolume
- struct SharedVolume
- enum PersistentVolume
- enum VolumeStatus
- enum AccessMode
- struct VolumeSnapshot
- enum VolumeError
- struct VolumeConfig
- fn create
- fn delete
- fn attach
- fn detach
- fn expand
- fn snapshot
- fn restore_from_snapshot
- fn clone
- fn transform
- fn check_integrity
- fn repair
- fn update_qos
- fn update_security
- fn update_backup_policy
pub struct VolumeMetadata {
creation_time: chrono::DateTime<chrono::Utc>,
last_modified: chrono::DateTime<chrono::Utc>,
status: VolumeStatus,
labels: HashMap<String, String>, // For organization/selection
}
Volume metadata for tracking volume details
pub struct QoSConfig {
iops_limit: Option<u32>,
throughput_limit: Option<u64>, // bytes per second
iops_guarantee: Option<u32>,
throughput_guarantee: Option<u64>,
burstable: Option<BurstConfig>,
}
QoS configuration for controlling volume performance
pub struct BurstConfig {
duration: chrono::Duration,
iops_multiplier: f32,
throughput_multiplier: f32,
}
Configuration for burstable QoS performance
pub struct SecurityConfig {
encryption_enabled: bool,
encryption_algorithm: Option<String>,
key_management: Option<KeyManagementType>,
access_policies: Vec<AccessPolicy>,
}
Security configuration for volumes
pub enum KeyManagementType {
Internal,
External { provider: String, config: HashMap<String, String> },
CustomerManaged,
HardwareSecurityModule { hsm_id: String },
}
Key management types for volume encryption
pub struct AccessPolicy {
allowed_users: Vec<String>,
allowed_groups: Vec<String>,
allowed_operations: Vec<VolumeOperation>,
}
Access policy for controlling volume operations
pub enum VolumeOperation {
Read,
Write,
Snapshot,
Delete,
Expand,
Clone,
}
Possible operations that can be performed on a volume
pub struct BackupPolicy {
schedule: String, // cron format
retention: RetentionPolicy,
consistency_type: ConsistencyType,
target_location: String,
}
Backup policy configuration
pub enum ConsistencyType {
Crash,
Filesystem,
Application { pre_backup_hook: String, post_backup_hook: String },
}
Types of consistency for backup operations
pub struct RetentionPolicy {
daily: u32,
weekly: u32,
monthly: u32,
yearly: u32,
}
Policy for retaining backups
pub enum Volume {
/// Represents a temporary volume killed when the app instance is killed
/// used for ephemeral storage within a single app instance.
///
/// In the event that multiple app instances are running on the same node,
/// each instance will have its own version of the ephemeral volume, which
/// is not shared with the other instances.
///
/// This allows for isolated storage for each app instance, ensuring that
/// data is not inadvertently shared or corrupted between instances.
/// This is useful for caching, temporary files, or any data that does not
/// need to persist beyond the lifecycle of the app instance.
Ephemeral(EphemeralVolume),
/// Represents a persistent volume that can be shared across nodes in the cluster
///
/// This volume type is used for applications that require data to persist across
/// app restarts or need to maintain state beyond the lifecycle of a single app
/// instance. It is also used for applications that require data to be shared across
/// multiple app instances running on different nodes in the cluster.
///
/// This volume type has a few different modes, each with its own characteristics:
///
/// Local Persistent Volumes are stored on worker node local disks but managed
/// in a way that preserves the data even if the container using them is removed.
/// These volumes offer excellent performance due to their local nature but are
/// tied to a specific node. If that node fails, the volume becomes unavailable
/// until the node recovers. This approach is suitable for workloads that
/// prioritize performance over availability, or in clusters where node failures
/// are rare.
///
/// Network-Attached Volumes are implemented via network storage protocols such
/// as NFS, iSCSI, or specialized storage vendor APIs. These volumes can be
/// accessed from any node in the cluster, allowing containers to be rescheduled
/// freely without losing access to their data. The tradeoff is increased latency
/// due to network communication, though modern networks and storage protocols can
/// minimize this impact. Network-attached volumes are ideal for workloads that
/// require flexibility in placement and moderate performance.
///
/// Distributed Volumes are spread across multiple physical nodes for redundancy
/// and improved availability. Technologies like Ceph, GlusterFS, or Longhorn
/// underpin these volumes, storing multiple copies of the data or using erasure
/// coding to protect against node failures. Distributed volumes offer the best
/// combination of availability and performance, though they typically require
/// more resources due to the replication overhead. They're well-suited for
/// mission-critical applications where both performance and reliability are
/// important.
Persistent(PersistentVolume),
/// Represents a network-shared volume
///
/// This volume type is used for applications that require data to be shared
/// across app instances running on different nodes in the cluster, and for applications
// ... additional implementation
}
Enum to represent the different types of volumes in OmniCloud. This enum defines the various volume types that can be used in OmniCloud, allowing for flexibility in how data is stored and accessed. The possible volume types include: - Ephemeral: A temporary volume that is killed when the app instance is killed, used for ephemeral storage within a single app instance. - Persistent: A persistent volume that can be shared across nodes in the cluster, used for applications that require data to persist across app restarts or need to maintain state beyond the lifecycle of a single app instance. - Shared: A network-shared volume that allows for data consistency and state management across app instances running on different nodes in the cluster.
Each volume type has its own characteristics and limitations, and it is important to choose the right type based on the application's requirements for data persistence, availability, and performance.
pub struct EphemeralVolume {
id: Uuid, // Unique identifier for the volume
size: u64, // Size in bytes
name: String, // Name of the volume
metadata: VolumeMetadata, // Metadata for tracking volume status and details
qos: Option<QoSConfig>, // QoS settings for performance
security: Option<SecurityConfig>, // Security settings
}
pub struct SharedVolume {
id: Uuid, // Unique identifier for the volume
size: u64, // Size in bytes
name: String, // Name of the volume
status: String, // Status of the volume (e.g., "available", "in-use")
nodes: Vec<String>, // List of nodes sharing this volume
access_mode: AccessMode, // Access mode (RWO, ROX, RWX)
metadata: VolumeMetadata, // Metadata for tracking volume status and details
qos: Option<QoSConfig>, // QoS settings for performance
security: Option<SecurityConfig>, // Security settings
backup_policy: Option<BackupPolicy>, // Backup settings
}
pub enum PersistentVolume {
Local {
id: Uuid, // Unique identifier for the volume
size: u64, // Size in bytes
name: String, // Name of the volume
status: String, // Status of the volume (e.g., "available", "in-use")
host_mount_path: String, // Path where the volume is mounted
metadata: VolumeMetadata, // Metadata for tracking volume status and details
qos: Option<QoSConfig>, // QoS settings for performance
security: Option<SecurityConfig>, // Security settings
backup_policy: Option<BackupPolicy>, // Backup settings
},
NetworkAttached {
id: Uuid, // Unique identifier for the volume
size: u64, // Size in bytes
name: String, // Name of the volume
status: String, // Status of the volume (e.g., "available", "in-use")
network_path: String, // Network path to the volume
metadata: VolumeMetadata, // Metadata for tracking volume status and details
qos: Option<QoSConfig>, // QoS settings for performance
security: Option<SecurityConfig>, // Security settings
backup_policy: Option<BackupPolicy>, // Backup settings
},
Distributed {
id: Uuid, // Unique identifier for the volume
size: u64, // Size in bytes
name: String, // Name of the volume
status: String, // Status of the volume (e.g., "available", "in-use")
nodes: Vec<String>, // List of nodes sharing this volume
metadata: VolumeMetadata, // Metadata for tracking volume status and details
qos: Option<QoSConfig>, // QoS settings for performance
security: Option<SecurityConfig>, // Security settings
backup_policy: Option<BackupPolicy>, // Backup settings
},
}
Enum to represent persistent volumes in the cluster. This enum defines the different types of persistent volumes that can be used in the cluster, allowing for flexibility in how data is stored and accessed. The possible persistent volume types include: - Local: A volume that is stored on the local node, typically used for applications that require data to persist across restarts or need to maintain state beyond the lifecycle of a single app instance. - NetworkAttached: A volume that is shared across nodes in the cluster, allowing for data consistency and state management across app instances running on different nodes. - Distributed: A volume that is distributed across multiple nodes in the cluster, providing high availability and fault tolerance for applications that require data to be available even in the event of a node failure. This enum is used in the Volume
struct to define the type of persistent volume that is being used in the cluster.
Each persistent volume type has its own characteristics and limitations, and it is important to choose the right type based on the application's requirements for data persistence, availability, and performance. Additionally, care should be taken to manage the lifecycle of persistent volumes to avoid data loss or inconsistency, especially in the event of node failures or network partitions.
pub enum VolumeStatus {
Available,
InUse {
node_id: Uuid, // ID of the node using the volume
},
Offline {
last_seen: chrono::DateTime<chrono::Utc>, // Last time the volume was seen online
},
Blocked,
Error,
}
Enum to represent the status of a volume. This enum defines the different states a volume can be in, allowing for better management and monitoring of the volume's lifecycle. The possible statuses include: - Available: The volume is ready for use and not currently in use by any node. - InUse: The volume is currently being used by a node, identified by its node ID. - Offline: The volume is not currently accessible, with a timestamp indicating the last time it was seen online. - Blocked: The volume is blocked and cannot be used, possibly due to a failure or misconfiguration. - Error: The volume is in an error state, indicating a problem with the volume or its configuration.
pub enum AccessMode {
ReadWriteOnce,
ReadOnlyMany,
ReadWriteMany,
}
Enum to represent access modes for shared volumes. This enum defines the different access modes that can be applied to shared volumes, allowing for flexibility in how volumes are accessed by different nodes. The access modes include: - ReadWriteOnce (RWO): The volume can be mounted as read-write by a single node. - ReadOnlyMany (ROX): The volume can be mounted as read-only by many nodes. - ReadWriteMany (RWX): The volume can be mounted as read-write by many nodes. This enum is used in the SharedVolume
struct to define how the volume can be accessed by different nodes in the cluster.
pub struct VolumeSnapshot {
id: Uuid,
source_volume_id: Uuid,
name: String,
creation_time: chrono::DateTime<chrono::Utc>,
size: u64,
consistency_type: ConsistencyType,
}
Snapshot of a volume at a point in time
pub enum VolumeError {
NotFound,
AlreadyExists,
InsufficientCapacity,
AccessDenied,
InvalidState,
ValidationFailed(String),
DriverFailed(String),
Timeout,
Internal(String),
}
Error type for volume operations
pub struct VolumeConfig {
name: String,
size: u64,
volume_type: String,
access_mode: Option<AccessMode>,
qos: Option<QoSConfig>,
security: Option<SecurityConfig>,
backup_policy: Option<BackupPolicy>,
labels: HashMap<String, String>,
}
Configuration for creating a new volume
pub fn create(config: VolumeConfig) -> Result<Self, VolumeError> {
// Implementation would go here
unimplemented!("Volume creation not yet implemented")
}
/// Deletes this volume
pub fn delete(&self) -> Result<(), VolumeError> {
// ... function body
}
Creates a new volume based on the provided configuration
pub fn delete(&self) -> Result<(), VolumeError> {
// Implementation would go here
unimplemented!("Volume deletion not yet implemented")
}
/// Attaches this volume to a specified node
pub fn attach(&mut self, node_id: &str) -> Result<(), VolumeError> {
// ... function body
}
Deletes this volume
pub fn attach(&mut self, node_id: &str) -> Result<(), VolumeError> {
// Implementation would go here
unimplemented!("Volume attachment not yet implemented")
}
/// Detaches this volume from its current node
pub fn detach(&mut self) -> Result<(), VolumeError> {
// ... function body
}
Attaches this volume to a specified node
pub fn detach(&mut self) -> Result<(), VolumeError> {
// Implementation would go here
unimplemented!("Volume detachment not yet implemented")
}
/// Expands this volume to a new size
pub fn expand(&mut self, new_size: u64) -> Result<(), VolumeError> {
// ... function body
}
Detaches this volume from its current node
pub fn expand(&mut self, new_size: u64) -> Result<(), VolumeError> {
// Implementation would go here
unimplemented!("Volume expansion not yet implemented")
}
/// Creates a snapshot of this volume
pub fn snapshot(&self, name: &str) -> Result<VolumeSnapshot, VolumeError> {
// ... function body
}
Expands this volume to a new size
pub fn snapshot(&self, name: &str) -> Result<VolumeSnapshot, VolumeError> {
// Implementation would go here
unimplemented!("Volume snapshot not yet implemented")
}
/// Restores this volume from a snapshot
pub fn restore_from_snapshot(&mut self, snapshot: &VolumeSnapshot) -> Result<(), VolumeError> {
// ... function body
}
Creates a snapshot of this volume
pub fn restore_from_snapshot(&mut self, snapshot: &VolumeSnapshot) -> Result<(), VolumeError> {
// Implementation would go here
unimplemented!("Volume restore not yet implemented")
}
/// Creates a clone of this volume
pub fn clone(&self, name: &str) -> Result<Self, VolumeError> {
// ... function body
}
Restores this volume from a snapshot
pub fn clone(&self, name: &str) -> Result<Self, VolumeError> {
// Implementation would go here
unimplemented!("Volume cloning not yet implemented")
}
/// Transforms this volume to a different type
pub fn transform(&self, to_type: String) -> Result<Self, VolumeError> {
// ... function body
}
Creates a clone of this volume
pub fn transform(&self, to_type: String) -> Result<Self, VolumeError> {
// Implementation would go here
unimplemented!("Volume transformation not yet implemented")
}
/// Checks the integrity of this volume
pub fn check_integrity(&self) -> Result<bool, VolumeError> {
// ... function body
}
Transforms this volume to a different type
pub fn check_integrity(&self) -> Result<bool, VolumeError> {
// Implementation would go here
unimplemented!("Volume integrity checking not yet implemented")
}
/// Repairs this volume if possible
pub fn repair(&mut self) -> Result<(), VolumeError> {
// ... function body
}
Checks the integrity of this volume
pub fn repair(&mut self) -> Result<(), VolumeError> {
// Implementation would go here
unimplemented!("Volume repair not yet implemented")
}
/// Updates the QoS configuration for this volume
pub fn update_qos(&mut self, qos: QoSConfig) -> Result<(), VolumeError> {
// ... function body
}
Repairs this volume if possible
pub fn update_qos(&mut self, qos: QoSConfig) -> Result<(), VolumeError> {
// Implementation would go here
unimplemented!("QoS update not yet implemented")
}
/// Updates the security configuration for this volume
pub fn update_security(&mut self, security: SecurityConfig) -> Result<(), VolumeError> {
// ... function body
}
Updates the QoS configuration for this volume
pub fn update_security(&mut self, security: SecurityConfig) -> Result<(), VolumeError> {
// Implementation would go here
unimplemented!("Security update not yet implemented")
}
/// Updates the backup policy for this volume
pub fn update_backup_policy(&mut self, policy: BackupPolicy) -> Result<(), VolumeError> {
// ... function body
}
Updates the security configuration for this volume
pub fn update_backup_policy(&mut self, policy: BackupPolicy) -> Result<(), VolumeError> {
// Implementation would go here
unimplemented!("Backup policy update not yet implemented")
}
// ... function body
}
Updates the backup policy for this volume