Skip to content

Conversation

joaoantoniocardoso
Copy link
Member

@joaoantoniocardoso joaoantoniocardoso commented Oct 13, 2025

This is a backport of #3594 into 1.4

Summary by Sourcery

Backport default environment variable injection and standard log configuration for Kraken extension containers

New Features:

  • Inject default Kraken extension container environment variables from host (e.g., MAV_SYSTEM_ID)

Enhancements:

  • Add DEFAULT_INJECTED_ENV_VARIABLES constant to Kraken config module
  • Extract container HostConfig log settings and Env var injection into private extension methods
  • Refactor extension start logic to apply new config helper methods

* Inject default env vars in containers when starting it
Copy link

sourcery-ai bot commented Oct 13, 2025

Reviewer's Guide

Backports injection of default environment variables and centralizes container HostConfig log settings by introducing helper methods for configuring container Env and HostConfig, updating the container startup flow accordingly, and exposing the new default Env vars list.

Class diagram for updated KrakenExtension methods

classDiagram
class KrakenExtension {
    +_set_container_config_default_env_variables(config: Dict[str, Any])
    +_set_container_config_host_config(config: Dict[str, Any])
    async start()
}
KrakenExtension : _set_container_config_default_env_variables added
KrakenExtension : _set_container_config_host_config added
KrakenExtension : start modified
Loading

Class diagram for new DEFAULT_INJECTED_ENV_VARIABLES in config

classDiagram
class KrakenConfig {
    +DEFAULT_INJECTED_ENV_VARIABLES: List[str]
}
KrakenConfig : DEFAULT_INJECTED_ENV_VARIABLES added
Loading

File-Level Changes

Change Details Files
Add helper to inject default ENV vars into container config
  • Created _set_container_config_default_env_variables method
  • Collect existing env var names to prevent duplicates
  • Append variables from DEFAULT_INJECTED_ENV_VARIABLES if set in OS env
core/services/kraken/extension/extension.py
Extract HostConfig log settings into reusable helper
  • Moved inline log config block into _set_container_config_host_config
  • Ensured HostConfig and LogConfig keys exist before assignment
core/services/kraken/extension/extension.py
Use new helpers in start method
  • Replaced inline HostConfig and Env logic with calls to helpers
core/services/kraken/extension/extension.py
Define and export DEFAULT_INJECTED_ENV_VARIABLES
  • Added DEFAULT_INJECTED_ENV_VARIABLES list with MAV_SYSTEM_ID
  • Updated all to include new constant
core/services/kraken/config.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Instead of fully overwriting HostConfig.LogConfig, merge new log settings with any existing values to avoid clobbering custom configurations.
  • Extract the hardcoded log rotation parameters (max-size and max-file) into configurable constants or settings to make them easier to adjust in the future.
  • Consider making the list of default environment variables (DEFAULT_INJECTED_ENV_VARIABLES) configurable (e.g. via a config file or environment) rather than hardcoding it to improve flexibility.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Instead of fully overwriting `HostConfig.LogConfig`, merge new log settings with any existing values to avoid clobbering custom configurations.
- Extract the hardcoded log rotation parameters (`max-size` and `max-file`) into configurable constants or settings to make them easier to adjust in the future.
- Consider making the list of default environment variables (`DEFAULT_INJECTED_ENV_VARIABLES`) configurable (e.g. via a config file or environment) rather than hardcoding it to improve flexibility.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@patrickelectric patrickelectric merged commit 3d36761 into bluerobotics:1.4 Oct 13, 2025
7 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.

3 participants