Skip to content

Conversation

@krpsh123
Copy link
Contributor

@krpsh123 krpsh123 commented Nov 13, 2025

Description

New API Endpoint: /api/v1/volumes/filter-prioritize

Overview

Direct API endpoint for filtering and scoring LVMVolumeGroups based on available space. Designed for external consumers like CSI drivers that need to select the best LVG for volume placement.

Endpoint

Path Method Description
/api/v1/volumes/filter-prioritize POST Filter LVGs by available space and return scored results

Request

Content-Type

application/json

Request Body

{
  "lvgs": [
    {
      "name": "lvg-worker-1",
      "thinPoolName": "thin-pool-1"  // Required only for thin volumes
    },
    {
      "name": "lvg-worker-2",
      "thinPoolName": "thin-pool-1"
    }
  ],
  "volume": {
    "name": "pvc-abc123",
    "size": 10737418240,  // Size in bytes (10 Gi)
    "type": "thick"       // "thick" or "thin"
  }
}

Request Fields

Field Type Required Description
lvgs array Yes List of candidate LVMVolumeGroups
lvgs[].name string Yes LVMVolumeGroup resource name
lvgs[].thinPoolName string For thin Thin pool name (required when volume.type = "thin")
volume.name string Yes Volume name (used for space reservation in cache)
volume.size int64 Yes Requested volume size in bytes
volume.type string Yes Volume type: "thick" or "thin"

Response

Success Response (200 OK)

{
  "lvgs": [
    {
      "name": "lvg-worker-1",
      "score": 8
    },
    {
      "name": "lvg-worker-2", 
      "score": 5
    }
  ]
}

Response Fields

Field Type Description
lvgs array Filtered and scored LVGs, sorted by score (highest first)
lvgs[].name string LVMVolumeGroup name
lvgs[].score int Score from 1-10 based on available space
error string Error message (only present on error)

Empty Result

If no LVGs have sufficient space:

{
  "lvgs": []
}

Behavior

  1. Filtering: LVGs without enough available space are excluded
  2. Scoring: Remaining LVGs are scored 1-10 based on free space percentage
  3. Reservation: Space is reserved in cache for all filtered LVGs (to prevent over-allocation during concurrent requests)
  4. Sorting: Results are sorted by score (highest to lowest)

Error Responses

Status Condition
400 Bad Request Empty lvgs list
400 Bad Request Invalid volume data (empty name or size ≤ 0)
400 Bad Request Invalid volume type
400 Bad Request Missing thinPoolName for thin volumes
405 Method Not Allowed Non-POST request
500 Internal Server Error Internal processing error

Example Usage

Thick Volume Request

curl -X POST https://scheduler-extender:8000/api/v1/volumes/filter-prioritize \
  -H "Content-Type: application/json" \
  -d '{
    "lvgs": [
      {"name": "lvg-worker-1"},
      {"name": "lvg-worker-2"}
    ],
    "volume": {
      "name": "pvc-12345",
      "size": 5368709120,
      "type": "thick"
    }
  }'

Thin Volume Request

curl -X POST https://scheduler-extender:8000/api/v1/volumes/filter-prioritize \
  -H "Content-Type: application/json" \
  -d '{
    "lvgs": [
      {"name": "lvg-worker-1", "thinPoolName": "data-pool"},
      {"name": "lvg-worker-2", "thinPoolName": "data-pool"}
    ],
    "volume": {
      "name": "pvc-67890",
      "size": 10737418240,
      "type": "thin"
    }
  }'

Notes

  • LVG must exist in scheduler-extender's cache (populated by LVG watcher controller)
  • Space reservation expires after configured timeout (default: 30 seconds)
  • Score calculation uses logarithmic scale based on free space percentage

Why do we need it, and what problem does it solve?

What is the expected result?

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

@krpsh123 krpsh123 self-assigned this Nov 13, 2025
@krpsh123 krpsh123 added the enhancement New feature or request label Nov 13, 2025
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
krpsh123 and others added 17 commits November 26, 2025 10:37
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Aleksandr Zimin <[email protected]>
Signed-off-by: Pavel Karpov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants