Skip to content

Make the SONiC port_config path configurable - #2563

Merged
berendt merged 1 commit into
mainfrom
sonic-e2e-v2-portpath
Aug 5, 2026
Merged

Make the SONiC port_config path configurable#2563
berendt merged 1 commit into
mainfrom
sonic-e2e-v2-portpath

Conversation

@ideaship

@ideaship ideaship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

First of the series tracked in #2562, which explains the ordering and what each
PR covers. This one stands on its own — it is a production change with an
unchanged default, and nothing later in the series is needed to review it.

The problem

PORT_CONFIG_PATH was hardcoded to /etc/sonic/port_config, which exists only
inside the conductor image: Containerfile:21 copies files/sonic/port_config/
there. A generator run from a checkout instead — local development — finds
nothing at that path, and the workaround is to plant the .ini files under
/etc/sonic, which needs root.

The change

Add SONIC_PORT_CONFIG_PATH to osism/settings.py, following the existing
SONIC_* environment variable convention, and wire
constants.PORT_CONFIG_PATH to it.

The default is the previous hardcoded path, so container behaviour is
identical
and nothing in production moves. Setting the variable points the
generator at files/sonic/port_config/ in the checkout instead.

Tests

Three cases: the setting's default, the environment override, and the
settings-to-constants wiring — the last because constants.PORT_CONFIG_PATH is
assigned at import time, so a test that only checked the setting would not catch
the wiring being dropped.

The directory holding the per-HWSKU port_config .ini files was hardcoded
to /etc/sonic/port_config, which only exists inside the conductor image
-- the Containerfile copies files/sonic/port_config there. A generator
run from a checkout instead, as in local development, finds nothing at
that path, and planting the files under /etc/sonic to work around it
needs root.

Introduce a SONIC_PORT_CONFIG_PATH setting in osism.settings, following
the existing SONIC_* environment variable convention, and wire
constants.PORT_CONFIG_PATH to it. The default is the previous hardcoded
path, so container behaviour is identical; setting the variable points
the generator at files/sonic/port_config/ in the checkout instead.

Tests cover the default, the environment override, and the
settings-to-constants wiring.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Roger Luethi <luethi@osism.tech>
@ideaship
ideaship marked this pull request as ready for review August 5, 2026 15:02
@ideaship
ideaship requested a review from berendt August 5, 2026 15:02
@ideaship ideaship moved this from New to In review in Human Board Aug 5, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In test_port_config_path_follows_settings, consider using monkeypatch.setattr (and possibly the existing reload_settings fixture) instead of manually mutating settings_module.SONIC_PORT_CONFIG_PATH and handling reloads with try/finally, to keep test setup/teardown more consistent and less error-prone.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `test_port_config_path_follows_settings`, consider using `monkeypatch.setattr` (and possibly the existing `reload_settings` fixture) instead of manually mutating `settings_module.SONIC_PORT_CONFIG_PATH` and handling reloads with `try/finally`, to keep test setup/teardown more consistent and less error-prone.

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.

@berendt
berendt merged commit e4d3173 into main Aug 5, 2026
4 checks passed
@berendt
berendt deleted the sonic-e2e-v2-portpath branch August 5, 2026 15:10
@github-project-automation github-project-automation Bot moved this from In review to Done in Human Board Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants