Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --network-mode option #674

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

rhjostone
Copy link
Contributor

@rhjostone rhjostone commented Jan 30, 2025

Addresses #665

Summary by Sourcery

New Features:

  • Allow users to specify the network mode for containers.

Copy link
Contributor

sourcery-ai bot commented Jan 30, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new --network-mode option to the run subcommand, allowing users to configure the network mode of the container. By default, network access is disabled (none).

Sequence diagram for container setup with network mode

sequenceDiagram
    participant User
    participant CLI
    participant Model
    participant Container

    User->>CLI: run command with --network-mode
    CLI->>Model: setup_container(args)
    Note over Model: Check if subcommand is 'run'
    Model->>Model: Add network mode to container args
    Model->>Container: Create container with network settings
    Container-->>User: Container running with specified network mode
Loading

Class diagram showing CLI argument changes

classDiagram
    class ArgumentParser {
        +add_argument()
    }
    class RunParser {
        +ARGS: list
        +network_mode: str
    }
    class Model {
        +setup_container(args)
    }
    RunParser --|> ArgumentParser
    Model ..> RunParser: uses
    note for RunParser "Added --network-mode argument"
    note for Model "Modified to handle network mode"
Loading

File-Level Changes

Change Details Files
Added a --network-mode argument to the run subcommand.
  • Added a new argument --network-mode to the run subcommand.
  • The default value for --network-mode is set to none.
  • The help text for --network-mode explains its purpose and links to the podman documentation.
ramalama/cli.py
Implemented the --network-mode argument in the container setup.
  • Added the --network argument to the conman_args list when the subcommand is run.
  • The value of the --network argument is set to the value of the --network-mode argument.
ramalama/model.py

Possibly linked issues


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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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
Contributor

@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 @rhjostone - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@rhatdan
Copy link
Member

rhatdan commented Jan 30, 2025

This option should be available for run and serve. Basically for any container operation.

ramalama/cli.py Outdated Show resolved Hide resolved
@dougsland
Copy link
Collaborator

I am assuming this is related to --network=host and --network=private?

@rhjostone rhjostone force-pushed the network-enable-option branch 2 times, most recently from 1e71e79 to c925324 Compare January 31, 2025 15:48
@rhjostone
Copy link
Contributor Author

I am assuming this is related to --network=host and --network=private?

Yeah, this should let you set any network driver that's supported in podman/docker:

https://docs.podman.io/en/latest/markdown/podman-run.1.html#network-mode-net
https://docs.docker.com/engine/network/#drivers

ramalama/cli.py Outdated Show resolved Hide resolved
@rhatdan
Copy link
Member

rhatdan commented Feb 1, 2025

Thanks @rhjostone this is very good.

Please squash your commits.

git rebase -i origin
git push --force

@rhjostone rhjostone force-pushed the network-enable-option branch from c925324 to 5a392cd Compare February 1, 2025 13:13
@rhjostone
Copy link
Contributor Author

Thanks @rhjostone this is very good.

Please squash your commits.

git rebase -i origin git push --force

Done!

@rhatdan
Copy link
Member

rhatdan commented Feb 1, 2025

LGTM

@dougsland
Copy link
Collaborator

dougsland commented Feb 1, 2025

alright, lets do it. LGTM Thanks for checking @rhjostone

@rhjostone
Copy link
Contributor Author

Thanks @dougsland @rhatdan!

@rhjostone rhjostone force-pushed the network-enable-option branch from 5a392cd to ed4f322 Compare February 1, 2025 19:57
@rhatdan
Copy link
Member

rhatdan commented Feb 1, 2025

Test wants the options to be alphabetically sorted in the man pages.

@rhjostone rhjostone force-pushed the network-enable-option branch from ed4f322 to 59adf1a Compare February 1, 2025 23:35
@rhjostone
Copy link
Contributor Author

@rhatdan Does the ordering in the man pages look correct now?

Signed-off-by: Joshua Stone <[email protected]>
@rhjostone rhjostone requested review from slp and engelmi as code owners February 3, 2025 15:16
@dougsland
Copy link
Collaborator

CI/CD not related to this change. Personally, I would love to have a documentation explaining the options and showing what happens if you change from one option to another. However, can be in a different patch.

@dougsland
Copy link
Collaborator

As he fixed the last milestone as @rhatdan requested and the patch looks good, moving forward. Thanks @rhjostone

@dougsland dougsland merged commit dd93fd0 into containers:main Feb 3, 2025
3 of 6 checks passed
@rhjostone rhjostone deleted the network-enable-option branch February 3, 2025 15:46
@ericcurtin
Copy link
Collaborator

This PR should have not been merged @dougsland it didn't pass a single bats build

@ericcurtin
Copy link
Collaborator

Opening a revert PR.

@rhjostone after the revert is complete, could you push this PR again? We need to then fix the tests so we can merge it when it's green.

A lot of people are opening PRs right now and they are gonna fail unless we revert.

@dougsland
Copy link
Collaborator

Opening a revert PR.

@rhjostone after the revert is complete, could you push this PR again? We need to then fix the tests so we can merge it when it's green.

A lot of people are opening PRs right now and they are gonna fail unless we revert.

Could you please share the error @ericcurtin ? To me the CI/CD is already broken for ages.

@rhatdan
Copy link
Member

rhatdan commented Feb 4, 2025

This PR is reverted.

@ericcurtin
Copy link
Collaborator

Opening a revert PR.
@rhjostone after the revert is complete, could you push this PR again? We need to then fix the tests so we can merge it when it's green.
A lot of people are opening PRs right now and they are gonna fail unless we revert.

Could you please share the error @ericcurtin ? To me the CI/CD is already broken for ages.

The error is in the CI logs in this PR.

@rhjostone can you re-push this PR, work through the tests to get them passing please.

@rhjostone
Copy link
Contributor Author

@ericcurtin It looks like the PR was reverted, then re-merged thanks to @rhatdan:

760b6fd

Do I still have to re-push the PR?

@rhatdan
Copy link
Member

rhatdan commented Feb 4, 2025

No, I took care of it. Thanks alot @rhjostone

@rhjostone
Copy link
Contributor Author

Good to know, thanks!

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.

5 participants