Skip to content

Kubernetes: Rework offers and resource handling#4021

Open
un-def wants to merge 2 commits into
masterfrom
pr_kubernetes_offers
Open

Kubernetes: Rework offers and resource handling#4021
un-def wants to merge 2 commits into
masterfrom
pr_kubernetes_offers

Conversation

@un-def

@un-def un-def commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator
  • Switch the backend from ComputeWithFilteredOffersCached to ComputeWithAllOffersCached. Kubernetes node offers don't depend on run requirements, so all node offers are now cached once and adjusted/filtered per requirements via get_offers_modifiers(), instead of re-querying the cluster for every distinct requirements set.

  • Emit a Kubernetes request of 0 when a resource range has no lower bound (e.g. cpu: ..4). Previously no request was emitted, and since Kubernetes defaults the request to the limit, cpu: ..4 silently behaved like cpu: 4. An explicit 0 request is less surprising and matches how ranges behave elsewhere in dstack.

  • Introduce ResourceRequests/ResourceLimits dataclasses that centralize the translation between dstack ResourcesSpec and Kubernetes resource maps, and back (from_kubernetes_map). Previously this logic was duplicated and built ad hoc as dicts in _create_job_pod() and get_instance_offers().

  • Add adjust_resources_by_resource_requests() to cap an offer's advertised resources to what was requested (used as the offer modifier), and to reflect the actual pod requests on the provisioned instance in run_job().

un-def added 2 commits July 10, 2026 10:20
* Switch the backend from ComputeWithFilteredOffersCached to
ComputeWithAllOffersCached. Kubernetes node offers don't depend on run
requirements, so all node offers are now cached once and
adjusted/filtered per requirements via get_offers_modifiers(), instead
of re-querying the cluster for every distinct requirements set.

* Emit a Kubernetes request of 0 when a resource range has no lower
bound (e.g. `cpu: ..4`). Previously no request was emitted, and since
Kubernetes defaults the request to the limit, `cpu: ..4` silently
behaved like `cpu: 4`.  An explicit 0 request is less surprising and
matches how ranges behave elsewhere in dstack.

* Introduce ResourceRequests/ResourceLimits dataclasses that centralize
the translation between dstack ResourcesSpec and Kubernetes resource
maps, and back (from_kubernetes_map). Previously this logic was
duplicated and built ad hoc as dicts in _create_job_pod() and
get_instance_offers().

* Add adjust_resources_by_resource_requests() to cap an offer's
advertised resources to what was requested (used as the offer
modifier), and to reflect the actual pod requests on the provisioned
instance in run_job().
@un-def un-def requested a review from r4victor July 10, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant