Add spec.bookings field with typed resource claim entries#296
Add spec.bookings field with typed resource claim entries#296PhilippMatthes wants to merge 2 commits intomainfrom
Conversation
Model consumer allocations and reserved capacity under spec.bookings using the field-presence union pattern established by spec.groups.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The modernize/newexpr linter flags the generic ptr[T] helper as an inlinable wrapper around new(). Replace the single usage with new(int64) and remove the helper function entirely.
Merging this branch will not change overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
The Cortex Placement Shim needs to record which resources each instance consumes on a hypervisor, and which capacity is held back from scheduling. Today, the Hypervisor CRD tracks actual resource usage via
status.allocation(auto-discovered by kvm-node-agent from libvirt), but has no representation of what Nova thinks is allocated. This prevents the shim from serving allocation and inventory endpoints directly from the CRD.This PR introduces
spec.bookings— the CRD's record of all resource claims as seen by the Placement API. There are two kinds of resource claims:reserved_host_memory_mb,reserved_host_cpus, andreserved_host_disk_mbconfig options subtract from available inventory.The field follows the same field-presence union pattern established by
spec.groups(andPodSpec.volumesin core Kubernetes). Each entry populates exactly one type-specific sub-field, and the populated field identifies the booking type:A CEL validation rule enforces that exactly one sub-field is populated per entry. The
consumerTypefield is a free-form string to accommodate all consumer types in the Placement API (see API reference).Library helper functions (
GetConsumers,GetConsumer,HasConsumer,GetReservations,GetReservation,SumResources) follow the same pattern as thespec.groupshelpers and are reusable across the shim, operator, and scheduler.The design is extensible: adding a new booking concept means adding one optional pointer field to the Booking struct and a corresponding type-specific struct. No changes to existing fields or consumers are required.
See: cobaltcore-dev/cortex#787