Skip to content

LCORE-1062: new configuration options for quota runner#923

Merged
tisnik merged 3 commits intolightspeed-core:mainfrom
tisnik:lcore-1062-new-configuration-options
Dec 16, 2025
Merged

LCORE-1062: new configuration options for quota runner#923
tisnik merged 3 commits intolightspeed-core:mainfrom
tisnik:lcore-1062-new-configuration-options

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Dec 16, 2025

Description

LCORE-1062: new configuration options for quota runner

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: N/A
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue #LCORE-1062

Summary by CodeRabbit

  • New Features

    • Added quota scheduler settings: retry count and retry delay.
    • Added API key token configuration support and a new inference action type.
  • Documentation

    • Updated configuration docs and OpenAPI to include the new quota and API key fields.
  • Tests

    • Added tests validating defaults and input constraints for the new quota scheduler fields.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 16, 2025

Walkthrough

Adds two new positive integer fields (database_reconnection_count, database_reconnection_delay) to QuotaSchedulerConfiguration, updates scheduler defaults, introduces APIKeyTokenConfiguration and api_key_config in authentication schema, and extends the Action enum with "rlsapi_v1_infer". Documentation and tests updated accordingly.

Changes

Cohort / File(s) Summary
Configuration model
src/models/config.py
Added database_reconnection_count: PositiveInt = 10 and database_reconnection_delay: PositiveInt = 1 to QuotaSchedulerConfiguration. Updated QuotaHandlersConfiguration.scheduler default_factory to construct the scheduler with these defaults.
Schema / OpenAPI
docs/config.json, docs/openapi.json
Added APIKeyTokenConfiguration schema; added api_key_config (anyOf APIKeyTokenConfiguration/null) to AuthenticationConfiguration; extended Action enum with "rlsapi_v1_infer". Added database_reconnection_count and database_reconnection_delay properties to QuotaSchedulerConfiguration schema (descriptions, defaults, exclusiveMinimum: 0).
Documentation (HTML / MD / PUML)
docs/config.html, docs/config.md, docs/config.puml, docs/openapi.md
Added the two reconnection fields to QuotaSchedulerConfiguration docs and adjusted layout (colgroup in config.html). Reflected descriptions and defaults across doc artifacts.
Tests
tests/unit/models/config/test_quota_scheduler_config.py, tests/unit/models/config/test_dump_configuration.py
Updated tests to expect the two new fields with defaults (10, 1); added validation tests asserting errors for non-positive reconnection values; adjusted dumped-configuration expectations to include the nested scheduler object with the new fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Files to inspect closely:
    • src/models/config.py — verify PositiveInt usage, defaults, and any interaction with existing validation.
    • docs/config.json / docs/openapi.json — ensure schema references, anyOf usage, and enum extension are valid and consistent.
    • Tests — confirm expected error messages and serialized output match implementation.

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding new configuration options (database_reconnection_count and database_reconnection_delay) for the quota runner/scheduler, which is reflected across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/models/config.py (1)

1370-1374: Fix mypy/pyright errors by passing all QuotaSchedulerConfiguration fields in default_factory

Static type-checkers now consider database_reconnection_count and database_reconnection_delay required parameters on QuotaSchedulerConfiguration.__init__, so QuotaSchedulerConfiguration(period=1) triggers the reported errors.

To keep behavior the same and satisfy mypy/pyright, pass all three fields explicitly in the default factory:

-    scheduler: QuotaSchedulerConfiguration = Field(
-        default_factory=lambda: QuotaSchedulerConfiguration(period=1),
+    scheduler: QuotaSchedulerConfiguration = Field(
+        default_factory=lambda: QuotaSchedulerConfiguration(
+            period=1,
+            database_reconnection_count=10,
+            database_reconnection_delay=1,
+        ),
         title="Quota scheduler",
         description="Quota scheduler configuration",
     )

This preserves the existing defaults used in tests and documentation while resolving the Missing named argument / Arguments missing for parameters diagnostics.

docs/config.json (1)

893-906: Critical: Missing fields in QuotaSchedulerConfiguration schema.

The QuotaSchedulerConfiguration schema only defines the period field, but is missing the two new fields that are the main focus of this PR:

  • database_reconnection_count (default: 10)
  • database_reconnection_delay (default: 1)

These fields are present in the source code (src/models/config.py lines 1316-1339) and are being tested in the test file, but are absent from this OpenAPI schema documentation. This creates an inconsistency between the actual configuration model and its documented schema.

Apply this diff to add the missing fields to the schema:

       "QuotaSchedulerConfiguration": {
         "additionalProperties": false,
         "description": "Quota scheduler configuration.",
         "properties": {
           "period": {
             "default": 1,
             "description": "Quota scheduler period specified in seconds",
             "minimum": 0,
             "title": "Period",
             "type": "integer"
+          },
+          "database_reconnection_count": {
+            "default": 10,
+            "description": "Database reconnection count on startup. When database for quota is not available on startup, the service tries to reconnect N times with specified delay.",
+            "minimum": 1,
+            "title": "Database reconnection count on startup",
+            "type": "integer"
+          },
+          "database_reconnection_delay": {
+            "default": 1,
+            "description": "Database reconnection delay specified in seconds. When database for quota is not available on startup, the service tries to reconnect N times with specified delay.",
+            "minimum": 1,
+            "title": "Database reconnection delay",
+            "type": "integer"
           }
         },
         "title": "QuotaSchedulerConfiguration",
         "type": "object"
       },
🧹 Nitpick comments (1)
docs/openapi.json (1)

6600-6620: New reconnection fields look correct; please confirm zero-handling matches backend validation

The added database_reconnection_count and database_reconnection_delay fields are well-positioned next to period, use consistent integer + exclusiveMinimum: 0.0 constraints, and their titles/descriptions clearly explain the startup retry behavior. This aligns with the PR intent for quota DB reconnection control.

One thing to double-check: using exclusiveMinimum: 0.0 means OpenAPI declares only values > 0 as valid. If the Pydantic model for QuotaSchedulerConfiguration allows 0 (e.g., to mean “no retries” or “no delay”) with ge=0/min_value=0, then the generated OpenAPI will be stricter than the actual config rules. If you intend to allow 0, switch these to a non‑exclusive minimum: 0.0; if you intend to forbid 0, ensure the Python-side validators/tests also reject zero for both fields so behavior and docs stay aligned.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db34bd5 and 52ca427.

⛔ Files ignored due to path filters (1)
  • docs/config.svg is excluded by !**/*.svg
📒 Files selected for processing (9)
  • docs/config.html (2 hunks)
  • docs/config.json (6 hunks)
  • docs/config.md (1 hunks)
  • docs/config.puml (1 hunks)
  • docs/openapi.json (1 hunks)
  • docs/openapi.md (1 hunks)
  • src/models/config.py (1 hunks)
  • tests/unit/models/config/test_dump_configuration.py (4 hunks)
  • tests/unit/models/config/test_quota_scheduler_config.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
src/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

src/**/*.py: Use absolute imports for internal modules in LCS project (e.g., from auth import get_auth_dependency)
All modules must start with descriptive docstrings explaining their purpose
Use logger = logging.getLogger(__name__) pattern for module logging
All functions must include complete type annotations for parameters and return types, using modern syntax (str | int) and Optional[Type] or Type | None
All functions must have docstrings with brief descriptions following Google Python docstring conventions
Function names must use snake_case with descriptive, action-oriented names (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns; return new data structures instead of modifying input parameters
Use async def for I/O operations and external API calls
All classes must include descriptive docstrings explaining their purpose following Google Python docstring conventions
Class names must use PascalCase with descriptive names and standard suffixes: Configuration for config classes, Error/Exception for exceptions, Resolver for strategy patterns, Interface for abstract base classes
Abstract classes must use ABC with @abstractmethod decorators
Include complete type annotations for all class attributes in Python classes
Use import logging and module logger pattern with standard log levels: debug, info, warning, error

Files:

  • src/models/config.py
src/models/config.py

📄 CodeRabbit inference engine (CLAUDE.md)

src/models/config.py: All configuration must use Pydantic models extending ConfigurationBase with extra="forbid" to reject unknown fields
Use type hints Optional[FilePath], PositiveInt, SecretStr for Pydantic configuration models

Files:

  • src/models/config.py
src/models/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

src/models/**/*.py: Use @field_validator and @model_validator for custom validation in Pydantic models
Pydantic configuration classes must extend ConfigurationBase; data models must extend BaseModel

Files:

  • src/models/config.py
tests/{unit,integration}/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

tests/{unit,integration}/**/*.py: Use pytest for all unit and integration tests; do not use unittest framework
Unit tests must achieve 60% code coverage; integration tests must achieve 10% coverage

Files:

  • tests/unit/models/config/test_dump_configuration.py
  • tests/unit/models/config/test_quota_scheduler_config.py
tests/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use pytest-mock with AsyncMock objects for mocking in tests

Files:

  • tests/unit/models/config/test_dump_configuration.py
  • tests/unit/models/config/test_quota_scheduler_config.py
🧬 Code graph analysis (1)
tests/unit/models/config/test_quota_scheduler_config.py (1)
src/models/config.py (1)
  • QuotaSchedulerConfiguration (1317-1340)
🪛 GitHub Actions: Pyright
src/models/config.py

[error] 1371-1371: pyright: Arguments missing for parameters "database_reconnection_count", "database_reconnection_delay" (reportCallIssue)

🪛 GitHub Actions: Type checks
src/models/config.py

[error] 1371-1371: Mypy: Missing named argument 'database_reconnection_count' for 'QuotaSchedulerConfiguration'. Command: uv run mypy --explicit-package-bases --disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports --disable-error-code attr-defined src/


[error] 1371-1371: Mypy: Missing named argument 'database_reconnection_delay' for 'QuotaSchedulerConfiguration'. Command: uv run mypy --explicit-package-bases --disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports --disable-error-code attr-defined src/

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build-pr
  • GitHub Check: E2E: library mode / azure
  • GitHub Check: E2E: library mode / ci
  • GitHub Check: E2E: server mode / azure
  • GitHub Check: E2E: server mode / ci
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
🔇 Additional comments (9)
docs/config.puml (1)

159-162: Quota scheduler fields documented consistently

database_reconnection_count and database_reconnection_delay here match the new fields on QuotaSchedulerConfiguration in src/models/config.py and their placement before period is consistent with other docs. No further changes needed.

src/models/config.py (1)

1317-1340: New quota reconnection fields look correct and well-typed

Using PositiveInt with defaults (10 count, 1 second delay) and explicit descriptions for database_reconnection_count and database_reconnection_delay aligns with the rest of the configuration models and the intended startup reconnection behavior. No issues from a modeling/validation perspective.

docs/openapi.md (1)

4352-4357: OpenAPI schema updated correctly for new quota reconnection fields

The QuotaSchedulerConfiguration component now includes database_reconnection_count and database_reconnection_delay with descriptions matching the model and other docs. This keeps the OpenAPI surface in sync with the Python configuration.

tests/unit/models/config/test_dump_configuration.py (1)

186-190: Dump configuration tests correctly assert new scheduler fields

The updated expectations for quota_handlers.scheduler (including database_reconnection_count and database_reconnection_delay alongside period) match the new QuotaSchedulerConfiguration model and ensure the dump format is locked in for both default and custom scheduler periods. Looks good.

Also applies to: 505-509, 689-693, 859-863

docs/config.md (1)

420-425: Config schema docs aligned with new QuotaSchedulerConfiguration fields

The QuotaSchedulerConfiguration table now documents database_reconnection_count and database_reconnection_delay with accurate descriptions. This keeps the human-readable config schema in sync with the code and OpenAPI docs.

docs/config.html (1)

1119-1123: HTML config docs correctly include new quota reconnection fields

The QuotaSchedulerConfiguration table now has a proper <colgroup> and rows for database_reconnection_count and database_reconnection_delay with descriptions consistent with other docs and the model. No issues.

Also applies to: 1137-1150

docs/config.json (1)

9-29: Verify that APIKeyTokenConfiguration changes belong in this PR.

The PR objectives state this PR "Adds new configuration options for the quota runner (LCORE-1062)", but this new APIKeyTokenConfiguration schema appears unrelated to quota configuration. Please confirm whether these authentication-related changes should be part of this PR or split into a separate PR for better traceability.

tests/unit/models/config/test_quota_scheduler_config.py (2)

10-17: LGTM!

The test correctly verifies the default values for the new configuration fields, including the quota runner reconnection parameters.


20-30: LGTM!

The test correctly validates custom configuration values for all fields, including the new reconnection parameters.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
tests/unit/models/config/test_quota_scheduler_config.py (2)

45-48: Test looks correct, but consider adding coverage for zero value.

The negative value validation test is correct. However, since database_reconnection_count is a PositiveInt (must be > 0), consider adding a test case for zero values as well, similar to the existing test_quota_scheduler_custom_configuration_zero_period test.

Example:

def test_quota_scheduler_custom_configuration_zero_reconnection_count() -> None:
    """Test that zero database_reconnection_count value raises ValidationError."""
    with pytest.raises(ValidationError, match="Input should be greater than 0"):
        QuotaSchedulerConfiguration(database_reconnection_count=0)

51-54: Test looks correct, but consider adding coverage for zero value.

The negative value validation test is correct. However, since database_reconnection_delay is a PositiveInt (must be > 0), consider adding a test case for zero values as well, similar to the existing test_quota_scheduler_custom_configuration_zero_period test.

Example:

def test_quota_scheduler_custom_configuration_zero_reconnection_delay() -> None:
    """Test that zero database_reconnection_delay value raises ValidationError."""
    with pytest.raises(ValidationError, match="Input should be greater than 0"):
        QuotaSchedulerConfiguration(database_reconnection_delay=0)
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52ca427 and ca2f2af.

📒 Files selected for processing (2)
  • src/models/config.py (2 hunks)
  • tests/unit/models/config/test_quota_scheduler_config.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/models/config.py
🧰 Additional context used
📓 Path-based instructions (2)
tests/{unit,integration}/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

tests/{unit,integration}/**/*.py: Use pytest for all unit and integration tests; do not use unittest framework
Unit tests must achieve 60% code coverage; integration tests must achieve 10% coverage

Files:

  • tests/unit/models/config/test_quota_scheduler_config.py
tests/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use pytest-mock with AsyncMock objects for mocking in tests

Files:

  • tests/unit/models/config/test_quota_scheduler_config.py
🧬 Code graph analysis (1)
tests/unit/models/config/test_quota_scheduler_config.py (1)
src/models/config.py (1)
  • QuotaSchedulerConfiguration (1317-1340)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
  • GitHub Check: build-pr
  • GitHub Check: E2E: library mode / ci
  • GitHub Check: E2E: server mode / azure
  • GitHub Check: E2E: server mode / ci
  • GitHub Check: E2E: library mode / azure
🔇 Additional comments (2)
tests/unit/models/config/test_quota_scheduler_config.py (2)

16-17: LGTM!

The default value assertions correctly match the model defaults defined in src/models/config.py (database_reconnection_count=10, database_reconnection_delay=1).


22-30: LGTM!

The custom configuration test properly validates all three fields with appropriate test values.

@tisnik tisnik force-pushed the lcore-1062-new-configuration-options branch from ca2f2af to defcde6 Compare December 16, 2025 14:04
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/models/config.py (1)

1334-1340: LGTM! Reconnection delay properly configured.

The field correctly uses PositiveInt with a sensible default of 1 second. The implementation aligns with coding guidelines and complements the reconnection count field.

Optional: Consider making the description slightly more distinct from database_reconnection_count to improve readability. For example:

-    database_reconnection_delay: PositiveInt = Field(
-        1,
-        title="Database reconnection delay",
-        description="Database reconnection delay specified in seconds. When database for "
-        "quota is not available on startup, the service tries to reconnect N "
-        "times with specified delay.",
-    )
+    database_reconnection_delay: PositiveInt = Field(
+        1,
+        title="Database reconnection delay",
+        description="Delay in seconds between reconnection attempts when the quota "
+        "database is unavailable on startup.",
+    )
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca2f2af and defcde6.

📒 Files selected for processing (2)
  • src/models/config.py (2 hunks)
  • tests/unit/models/config/test_quota_scheduler_config.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unit/models/config/test_quota_scheduler_config.py
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

src/**/*.py: Use absolute imports for internal modules in LCS project (e.g., from auth import get_auth_dependency)
All modules must start with descriptive docstrings explaining their purpose
Use logger = logging.getLogger(__name__) pattern for module logging
All functions must include complete type annotations for parameters and return types, using modern syntax (str | int) and Optional[Type] or Type | None
All functions must have docstrings with brief descriptions following Google Python docstring conventions
Function names must use snake_case with descriptive, action-oriented names (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns; return new data structures instead of modifying input parameters
Use async def for I/O operations and external API calls
All classes must include descriptive docstrings explaining their purpose following Google Python docstring conventions
Class names must use PascalCase with descriptive names and standard suffixes: Configuration for config classes, Error/Exception for exceptions, Resolver for strategy patterns, Interface for abstract base classes
Abstract classes must use ABC with @abstractmethod decorators
Include complete type annotations for all class attributes in Python classes
Use import logging and module logger pattern with standard log levels: debug, info, warning, error

Files:

  • src/models/config.py
src/models/config.py

📄 CodeRabbit inference engine (CLAUDE.md)

src/models/config.py: All configuration must use Pydantic models extending ConfigurationBase with extra="forbid" to reject unknown fields
Use type hints Optional[FilePath], PositiveInt, SecretStr for Pydantic configuration models

Files:

  • src/models/config.py
src/models/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

src/models/**/*.py: Use @field_validator and @model_validator for custom validation in Pydantic models
Pydantic configuration classes must extend ConfigurationBase; data models must extend BaseModel

Files:

  • src/models/config.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
  • GitHub Check: E2E: server mode / ci
  • GitHub Check: build-pr
  • GitHub Check: E2E: library mode / azure
  • GitHub Check: E2E: library mode / ci
  • GitHub Check: E2E: server mode / azure
🔇 Additional comments (2)
src/models/config.py (2)

1326-1332: LGTM! Well-structured reconnection count configuration.

The field is correctly typed with PositiveInt, ensuring only positive values are accepted. The default value of 10 reconnection attempts is reasonable, and the description clearly explains its purpose.


1371-1373: LGTM! Default factory correctly updated.

The default factory properly initializes all three QuotaSchedulerConfiguration parameters with values that match the Field defaults. This ensures consistency across the configuration model.

@tisnik tisnik merged commit bace7c4 into lightspeed-core:main Dec 16, 2025
19 of 25 checks passed
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