Skip to content

[FEATURES] optimize RuntimeTieredStore struct for CacheRuntime #5898

@xliuqq

Description

@xliuqq

What feature you'd like to add:

The mapping relationship between Medium and Path defined in the RuntimeTieredStoreLevel structure within the current CacheRuntime is ambiguous

Why is this feature needed:

Help users configure the RuntimeTieredStoreLevel fields more properly and reasonably.

The original struct:

// RuntimeTieredStoreLevel describes the configuration for a single tier in the tiered storage
type RuntimeTieredStoreLevel struct {
	// Medium describes the storage medium type for this tier.
	// Supported types include process memory and various volume types.
	// +optional
	Medium MediumSource `json:"medium,omitempty"`

	// Path is a list of file paths to be used for the cache tier.
	// Multiple paths can be specified to distribute cache across different mount points.
	// For example: ["/mnt/cache1", "/mnt/cache2"].
	// +kubebuilder:validation:MinItems=1
	// +optional
	Path []string `json:"path,omitempty"`

	// Quota is a list of storage quotas for each path in the tier.
	// The length of Quota should match the length of Path.
	// Each quota corresponds to the path at the same index.
	// For example: ["100Gi", "50Gi"] allocates 100GiB to the first path and 50GiB to the second path.
	// +optional
	Quota []resource.Quantity `json:"quota,omitempty"`

	// High is the ratio of high watermark of the tier (e.g., "0.9").
	// When cache usage exceeds this ratio, eviction will be triggered.
	// +optional
	High string `json:"high,omitempty"`

	// Low is the ratio of low watermark of the tier (e.g., "0.7").
	// Eviction will continue until cache usage falls below this ratio.
	// +optional
	Low string `json:"low,omitempty"`
}

The structure definition confirmed after offline discussion is

// ProcessMemoryMediumSource describes process memory as a storage medium.
// Cache data will be stored in the process's memory space.
type ProcessMemoryMediumSource struct {
	// Quota specifies the amount of memory to allocate for caching.
	// This value will be added to the container's resource requests and limits.
	// Example: "4Gi" allocates 4GiB memory for cache.
	// +kubebuilder:validation:Required
	Quota resource.Quantity `json:"quota"`
}

// HostPathMediumSource describes hostPath volumes as a storage medium.
// Multiple paths can be configured to distribute cache across different disks.
type HostPathMediumSource struct {
	// Paths is a list of file paths on the host machine to be used for caching.
	// Multiple paths allow distributing cache across different mount points or disks.
	// Example: ["/mnt/cache1", "/mnt/cache2"]
	// +kubebuilder:validation:MinItems=1
	// +kubebuilder:validation:Required
	Paths []string `json:"paths"`

	// Quotas is a list of storage quotas corresponding to each path.
	// The length of Quotas must match the length of Paths.
	// Each quota defines the maximum cache size for the corresponding path.
	// Example: ["100Gi", "50Gi"] allocates 100GiB to the first path and 50GiB to the second.
	// +kubebuilder:validation:MinItems=1
	// +kubebuilder:validation:Required
	Quotas []resource.Quantity `json:"quotas"`

	// Type specifies the type of hostPath volume.
	// Defaults to empty string (no validation).
	// More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath
	// +optional
	Type *corev1.HostPathType `json:"type,omitempty"`
}

// EmptyDirMediumSource describes emptyDir volume as a storage medium.
// Can be backed by node's default storage or memory (tmpfs).
type EmptyDirMediumSource struct {
	// Quota specifies the maximum storage capacity for the emptyDir volume.
	// For Memory medium, this limit is also constrained by the sum of container memory limits.
	// The actual limit = min(Quota, sum of container memory limits).
	// Example: "100Gi" limits the emptyDir to 100GiB.
	// +kubebuilder:validation:Required
	Quota resource.Quantity `json:"quota"`

	// medium represents what type of storage medium should back this directory.
	// The default is "" which means to use the node's default medium.
	// Must be an empty string (default) or Memory.
	// More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir
	// +optional
	Medium corev1.StorageMedium `json:"medium,omitempty"`
}

// RuntimeTieredStoreLevel describes the configuration for a single tier in the tiered storage.
// Each tier can use different storage media (e.g., memory, SSD, HDD).
// Only one of ProcessMemory, EmptyDir, or HostPath should be specified.
type RuntimeTieredStoreLevel struct {
	// ProcessMemory indicates that process memory should be used as one storage medium.
	// When specified, cache data will be stored in the process's memory space,
	// and the quota will be added to the container's resource requests and limits.
	// +optional
	ProcessMemory *ProcessMemoryMediumSource `json:"processMemory,omitempty"`

	// EmptyDir indicates that an emptyDir volume should be used as the storage medium.
	// +optional
	EmptyDir *EmptyDirMediumSource `json:"emptyDir,omitempty"`

	// HostPath indicates that one or more hostPath volumes should be used as a storage medium.
	// +optional
	HostPath *HostPathMediumSource `json:"hostPath,omitempty"`
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions