network icon indicating copy to clipboard operation
network copied to clipboard

feat: support this role in container builds

Open richm opened this issue 3 months ago • 7 comments

Feature: Support running the timesync role during container builds.

Reason: This is particularly useful for building bootc derivative OSes.

Result: These flags enable running the bootc container scenarios in CI, which ensures that the role works in buildah build environment. This allows us to officially support this role for image mode builds.

Signed-off-by: Rich Megginson [email protected]

Summary by Sourcery

Enable offline NetworkManager support to allow the role to run in container build environments, refactor the command API and provider switching logic, and overhaul the test suite with a reusable harness and helper tasks to streamline CI testing

New Features:

  • Introduce an offline NetworkManager provider (nm_offline) for container build environments
  • Enable support for running the role under Buildah/container scenarios by switching to offline mode when the system is not booted

Enhancements:

  • Add a check_rc flag to run_command and rename the ifcfg_header property to managed_file_header
  • Automatically detect booted systems (__network_is_booted) and switch to nm_offline when necessary

CI:

  • Remove branch filters from the QEMU KVM integration tests workflow

Tests:

  • Refactor test playbooks to use a unified run_test.yml harness with modular setup, assert, and cleanup tasks
  • Add new test helper tasks (assert_connection_settings.yml, assert_command_output.yml, assert_nm_connection_status.yml, and handlers)
  • Update tests to conditionally skip or adjust behavior in buildah environments and increase the default test timeout

richm avatar Sep 30 '25 19:09 richm

Reviewer's Guide

Enables offline operation of the network role in buildah environments by introducing an nm_offline provider and boot detection, refactors library methods for command execution and file header handling, updates defaults and main tasks for offline support, and restructures the integration tests and CI workflow with a unified run_test harness to handle build and boot scenarios.

Class diagram for new and updated command provider classes

classDiagram
    class Cmd {
        +managed_file_header
        +run_command(argv, encoding=None, check_rc=False)
        +log(...)
    }
    class Cmd_nm {
        +managed_file_header
        +run_command(argv, encoding=None, check_rc=False)
    }
    class Cmd_nm_offline {
        +profile_path(name)
        +run_prepare()
        +connection_create(connections, idx)
        +run_action_present(idx)
        +run_action_absent(idx)
        +run_action_up(idx)
        +run_action_down(idx)
    }
    class Cmd_initscripts {
        +managed_file_header
        +run_command(argv, encoding=None, check_rc=False)
    }
    Cmd <|-- Cmd_nm
    Cmd <|-- Cmd_nm_offline
    Cmd <|-- Cmd_initscripts

File-Level Changes

Change Details Files
Refactor command execution API and header property
  • Renamed ifcfg_header to managed_file_header in base and subclasses
  • Extended run_command signature to accept a new check_rc parameter
library/network_connections.py
Introduce offline NM backend for container builds
  • Added Cmd_nm_offline provider class with fully offline connection_create and action methods
  • Updated provider factory to include nm_offline option
library/network_connections.py
Automatic switch to nm_offline when system not booted
  • Added systemd boot detection in tasks/set_facts.yml to set __network_is_booted
  • Set network_provider to nm_offline in main tasks when __network_is_booted is false
tasks/set_facts.yml
tasks/main.yml
Adjust service tasks and defaults for nm_offline support
  • Omitted starting services when not booted via conditional state in tasks/main.yml
  • Defined nm_offline under __network_provider_setup in defaults/main.yml
tasks/main.yml
defaults/main.yml
Refactor integration tests with unified run_test harness
  • Created tasks/run_test.yml and handler scripts (handle_setup_task.yml, handle_test_task.yml, handle_assert_task.yml, handle_cleanup_task.yml)
  • Refactored playbooks to invoke run_test abstraction and added buildah/boot conditional logic
tests/playbooks/*.yml
tests/tasks/run_test.yml
tests/tasks/handle_*.yml
Add test helper task modules for assertions
  • Added assert_connection_settings.yml, assert_command_output.yml, assert_nm_connection_status.yml for reusable checks
  • Introduced collection-requirements.yml to pull community.general
tests/tasks/assert_connection_settings.yml
tests/tasks/assert_command_output.yml
tests/tasks/assert_nm_connection_status.yml
tests/collection-requirements.yml
Update CI workflow for bootc integration
  • Removed branch filter from qemu-kvm-integration-tests workflow
  • Included bootc container images in the test matrix
.github/workflows/qemu-kvm-integration-tests.yml

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

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Sep 30 '25 19:09 sourcery-ai[bot]

Codecov Report

:x: Patch coverage is 5.13699% with 277 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 39.90%. Comparing base (1b57520) to head (e8a3ff4). :warning: Report is 57 commits behind head on main.

Files with missing lines Patch % Lines
library/network_connections.py 5.13% 277 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #814      +/-   ##
==========================================
- Coverage   43.11%   39.90%   -3.22%     
==========================================
  Files          12       12              
  Lines        3124     3408     +284     
==========================================
+ Hits         1347     1360      +13     
- Misses       1777     2048     +271     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Sep 30 '25 19:09 codecov[bot]

[citest]

richm avatar Oct 17 '25 15:10 richm

[citest]

richm avatar Oct 17 '25 21:10 richm

[citest]

richm avatar Oct 18 '25 00:10 richm

[citest]

richm avatar Oct 20 '25 17:10 richm

[citest]

richm avatar Oct 20 '25 17:10 richm

Thank you for your contribution! There was no activity in this pull request recently. To avoid pull requests to pile up, an automated process marked this pull request as stale. It will close this pull request if no further activity occurs. The current policy is available at: https://github.com//linux-system-roles/network/blob/main/.github/stale.yml

stale[bot] avatar Dec 18 '25 00:12 stale[bot]