Skip to content

Conversation

@emi80
Copy link
Contributor

@emi80 emi80 commented Sep 30, 2025

Enhancement: This PR adds the loopback device to black_list_names when deleting all profiles except the ones explicitly included in the ansible playbook

Reason: Adding an entry without a name and persistent_state: absent to the network_connections variables would trigger a changed state in one of the tasks

TASK [network : Configure networking connection profiles] **********************
changed: [hostname]

This was because the profile loopback device was being removed and then automatically recreated by the system.

Result: Now the loopback profile is kept and the state is not reported as changed:

TASK [network : Configure networking connection profiles] **********************
ok: [hostname]

Issue Tracker Tickets (GitHub issue): #689

Summary by Sourcery

Keep the loopback network profile from being deleted when purging absent profiles to prevent false-positive changes in Ansible playbooks

Bug Fixes:

  • Prevent Ansible from reporting a changed state by avoiding removal and automatic recreation of the loopback profile

Enhancements:

  • Add "lo" (loopback) to the blacklist when deleting all non-explicit network profiles

@sourcery-ai
Copy link

sourcery-ai bot commented Sep 30, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR updates the 'absent' action in the network_connections module to exclude the loopback interface ('lo') from deletion, preventing a spurious 'changed' state each run when the system auto-recreates it.

Flow diagram for updated profile deletion logic (excluding loopback)

flowchart TD
    A["Start profile deletion (absent action)"] --> B["Get non-absent profile names"]
    B --> C["Add 'lo' (loopback) to blacklist"]
    C --> D["Iterate over all network profiles"]
    D --> E["If profile is in blacklist, skip deletion"]
    D --> F["If profile is not in blacklist, delete profile"]
    E --> G["End"]
    F --> G["End"]
Loading

File-Level Changes

Change Details Files
Exclude loopback interface from profile deletion
  • Add black_list_names.add("lo") to skip loopback
  • Insert comment explaining rationale for skipping loopback
library/network_connections.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 and they look great!


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.

@richm richm changed the title Skip the loopback profile when deleting all profiles except the ones explicitly included fix: Skip the loopback profile when deleting all profiles except the ones explicitly included Sep 30, 2025
@codecov
Copy link

codecov bot commented Sep 30, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 43.22%. Comparing base (1b57520) to head (76c97ff).
⚠️ Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
library/network_connections.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #813      +/-   ##
==========================================
+ Coverage   43.11%   43.22%   +0.10%     
==========================================
  Files          12       12              
  Lines        3124     3123       -1     
==========================================
+ Hits         1347     1350       +3     
+ Misses       1777     1773       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

…cept explicitly included - address linux-system-roles#689

Signed-off-by: Emilio Palumbo <emiliopalumbo@gmail.com>
@richm
Copy link
Contributor

richm commented Oct 6, 2025

[citest]

@richm richm merged commit 3df2be4 into linux-system-roles:main Oct 7, 2025
37 of 40 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